From 8aa8acf64e18f8b0cf07a19216243c55e3cd20a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 3 Feb 2020 16:27:26 +0100 Subject: [PATCH 1/7] Add French configure-pod-configmap --- .../configure-pod-configmap.md | 682 ++++++++++++++++++ 1 file changed, 682 insertions(+) create mode 100644 content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md diff --git a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md new file mode 100644 index 0000000000..580f66ddef --- /dev/null +++ b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md @@ -0,0 +1,682 @@ +--- +title: Configure a Pod to Use a ConfigMap +content_template: templates/task +weight: 150 +card: + name: tasks + weight: 50 +--- + +{{% capture overview %}} +ConfigMaps allow you to decouple configuration artifacts from image content to keep containerized applications portable. +This page provides a series of usage examples demonstrating how to create ConfigMaps and configure Pods using data stored in ConfigMaps. + +{{% /capture %}} + +{{% capture prerequisites %}} + +{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} + +{{% /capture %}} + +{{% capture steps %}} + +## Create a ConfigMap + +You can use either `kubectl create configmap` or a ConfigMap generator in `kustomization.yaml` to create a ConfigMap. +Note that `kubectl` starts to support `kustomization.yaml` since 1.14. + +### Create a ConfigMap Using kubectl create configmap + +Use the `kubectl create configmap` command to create configmaps from [directories](#create-configmaps-from-directories), [files](#create-configmaps-from-files), or [literal values](#create-configmaps-from-literal-values): + +```shell +kubectl create configmap +``` + +where \ is the name you want to assign to the ConfigMap and \ is the directory, file, or literal value to draw the data from. + +The data source corresponds to a key-value pair in the ConfigMap, where + +* key = the file name or the key you provided on the command line, and +* value = the file contents or the literal value you provided on the command line. + +You can use [`kubectl describe`](/docs/reference/generated/kubectl/kubectl-commands/#describe) or [`kubectl get`](/docs/reference/generated/kubectl/kubectl-commands/#get) to retrieve information about a ConfigMap. + +#### Create ConfigMaps from directories + +You can use `kubectl create configmap` to create a ConfigMap from multiple files in the same directory. + +For example: + +```shell +# Create the local directory +mkdir -p configure-pod-container/configmap/ + +# Download the sample files into `configure-pod-container/configmap/` directory +wget https://kubernetes.io/examples/configmap/game.properties -O configure-pod-container/configmap/game.properties +wget https://kubernetes.io/examples/configmap/ui.properties -O configure-pod-container/configmap/ui.properties + +# Create the configmap +kubectl create configmap game-config --from-file=configure-pod-container/configmap/ +``` + +combines the contents of the `configure-pod-container/configmap/` directory + +```shell +game.properties +ui.properties +``` + +into the following ConfigMap: + +```shell +kubectl describe configmaps game-config +``` + +where the output is similar to this: + +```text +Name: game-config +Namespace: default +Labels: +Annotations: + +Data +==== +game.properties: 158 bytes +ui.properties: 83 bytes +``` + +The `game.properties` and `ui.properties` files in the `configure-pod-container/configmap/` directory are represented in the `data` section of the ConfigMap. + +```shell +kubectl get configmaps game-config -o yaml +``` + +The output is similar to this: + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2016-02-18T18:52:05Z + name: game-config + namespace: default + resourceVersion: "516" + uid: b4952dc3-d670-11e5-8cd0-68f728db1985 +data: + game.properties: | + enemies=aliens + lives=3 + enemies.cheat=true + enemies.cheat.level=noGoodRotten + secret.code.passphrase=UUDDLRLRBABAS + secret.code.allowed=true + secret.code.lives=30 + ui.properties: | + color.good=purple + color.bad=yellow + allow.textmode=true + how.nice.to.look=fairlyNice +``` + +#### Create ConfigMaps from files + +You can use `kubectl create configmap` to create a ConfigMap from an individual file, or from multiple files. + +For example, + +```shell +kubectl create configmap game-config-2 --from-file=configure-pod-container/configmap/game.properties +``` + +would produce the following ConfigMap: + +```shell +kubectl describe configmaps game-config-2 +``` + +where the output is similar to this: + +```text +Name: game-config-2 +Namespace: default +Labels: +Annotations: + +Data +==== +game.properties: 158 bytes +``` + +You can pass in the `--from-file` argument multiple times to create a ConfigMap from multiple data sources. + +```shell +kubectl create configmap game-config-2 --from-file=configure-pod-container/configmap/game.properties --from-file=configure-pod-container/configmap/ui.properties +``` + +Describe the above `game-config-2` configmap created + +```shell +kubectl describe configmaps game-config-2 +``` + +The output is similar to this: + +```text +Name: game-config-2 +Namespace: default +Labels: +Annotations: + +Data +==== +game.properties: 158 bytes +ui.properties: 83 bytes +``` + +Use the option `--from-env-file` to create a ConfigMap from an env-file, for example: + +```shell +# Env-files contain a list of environment variables. +# These syntax rules apply: +# Each line in an env file has to be in VAR=VAL format. +# Lines beginning with # (i.e. comments) are ignored. +# Blank lines are ignored. +# There is no special handling of quotation marks (i.e. they will be part of the ConfigMap value)). + +# Download the sample files into `configure-pod-container/configmap/` directory +wget https://kubernetes.io/examples/configmap/game-env-file.properties -O configure-pod-container/configmap/game-env-file.properties + +# The env-file `game-env-file.properties` looks like below +cat configure-pod-container/configmap/game-env-file.properties +enemies=aliens +lives=3 +allowed="true" + +# This comment and the empty line above it are ignored +``` + +```shell +kubectl create configmap game-config-env-file \ + --from-env-file=configure-pod-container/configmap/game-env-file.properties +``` + +would produce the following ConfigMap: + +```shell +kubectl get configmap game-config-env-file -o yaml +``` + +where the output is similar to this: + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2017-12-27T18:36:28Z + name: game-config-env-file + namespace: default + resourceVersion: "809965" + uid: d9d1ca5b-eb34-11e7-887b-42010a8002b8 +data: + allowed: '"true"' + enemies: aliens + lives: "3" +``` + +{{< caution >}} +When passing `--from-env-file` multiple times to create a ConfigMap from multiple data sources, only the last env-file is used. +{{< /caution >}} + +The behavior of passing `--from-env-file` multiple times is demonstrated by: + +```shell +# Download the sample files into `configure-pod-container/configmap/` directory +wget https://k8s.io/examples/configmap/ui-env-file.properties -O configure-pod-container/configmap/ui-env-file.properties + +# Create the configmap +kubectl create configmap config-multi-env-files \ + --from-env-file=configure-pod-container/configmap/game-env-file.properties \ + --from-env-file=configure-pod-container/configmap/ui-env-file.properties +``` + +would produce the following ConfigMap: + +```shell +kubectl get configmap config-multi-env-files -o yaml +``` + +where the output is similar to this: + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2017-12-27T18:38:34Z + name: config-multi-env-files + namespace: default + resourceVersion: "810136" + uid: 252c4572-eb35-11e7-887b-42010a8002b8 +data: + color: purple + how: fairlyNice + textmode: "true" +``` + +#### Define the key to use when creating a ConfigMap from a file + +You can define a key other than the file name to use in the `data` section of your ConfigMap when using the `--from-file` argument: + +```shell +kubectl create configmap game-config-3 --from-file== +``` + +where `` is the key you want to use in the ConfigMap and `` is the location of the data source file you want the key to represent. + +For example: + +```shell +kubectl create configmap game-config-3 --from-file=game-special-key=configure-pod-container/configmap/game.properties +``` + +would produce the following ConfigMap: + +```shell +kubectl get configmaps game-config-3 -o yaml +``` + +where the output is similar to this: + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2016-02-18T18:54:22Z + name: game-config-3 + namespace: default + resourceVersion: "530" + uid: 05f8da22-d671-11e5-8cd0-68f728db1985 +data: + game-special-key: | + enemies=aliens + lives=3 + enemies.cheat=true + enemies.cheat.level=noGoodRotten + secret.code.passphrase=UUDDLRLRBABAS + secret.code.allowed=true + secret.code.lives=30 +``` + +#### Create ConfigMaps from literal values + +You can use `kubectl create configmap` with the `--from-literal` argument to define a literal value from the command line: + +```shell +kubectl create configmap special-config --from-literal=special.how=very --from-literal=special.type=charm +``` + +You can pass in multiple key-value pairs. +Each pair provided on the command line is represented as a separate entry in the `data` section of the ConfigMap. + +```shell +kubectl get configmaps special-config -o yaml +``` + +The output is similar to this: + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2016-02-18T19:14:38Z + name: special-config + namespace: default + resourceVersion: "651" + uid: dadce046-d673-11e5-8cd0-68f728db1985 +data: + special.how: very + special.type: charm +``` + +### Create a ConfigMap from generator + +`kubectl` supports `kustomization.yaml` since 1.14. +You can also create a ConfigMap from generators and then apply it to create the object on the Apiserver. +The generators should be specified in a `kustomization.yaml` inside a directory. + +#### Generate ConfigMaps from files + +For example, to generate a ConfigMap from files `configure-pod-container/configmap/game.properties` + +```shell +# Create a kustomization.yaml file with ConfigMapGenerator +cat <./kustomization.yaml +configMapGenerator: +- name: game-config-4 + files: + - configure-pod-container/configmap/game.properties +EOF +``` + +Apply the kustomization directory to create the ConfigMap object. + +```shell +kubectl apply -k . +configmap/game-config-4-m9dm2f92bt created +``` + +You can check that the ConfigMap was created like this: + +```text +kubectl get configmap +NAME DATA AGE +game-config-4-m9dm2f92bt 1 37s + + +kubectl describe configmaps/game-config-4-m9dm2f92bt +Name: game-config-4-m9dm2f92bt +Namespace: default +Labels: +Annotations: kubectl.kubernetes.io/last-applied-configuration: + {"apiVersion":"v1","data":{"game.properties":"enemies=aliens\nlives=3\nenemies.cheat=true\nenemies.cheat.level=noGoodRotten\nsecret.code.p... + +Data +==== +game.properties: +---- +enemies=aliens +lives=3 +enemies.cheat=true +enemies.cheat.level=noGoodRotten +secret.code.passphrase=UUDDLRLRBABAS +secret.code.allowed=true +secret.code.lives=30 +Events: +``` + +Note that the generated ConfigMap name has a suffix appended by hashing the contents. +This ensures that a new ConfigMap is generated each time the content is modified. + +#### Define the key to use when generating a ConfigMap from a file + +You can define a key other than the file name to use in the ConfigMap generator. +For example, to generate a ConfigMap from files `configure-pod-container/configmap/game.properties` +with the key `game-special-key` + +```shell +# Create a kustomization.yaml file with ConfigMapGenerator +cat <./kustomization.yaml +configMapGenerator: +- name: game-config-5 + files: + - game-special-key=configure-pod-container/configmap/game.properties +EOF +``` + +Apply the kustomization directory to create the ConfigMap object. + +```text +kubectl apply -k . +configmap/game-config-5-m67dt67794 created +``` + +#### Generate ConfigMaps from Literals + +To generate a ConfigMap from literals `special.type=charm` and `special.how=very`, you can specify the ConfigMap generator in `kustomization.yaml` as + +```shell +# Create a kustomization.yaml file with ConfigMapGenerator +cat <./kustomization.yaml +configMapGenerator: +- name: special-config-2 + literals: + - special.how=very + - special.type=charm +EOF +``` + +Apply the kustomization directory to create the ConfigMap object. + +```text +kubectl apply -k . +configmap/special-config-2-c92b5mmcf2 created +``` + +## Define container environment variables using ConfigMap data + +### Define a container environment variable with data from a single ConfigMap + +1. Define an environment variable as a key-value pair in a ConfigMap: + + ```shell + kubectl create configmap special-config --from-literal=special.how=very + ``` + +1. Assign the `special.how` value defined in the ConfigMap to the `SPECIAL_LEVEL_KEY` environment variable in the Pod specification. + + {{< codenew file="pods/pod-single-configmap-env-variable.yaml" >}} + + Create the Pod: + + ```shell + kubectl create -f https://kubernetes.io/examples/pods/pod-single-configmap-env-variable.yaml + ``` + + Now, the Pod's output includes environment variable `SPECIAL_LEVEL_KEY=very`. + +### Define container environment variables with data from multiple ConfigMaps + +* As with the previous example, create the ConfigMaps first. + + {{< codenew file="configmap/configmaps.yaml" >}} + + Create the ConfigMap: + + ```shell + kubectl create -f https://kubernetes.io/examples/configmap/configmaps.yaml + ``` + +* Define the environment variables in the Pod specification. + + {{< codenew file="pods/pod-multiple-configmap-env-variable.yaml" >}} + + Create the Pod: + + ```shell + kubectl create -f https://kubernetes.io/examples/pods/pod-multiple-configmap-env-variable.yaml + ``` + + Now, the Pod's output includes environment variables `SPECIAL_LEVEL_KEY=very` and `LOG_LEVEL=INFO`. + +## Configure all key-value pairs in a ConfigMap as container environment variables + +{{< note >}} +This functionality is available in Kubernetes v1.6 and later. +{{< /note >}} + +* Create a ConfigMap containing multiple key-value pairs. + + {{< codenew file="configmap/configmap-multikeys.yaml" >}} + + Create the ConfigMap: + + ```shell + kubectl create -f https://kubernetes.io/examples/configmap/configmap-multikeys.yaml + ``` + +* Use `envFrom` to define all of the ConfigMap's data as container environment variables. + The key from the ConfigMap becomes the environment variable name in the Pod. + + {{< codenew file="pods/pod-configmap-envFrom.yaml" >}} + + Create the Pod: + + ```shell + kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-envFrom.yaml + ``` + + Now, the Pod's output includes environment variables `SPECIAL_LEVEL=very` and `SPECIAL_TYPE=charm`. + +## Use ConfigMap-defined environment variables in Pod commands + +You can use ConfigMap-defined environment variables in the `command` section of the Pod specification using the `$(VAR_NAME)` Kubernetes substitution syntax. + +For example, the following Pod specification + +{{< codenew file="pods/pod-configmap-env-var-valueFrom.yaml" >}} + +created by running + +```shell +kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-env-var-valueFrom.yaml +``` + +produces the following output in the `test-container` container: + +```shell +very charm +``` + +## Add ConfigMap data to a Volume + +As explained in [Create ConfigMaps from files](#create-configmaps-from-files), when you create a ConfigMap using ``--from-file``, the filename becomes a key stored in the `data` section of the ConfigMap. The file contents become the key's value. + +The examples in this section refer to a ConfigMap named special-config, shown below. + +{{< codenew file="configmap/configmap-multikeys.yaml" >}} + +Create the ConfigMap: + +```shell +kubectl create -f https://kubernetes.io/examples/configmap/configmap-multikeys.yaml +``` + +### Populate a Volume with data stored in a ConfigMap + +Add the ConfigMap name under the `volumes` section of the Pod specification. +This adds the ConfigMap data to the directory specified as `volumeMounts.mountPath` (in this case, `/etc/config`). +The `command` section lists directory files with names that match the keys in ConfigMap. + +{{< codenew file="pods/pod-configmap-volume.yaml" >}} + +Create the Pod: + +```shell +kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-volume.yaml +``` + +When the pod runs, the command `ls /etc/config/` produces the output below: + +```shell +SPECIAL_LEVEL +SPECIAL_TYPE +``` + +{{< caution >}} +If there are some files in the `/etc/config/` directory, they will be deleted. +{{< /caution >}} + +### Add ConfigMap data to a specific path in the Volume + +Use the `path` field to specify the desired file path for specific ConfigMap items. +In this case, the `SPECIAL_LEVEL` item will be mounted in the `config-volume` volume at `/etc/config/keys`. + +{{< codenew file="pods/pod-configmap-volume-specific-key.yaml" >}} + +Create the Pod: + +```shell +kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-volume-specific-key.yaml +``` + +When the pod runs, the command `cat /etc/config/keys` produces the output below: + +```shell +very +``` + +{{< caution >}} +Like before, all previous files in the `/etc/config/` directory will be deleted. +{{< /caution >}} + +### Project keys to specific paths and file permissions + +You can project keys to specific paths and specific permissions on a per-file +basis. The [Secrets](/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod) user guide explains the syntax. + +### Mounted ConfigMaps are updated automatically + +When a ConfigMap already being consumed in a volume is updated, projected keys are eventually updated as well. Kubelet is checking whether the mounted ConfigMap is fresh on every periodic sync. However, it is using its local ttl-based cache for getting the current value of the ConfigMap. As a result, the total delay from the moment when the ConfigMap is updated to the moment when new keys are projected to the pod can be as long as kubelet sync period (1 minute by default) + ttl of ConfigMaps cache (1 minute by default) in kubelet. You can trigger an immediate refresh by updating one of the pod's annotations. + +{{< note >}} +A container using a ConfigMap as a [subPath](/docs/concepts/storage/volumes/#using-subpath) volume will not receive ConfigMap updates. +{{< /note >}} + +{{% /capture %}} + +{{% capture discussion %}} + +## Understanding ConfigMaps and Pods + +The ConfigMap API resource stores configuration data as key-value pairs. The data can be consumed in pods or provide the configurations for system components such as controllers. ConfigMap is similar to [Secrets](/docs/concepts/configuration/secret/), but provides a means of working with strings that don't contain sensitive information. Users and system components alike can store configuration data in ConfigMap. + +{{< note >}} +ConfigMaps should reference properties files, not replace them. Think of the ConfigMap as representing something similar to the Linux `/etc` directory and its contents. For example, if you create a [Kubernetes Volume](/docs/concepts/storage/volumes/) from a ConfigMap, each data item in the ConfigMap is represented by an individual file in the volume. +{{< /note >}} + +The ConfigMap's `data` field contains the configuration data. As shown in the example below, this can be simple -- like individual properties defined using `--from-literal` -- or complex -- like configuration files or JSON blobs defined using `--from-file`. + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2016-02-18T19:14:38Z + name: example-config + namespace: default +data: + # example of a simple property defined using --from-literal + example.property.1: hello + example.property.2: world + # example of a complex property defined using --from-file + example.property.file: |- + property.1=value-1 + property.2=value-2 + property.3=value-3 +``` + +### Restrictions + +* You must create a ConfigMap before referencing it in a Pod specification (unless you mark the ConfigMap as "optional"). + If you reference a ConfigMap that doesn't exist, the Pod won't start. + Likewise, references to keys that don't exist in the ConfigMap will prevent the pod from starting. + +* If you use `envFrom` to define environment variables from ConfigMaps, keys that are considered invalid will be skipped. + The pod will be allowed to start, but the invalid names will be recorded in the event log (`InvalidVariableNames`). + The log message lists each skipped key. + For example: + + ```shell + kubectl get events + ``` + + The output is similar to this: + + ```text + LASTSEEN FIRSTSEEN COUNT NAME KIND SUBOBJECT TYPE REASON SOURCE MESSAGE + 0s 0s 1 dapi-test-pod Pod Warning InvalidEnvironmentVariableNames {kubelet, 127.0.0.1} Keys [1badkey, 2alsobad] from the EnvFrom configMap default/myconfig were skipped since they are considered invalid environment variable names. + ``` + +* ConfigMaps reside in a specific {{< glossary_tooltip term_id="namespace" >}}. + A ConfigMap can only be referenced by pods residing in the same namespace. + +* You can't use ConfigMaps for {{< glossary_tooltip text="static pods" term_id="static-pod" >}}, because the Kubelet does not support this. + +{{% /capture %}} + +{{% capture whatsnext %}} + +* Follow a real world example of [Configuring Redis using a ConfigMap](/docs/tutorials/configuration/configure-redis-using-configmap/). + +{{% /capture %}} From 6725d2888d244aa914ba6e36aba0565104f91d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Tue, 16 Jun 2020 07:18:55 +0200 Subject: [PATCH 2/7] Fix --- .../configure-pod-configmap.md | 231 +++++++++--------- 1 file changed, 116 insertions(+), 115 deletions(-) diff --git a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md index 580f66ddef..d3a0aa0aba 100644 --- a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md +++ b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md @@ -8,8 +8,8 @@ card: --- {{% capture overview %}} -ConfigMaps allow you to decouple configuration artifacts from image content to keep containerized applications portable. -This page provides a series of usage examples demonstrating how to create ConfigMaps and configure Pods using data stored in ConfigMaps. +Les ConfigMaps vous permettent de découpler les artefacts de configuration du contenu de l'image pour garder les applications conteneurisées portables. +Cette page fournit une série d'exemples d'utilisation montrant comment créer des ConfigMaps et configurer des pods à l'aide des données stockées dans des ConfigMaps. {{% /capture %}} @@ -21,60 +21,60 @@ This page provides a series of usage examples demonstrating how to create Config {{% capture steps %}} -## Create a ConfigMap +## Créer un ConfigMap -You can use either `kubectl create configmap` or a ConfigMap generator in `kustomization.yaml` to create a ConfigMap. -Note that `kubectl` starts to support `kustomization.yaml` since 1.14. +Vous pouvez utiliser soit `kubectl create configmap` ou un générateur ConfigMap dans `kustomization.yaml` pour créer un ConfigMap. +Notez que `kubectl` prends en charge `kustomization.yaml` à partir de la version 1.14. -### Create a ConfigMap Using kubectl create configmap +### Créer un ConfigMap à l'aide de kubectl create configmap -Use the `kubectl create configmap` command to create configmaps from [directories](#create-configmaps-from-directories), [files](#create-configmaps-from-files), or [literal values](#create-configmaps-from-literal-values): +Utilisez la commande `kubectl create configmap` pour créer des Configmaps depuis des [dossiers](#create-configmaps-from-directories), [fichiers](#create-configmaps-from-files), ou des [valeurs littérales](#create-configmaps-from-literal-values): ```shell kubectl create configmap ``` -where \ is the name you want to assign to the ConfigMap and \ is the directory, file, or literal value to draw the data from. +où \ est le nom que vous souhaitez attribuer à ConfigMap et \ est le répertoire, le fichier ou la valeur littérale à partir de laquelle récupérer les données. -The data source corresponds to a key-value pair in the ConfigMap, where +La source de données correspond à une paire clé-valeur dans ConfigMap, où -* key = the file name or the key you provided on the command line, and -* value = the file contents or the literal value you provided on the command line. +* clé = le nom du fichier ou la clé que vous avez fournie sur la ligne de commande, et +* valeur = le contenu du fichier ou la valeur littérale que vous avez fournie sur la ligne de commande. -You can use [`kubectl describe`](/docs/reference/generated/kubectl/kubectl-commands/#describe) or [`kubectl get`](/docs/reference/generated/kubectl/kubectl-commands/#get) to retrieve information about a ConfigMap. +Vous pouvez utiliser [`kubectl describe`](/docs/reference/generated/kubectl/kubectl-commands/#describe) ou [`kubectl get`](/docs/reference/generated/kubectl/kubectl-commands/#get) pour récupérer des informations sur un ConfigMap. -#### Create ConfigMaps from directories +#### Créer des ConfigMaps à partir de répertoires -You can use `kubectl create configmap` to create a ConfigMap from multiple files in the same directory. +Vous pouvez utiliser `kubectl create configmap` pour créer un ConfigMap à partir de plusieurs fichiers dans le même répertoire. -For example: +Par exemple: ```shell -# Create the local directory +# Créez le répertoire local mkdir -p configure-pod-container/configmap/ -# Download the sample files into `configure-pod-container/configmap/` directory +# Téléchargez les exemples de fichiers dans le répertoire `configure-pod-container/configmap/` wget https://kubernetes.io/examples/configmap/game.properties -O configure-pod-container/configmap/game.properties wget https://kubernetes.io/examples/configmap/ui.properties -O configure-pod-container/configmap/ui.properties -# Create the configmap +# Créer la configmap kubectl create configmap game-config --from-file=configure-pod-container/configmap/ ``` -combines the contents of the `configure-pod-container/configmap/` directory +combine le contenu du répertoire `configure-pod-container/configmap/` ```shell game.properties ui.properties ``` -into the following ConfigMap: +dans le ConfigMap suivant: ```shell kubectl describe configmaps game-config ``` -where the output is similar to this: +où la sortie est similaire à ceci: ```text Name: game-config @@ -88,13 +88,13 @@ game.properties: 158 bytes ui.properties: 83 bytes ``` -The `game.properties` and `ui.properties` files in the `configure-pod-container/configmap/` directory are represented in the `data` section of the ConfigMap. +Les fichiers `game.properties` et `ui.properties` dans le répertoire `configure-pod-container/configmap/` sont représentés dans la section `data` de la ConfigMap. ```shell kubectl get configmaps game-config -o yaml ``` -The output is similar to this: +La sortie est similaire à ceci: ```yaml apiVersion: v1 @@ -121,23 +121,23 @@ data: how.nice.to.look=fairlyNice ``` -#### Create ConfigMaps from files +#### Créer des ConfigMaps à partir de fichiers -You can use `kubectl create configmap` to create a ConfigMap from an individual file, or from multiple files. +Vous pouvez utiliser `kubectl create configmap` pour créer un ConfigMap à partir d'un fichier individuel ou de plusieurs fichiers. -For example, +Par exemple, ```shell kubectl create configmap game-config-2 --from-file=configure-pod-container/configmap/game.properties ``` -would produce the following ConfigMap: +produirait le ConfigMap suivant: ```shell kubectl describe configmaps game-config-2 ``` -where the output is similar to this: +où la sortie est similaire à ceci: ```text Name: game-config-2 @@ -150,19 +150,19 @@ Data game.properties: 158 bytes ``` -You can pass in the `--from-file` argument multiple times to create a ConfigMap from multiple data sources. +Vous pouvez passer l'argument `--from-file` plusieurs fois pour créer un ConfigMap à partir de plusieurs sources de données. ```shell kubectl create configmap game-config-2 --from-file=configure-pod-container/configmap/game.properties --from-file=configure-pod-container/configmap/ui.properties ``` -Describe the above `game-config-2` configmap created +Décrivez la ConfigMap crée `game-config-2`: ```shell kubectl describe configmaps game-config-2 ``` -The output is similar to this: +La sortie est similaire à ceci: ```text Name: game-config-2 @@ -176,26 +176,26 @@ game.properties: 158 bytes ui.properties: 83 bytes ``` -Use the option `--from-env-file` to create a ConfigMap from an env-file, for example: +Utilisez l'option `--from-env-file` pour créer un ConfigMap à partir d'un fichier env, par exemple: ```shell -# Env-files contain a list of environment variables. -# These syntax rules apply: -# Each line in an env file has to be in VAR=VAL format. -# Lines beginning with # (i.e. comments) are ignored. -# Blank lines are ignored. -# There is no special handling of quotation marks (i.e. they will be part of the ConfigMap value)). +# Les fichiers env contiennent une liste de variables d'environnement. +# Ces règles de syntaxe s'appliquent: +# Chaque ligne d'un fichier env doit être au format VAR=VAL. +# Les lignes commençant par # (c'est-à-dire les commentaires) sont ignorées. +# Les lignes vides sont ignorées. +# Il n'y a pas de traitement spécial des guillemets (c'est-à-dire qu'ils feront partie de la valeur ConfigMap)). -# Download the sample files into `configure-pod-container/configmap/` directory +# Téléchargez les exemples de fichiers dans le dossier `configure-pod-container/configmap/` wget https://kubernetes.io/examples/configmap/game-env-file.properties -O configure-pod-container/configmap/game-env-file.properties -# The env-file `game-env-file.properties` looks like below +# Le fichier env `game-env-file.properties` ressemble à ceci cat configure-pod-container/configmap/game-env-file.properties enemies=aliens lives=3 allowed="true" -# This comment and the empty line above it are ignored +# Ce commentaire et la ligne vide au-dessus sont ignorés ``` ```shell @@ -203,13 +203,13 @@ kubectl create configmap game-config-env-file \ --from-env-file=configure-pod-container/configmap/game-env-file.properties ``` -would produce the following ConfigMap: +produirait le ConfigMap suivant: ```shell kubectl get configmap game-config-env-file -o yaml ``` -where the output is similar to this: +où la sortie est similaire à ceci: ```yaml apiVersion: v1 @@ -227,28 +227,28 @@ data: ``` {{< caution >}} -When passing `--from-env-file` multiple times to create a ConfigMap from multiple data sources, only the last env-file is used. +Lorsque vous passez plusieurs fois `--from-env-file` pour créer un ConfigMap à partir de plusieurs sources de données, seul le dernier fichier env est utilisé. {{< /caution >}} -The behavior of passing `--from-env-file` multiple times is demonstrated by: +Le comportement consistant à passer plusieurs fois `--from-env-file` est démontré par: ```shell -# Download the sample files into `configure-pod-container/configmap/` directory +# Téléchargez les exemples de fichiers dans le répertoire `configure-pod-container/configmap/` wget https://k8s.io/examples/configmap/ui-env-file.properties -O configure-pod-container/configmap/ui-env-file.properties -# Create the configmap +# Créez le configmap kubectl create configmap config-multi-env-files \ --from-env-file=configure-pod-container/configmap/game-env-file.properties \ --from-env-file=configure-pod-container/configmap/ui-env-file.properties ``` -would produce the following ConfigMap: +produirait le ConfigMap suivant: ```shell kubectl get configmap config-multi-env-files -o yaml ``` -where the output is similar to this: +où la sortie est similaire à ceci: ```yaml apiVersion: v1 @@ -265,29 +265,29 @@ data: textmode: "true" ``` -#### Define the key to use when creating a ConfigMap from a file +#### Définissez la clé à utiliser lors de la création d'un ConfigMap à partir d'un fichier -You can define a key other than the file name to use in the `data` section of your ConfigMap when using the `--from-file` argument: +Vous pouvez définir une clé autre que le nom de fichier à utiliser dans la section `data` de votre ConfigMap lorsque vous utilisez l'argument `--from-file`: ```shell kubectl create configmap game-config-3 --from-file== ``` -where `` is the key you want to use in the ConfigMap and `` is the location of the data source file you want the key to represent. +où `` est la clé que vous souhaitez utiliser dans la ConfigMap et `` est l'emplacement du fichier de source de données que vous souhaitez que la clé représente. -For example: +Par exemple: ```shell kubectl create configmap game-config-3 --from-file=game-special-key=configure-pod-container/configmap/game.properties ``` -would produce the following ConfigMap: +produirait la ConfigMap suivante: ```shell kubectl get configmaps game-config-3 -o yaml ``` -where the output is similar to this: +où la sortie est similaire à ceci: ```yaml apiVersion: v1 @@ -309,22 +309,22 @@ data: secret.code.lives=30 ``` -#### Create ConfigMaps from literal values +#### Créer des ConfigMaps à partir de valeurs littérales -You can use `kubectl create configmap` with the `--from-literal` argument to define a literal value from the command line: +Vous pouvez utiliser `kubectl create configmap` avec l'argument `--from-literal` définir une valeur littérale à partir de la ligne de commande: ```shell kubectl create configmap special-config --from-literal=special.how=very --from-literal=special.type=charm ``` -You can pass in multiple key-value pairs. -Each pair provided on the command line is represented as a separate entry in the `data` section of the ConfigMap. +Vous pouvez transmettre plusieurs paires clé-valeur. +Chaque paire fournie sur la ligne de commande est représentée comme une entrée distincte dans la section `data` de la ConfigMap. ```shell kubectl get configmaps special-config -o yaml ``` -The output is similar to this: +La sortie est similaire à ceci: ```yaml apiVersion: v1 @@ -340,15 +340,15 @@ data: special.type: charm ``` -### Create a ConfigMap from generator +### Créer un ConfigMap à partir du générateur -`kubectl` supports `kustomization.yaml` since 1.14. -You can also create a ConfigMap from generators and then apply it to create the object on the Apiserver. -The generators should be specified in a `kustomization.yaml` inside a directory. +`kubectl` supporte `kustomization.yaml` depuis 1.14. +Vous pouvez également créer un ConfigMap à partir de générateurs, puis l'appliquer pour créer l'objet sur l'Apiserver. +Les générateurs doivent être spécifiés dans un `kustomization.yaml` à l'intérieur d'un répertoire. -#### Generate ConfigMaps from files +#### Générer des ConfigMaps à partir de fichiers -For example, to generate a ConfigMap from files `configure-pod-container/configmap/game.properties` +Par exemple, pour générer un ConfigMap à partir de fichiers `configure-pod-container/configmap/game.properties` ```shell # Create a kustomization.yaml file with ConfigMapGenerator @@ -360,14 +360,14 @@ configMapGenerator: EOF ``` -Apply the kustomization directory to create the ConfigMap object. +Appliquer le dossier kustomization pour créer l'objet ConfigMap. ```shell kubectl apply -k . configmap/game-config-4-m9dm2f92bt created ``` -You can check that the ConfigMap was created like this: +Vous pouvez vérifier que le ConfigMap a été créé comme ceci: ```text kubectl get configmap @@ -396,17 +396,17 @@ secret.code.lives=30 Events: ``` -Note that the generated ConfigMap name has a suffix appended by hashing the contents. -This ensures that a new ConfigMap is generated each time the content is modified. +Notez que le nom ConfigMap généré a un suffixe obtenu par hachage de son contenu. +Cela garantit qu'un nouveau ConfigMap est généré chaque fois que le contenu est modifié. -#### Define the key to use when generating a ConfigMap from a file +#### Définissez la clé à utiliser lors de la génération d'un ConfigMap à partir d'un fichier -You can define a key other than the file name to use in the ConfigMap generator. -For example, to generate a ConfigMap from files `configure-pod-container/configmap/game.properties` -with the key `game-special-key` +Vous pouvez définir une clé autre que le nom de fichier à utiliser dans le générateur ConfigMap. +Par exemple, pour générer un ConfigMap à partir du fichier `configure-pod-container/configmap/game.properties` +avec la clé `game-special-key` ```shell -# Create a kustomization.yaml file with ConfigMapGenerator +# Créer un fichier kustomization.yaml avec ConfigMapGenerator cat <./kustomization.yaml configMapGenerator: - name: game-config-5 @@ -415,16 +415,16 @@ configMapGenerator: EOF ``` -Apply the kustomization directory to create the ConfigMap object. +Appliquer le dossier kustomization pour créer l'objet ConfigMap. ```text kubectl apply -k . configmap/game-config-5-m67dt67794 created ``` -#### Generate ConfigMaps from Literals +#### Générer des ConfigMaps à partir de littéraux -To generate a ConfigMap from literals `special.type=charm` and `special.how=very`, you can specify the ConfigMap generator in `kustomization.yaml` as +Pour générer un ConfigMap à partir de littéraux `special.type=charm` et `special.how=very`, vous pouvez spécifier le générateur ConfigMap dans `kustomization.yaml` comme ```shell # Create a kustomization.yaml file with ConfigMapGenerator @@ -437,137 +437,138 @@ configMapGenerator: EOF ``` -Apply the kustomization directory to create the ConfigMap object. +Appliquez le dossier kustomization pour créer l'objet ConfigMap. ```text kubectl apply -k . configmap/special-config-2-c92b5mmcf2 created ``` -## Define container environment variables using ConfigMap data +## Définir des variables d'environnement de conteneur à l'aide des données ConfigMap -### Define a container environment variable with data from a single ConfigMap +### Définissez une variable d'environnement de conteneur avec les données d'une seule ConfigMap -1. Define an environment variable as a key-value pair in a ConfigMap: +1. Définissez une variable d'environnement comme paire clé-valeur dans un ConfigMap: ```shell kubectl create configmap special-config --from-literal=special.how=very ``` -1. Assign the `special.how` value defined in the ConfigMap to the `SPECIAL_LEVEL_KEY` environment variable in the Pod specification. +1. Attribuez la valeur `special.how` défini dans ConfigMap à la variable d'environnement `SPECIAL_LEVEL_KEY` dans la spécification du Pod. {{< codenew file="pods/pod-single-configmap-env-variable.yaml" >}} - Create the Pod: + Créez le pod: ```shell kubectl create -f https://kubernetes.io/examples/pods/pod-single-configmap-env-variable.yaml ``` - Now, the Pod's output includes environment variable `SPECIAL_LEVEL_KEY=very`. + Maintenant, la sortie du Pod comprend une variable d'environnement `SPECIAL_LEVEL_KEY=very`. -### Define container environment variables with data from multiple ConfigMaps +### Définir des variables d'environnement de conteneur avec des données de plusieurs ConfigMaps -* As with the previous example, create the ConfigMaps first. +* Comme avec l'exemple précédent, créez d'abord les ConfigMaps. {{< codenew file="configmap/configmaps.yaml" >}} - Create the ConfigMap: + Créez le ConfigMap: ```shell kubectl create -f https://kubernetes.io/examples/configmap/configmaps.yaml ``` -* Define the environment variables in the Pod specification. +* Définissez les variables d'environnement dans la spécification Pod. {{< codenew file="pods/pod-multiple-configmap-env-variable.yaml" >}} - Create the Pod: + Créez le pod: ```shell kubectl create -f https://kubernetes.io/examples/pods/pod-multiple-configmap-env-variable.yaml ``` - Now, the Pod's output includes environment variables `SPECIAL_LEVEL_KEY=very` and `LOG_LEVEL=INFO`. + Maintenant, la sortie du Pod comprend des variables d'environnement `SPECIAL_LEVEL_KEY=very` et `LOG_LEVEL=INFO`. -## Configure all key-value pairs in a ConfigMap as container environment variables +## Configurer toutes les paires clé-valeur dans un ConfigMap en tant que variables d'environnement de conteneur {{< note >}} -This functionality is available in Kubernetes v1.6 and later. +Cette fonctionnalité est disponible dans Kubernetes v1.6 et versions ultérieures. {{< /note >}} -* Create a ConfigMap containing multiple key-value pairs. +* Créez un ConfigMap contenant plusieurs paires clé-valeur. {{< codenew file="configmap/configmap-multikeys.yaml" >}} - Create the ConfigMap: + Créez le ConfigMap: ```shell kubectl create -f https://kubernetes.io/examples/configmap/configmap-multikeys.yaml ``` -* Use `envFrom` to define all of the ConfigMap's data as container environment variables. - The key from the ConfigMap becomes the environment variable name in the Pod. +* Utilisez `envFrom` pour définir toutes les données du ConfigMap en tant que variables d'environnement du conteneur. + La clé de ConfigMap devient le nom de la variable d'environnement dans le pod. {{< codenew file="pods/pod-configmap-envFrom.yaml" >}} - Create the Pod: + Créez le pod: ```shell kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-envFrom.yaml ``` - Now, the Pod's output includes environment variables `SPECIAL_LEVEL=very` and `SPECIAL_TYPE=charm`. + Maintenant, la sortie du Pod comprend les variables d'environnement `SPECIAL_LEVEL=very` et `SPECIAL_TYPE=charm`. -## Use ConfigMap-defined environment variables in Pod commands +## Utiliser des variables d'environnement définies par ConfigMap dans les commandes du Pod -You can use ConfigMap-defined environment variables in the `command` section of the Pod specification using the `$(VAR_NAME)` Kubernetes substitution syntax. +Vous pouvez utiliser des variables d'environnement définies par ConfigMap dans la section `command` de la spécification du Pod en utilisant la syntaxe de substitution Kubernetes `$(VAR_NAME)`. -For example, the following Pod specification +Par exemple, la spécification de pod suivante {{< codenew file="pods/pod-configmap-env-var-valueFrom.yaml" >}} -created by running +créé en exécutant ```shell kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-env-var-valueFrom.yaml ``` -produces the following output in the `test-container` container: +produit la sortie suivante dans le conteneur `test-container`: ```shell very charm ``` -## Add ConfigMap data to a Volume +## Ajouter des données ConfigMap à un volume -As explained in [Create ConfigMaps from files](#create-configmaps-from-files), when you create a ConfigMap using ``--from-file``, the filename becomes a key stored in the `data` section of the ConfigMap. The file contents become the key's value. +Comme expliqué dans [Créer des ConfigMaps à partir de fichiers](#create-configmaps-from-files), lorsque vous créez un ConfigMap à l'aide `--from-file`, le nom de fichier devient une clé stockée dans la section `data` du ConfigMap. +Le contenu du fichier devient la valeur de la clé. -The examples in this section refer to a ConfigMap named special-config, shown below. +Les exemples de cette section se réfèrent à un ConfigMap nommé special-config, illustré ci-dessous. {{< codenew file="configmap/configmap-multikeys.yaml" >}} -Create the ConfigMap: +Créez le ConfigMap: ```shell kubectl create -f https://kubernetes.io/examples/configmap/configmap-multikeys.yaml ``` -### Populate a Volume with data stored in a ConfigMap +### Remplissez un volume avec des données stockées dans un ConfigMap -Add the ConfigMap name under the `volumes` section of the Pod specification. -This adds the ConfigMap data to the directory specified as `volumeMounts.mountPath` (in this case, `/etc/config`). -The `command` section lists directory files with names that match the keys in ConfigMap. +Ajoutez le nom ConfigMap sous la section `volumes` de la spécification Pod. +Ceci ajoute les données ConfigMap au répertoire spécifié comme `volumeMounts.mountPath` (dans ce cas, `/etc/config`). +La section `command` répertorie les fichiers de répertoire dont les noms correspondent aux clés de ConfigMap. {{< codenew file="pods/pod-configmap-volume.yaml" >}} -Create the Pod: +Créez le pod: ```shell kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-volume.yaml ``` -When the pod runs, the command `ls /etc/config/` produces the output below: +Lorsque le pod s'exécute, la commande `ls /etc/config/` produit la sortie ci-dessous: ```shell SPECIAL_LEVEL @@ -575,7 +576,7 @@ SPECIAL_TYPE ``` {{< caution >}} -If there are some files in the `/etc/config/` directory, they will be deleted. +S'il y a des fichiers dans le dossier `/etc/config/`, ils seront supprimés. {{< /caution >}} ### Add ConfigMap data to a specific path in the Volume From fb9823b9ecba18686d2d6acc760f395a08857cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Sat, 10 Apr 2021 17:23:40 +0200 Subject: [PATCH 3/7] Fix --- .../configure-pod-configmap.md | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md index d3a0aa0aba..72e642b12d 100644 --- a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md +++ b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md @@ -579,55 +579,65 @@ SPECIAL_TYPE S'il y a des fichiers dans le dossier `/etc/config/`, ils seront supprimés. {{< /caution >}} -### Add ConfigMap data to a specific path in the Volume +### Ajouter un configmap à un chemin spécifique dans un volume -Use the `path` field to specify the desired file path for specific ConfigMap items. -In this case, the `SPECIAL_LEVEL` item will be mounted in the `config-volume` volume at `/etc/config/keys`. +Utilisez le champ `path` pour spécifier le chemin de fichier souhaité pour les éléments de configmap spécifiques. +Dans ce cas, le `SPECIAL_LEVEL` sera monté dans le volume `config-volume` au chemin `/etc/config/keys`. {{< codenew file="pods/pod-configmap-volume-specific-key.yaml" >}} -Create the Pod: +Créez le Pod : ```shell kubectl create -f https://kubernetes.io/examples/pods/pod-configmap-volume-specific-key.yaml ``` -When the pod runs, the command `cat /etc/config/keys` produces the output below: +Lorsque le pod fonctionne, la commande `cat /etc/config/keys` produit la sortie ci-dessous : ```shell very ``` {{< caution >}} -Like before, all previous files in the `/etc/config/` directory will be deleted. +Comme avant, tous les fichiers précédents dans le répertoire `/etc/config/` seront supprimés. {{< /caution >}} -### Project keys to specific paths and file permissions +### Clés de projet pour des chemins et des autorisations de fichiers spécifiques -You can project keys to specific paths and specific permissions on a per-file -basis. The [Secrets](/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod) user guide explains the syntax. +You can project keys to specific paths and specific permissions on a per-file basis. +Le guide de l'utilisateur [Secrets](/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod) explique la syntaxe. -### Mounted ConfigMaps are updated automatically +### Les ConfigMaps montées sont mises à jour automatiquement -When a ConfigMap already being consumed in a volume is updated, projected keys are eventually updated as well. Kubelet is checking whether the mounted ConfigMap is fresh on every periodic sync. However, it is using its local ttl-based cache for getting the current value of the ConfigMap. As a result, the total delay from the moment when the ConfigMap is updated to the moment when new keys are projected to the pod can be as long as kubelet sync period (1 minute by default) + ttl of ConfigMaps cache (1 minute by default) in kubelet. You can trigger an immediate refresh by updating one of the pod's annotations. +Lorsqu'une ConfigMap déjà consommée dans un volume est mise à jour, les clés projetées sont éventuellement mises à jour elles aussi. +Kubelet vérifie si la ConfigMap montée est fraîche à chaque synchronisation périodique. +Cependant, il utilise son cache local basé sur le ttl pour obtenir la valeur actuelle de la ConfigMap. +Par conséquent, le délai total entre le moment où la ConfigMap est mise à jour et le moment où les nouvelles clés sont projetées vers le pod peut être aussi long que la période de synchronisation de kubelet (1 minute par défaut) + le ttl du cache ConfigMaps (1 minute par défaut) dans kubelet. +Vous pouvez déclencher un rafraîchissement immédiat en mettant à jour l'une des annotations du pod. {{< note >}} -A container using a ConfigMap as a [subPath](/docs/concepts/storage/volumes/#using-subpath) volume will not receive ConfigMap updates. +Un conteneur utilisant un ConfigMap comme volume [subPath](/docs/concepts/storage/volumes/#using-subpath) ne recevra pas les mises à jour de ConfigMap. {{< /note >}} {{% /capture %}} {{% capture discussion %}} -## Understanding ConfigMaps and Pods +## Comprendre le lien entre les ConfigMaps et les Pods -The ConfigMap API resource stores configuration data as key-value pairs. The data can be consumed in pods or provide the configurations for system components such as controllers. ConfigMap is similar to [Secrets](/docs/concepts/configuration/secret/), but provides a means of working with strings that don't contain sensitive information. Users and system components alike can store configuration data in ConfigMap. +La ressource API ConfigMap stocke les données de configuration sous forme de paires clé-valeur. +Les données peuvent être consommées dans des pods ou fournir les configurations des composants du système tels que les contrôleurs. +ConfigMap est similaire à [Secrets](/docs/concepts/configuration/secret/), mais fournit un moyen de travailler avec des chaînes de caractères qui ne contiennent pas d'informations sensibles. +Les utilisateurs comme les composants du système peuvent stocker des données de configuration dans un ConfigMap. {{< note >}} -ConfigMaps should reference properties files, not replace them. Think of the ConfigMap as representing something similar to the Linux `/etc` directory and its contents. For example, if you create a [Kubernetes Volume](/docs/concepts/storage/volumes/) from a ConfigMap, each data item in the ConfigMap is represented by an individual file in the volume. +Les ConfigMaps doivent faire référence aux fichiers de propriétés, et non les remplacer. +Pensez à la ConfigMap comme représentant quelque chose de similaire au répertoire `/etc` de Linux et à son contenu. +Par exemple, si vous créez un [volume Kubernetes] (/docs/concepts/storage/volumes/) à partir d'une ConfigMap, chaque élément de données de la ConfigMap est représenté par un fichier individuel dans le volume. {{< /note >}} -The ConfigMap's `data` field contains the configuration data. As shown in the example below, this can be simple -- like individual properties defined using `--from-literal` -- or complex -- like configuration files or JSON blobs defined using `--from-file`. +Le champ `data` de la ConfigMap contient les données de configuration. +Comme le montre l'exemple ci-dessous, cela peut être simple -- comme des propriétés individuelles définies à l'aide de `--from-literal` -- ou complexe -- comme des fichiers de configuration ou des blobs JSON définis à l'aide de `--from-file`. ```yaml apiVersion: v1 @@ -649,35 +659,35 @@ data: ### Restrictions -* You must create a ConfigMap before referencing it in a Pod specification (unless you mark the ConfigMap as "optional"). - If you reference a ConfigMap that doesn't exist, the Pod won't start. - Likewise, references to keys that don't exist in the ConfigMap will prevent the pod from starting. +* Vous devez créer un ConfigMap avant de le référencer dans une spécification de Pod (sauf si vous marquez le ConfigMap comme "facultatif"). + Si vous faites référence à un ConfigMap qui n'existe pas, le Pod ne démarrera pas. + De même, les références à des clés qui n'existent pas dans la ConfigMap empêcheront le pod de démarrer. -* If you use `envFrom` to define environment variables from ConfigMaps, keys that are considered invalid will be skipped. - The pod will be allowed to start, but the invalid names will be recorded in the event log (`InvalidVariableNames`). - The log message lists each skipped key. - For example: +* Si vous utilisez `envFrom` pour définir des variables d'environnement à partir de ConfigMaps, les clés considérées comme invalides seront ignorées. + Le pod sera autorisé à démarrer, mais les noms invalides seront enregistrés dans le journal des événements (`InvalidVariableNames`). + Le message du journal énumère chaque clé sautée. + Par exemple : ```shell kubectl get events ``` - The output is similar to this: + Le résultat est similaire à celui-ci : ```text LASTSEEN FIRSTSEEN COUNT NAME KIND SUBOBJECT TYPE REASON SOURCE MESSAGE 0s 0s 1 dapi-test-pod Pod Warning InvalidEnvironmentVariableNames {kubelet, 127.0.0.1} Keys [1badkey, 2alsobad] from the EnvFrom configMap default/myconfig were skipped since they are considered invalid environment variable names. ``` -* ConfigMaps reside in a specific {{< glossary_tooltip term_id="namespace" >}}. - A ConfigMap can only be referenced by pods residing in the same namespace. +* Les ConfigMaps résident dans un {{< glossary_tooltip term_id="namespace" >}}. + Un ConfigMap ne peut être référencé que par des pods résidant dans le même namespace. -* You can't use ConfigMaps for {{< glossary_tooltip text="static pods" term_id="static-pod" >}}, because the Kubelet does not support this. +* Vous ne pouvez pas utiliser des ConfigMaps pour {{< glossary_tooltip text="static pods" term_id="static-pod" >}}, car le Kubelet ne le supporte pas. {{% /capture %}} {{% capture whatsnext %}} -* Follow a real world example of [Configuring Redis using a ConfigMap](/docs/tutorials/configuration/configure-redis-using-configmap/). +* Suivez un exemple concret de [Configurer Redis en utilisant un ConfigMap](/docs/tutorials/configuration/configure-redis-using-configmap/). {{% /capture %}} From 049c832f33b813b9599845f7642869996b1c2dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Sat, 10 Apr 2021 22:52:11 +0200 Subject: [PATCH 4/7] Fix --- .../configure-pod-configmap.md | 4 ++-- .../configmap/configmap-multikeys.yaml | 8 +++++++ content/fr/examples/configmap/configmaps.yaml | 15 +++++++++++++ .../pods/pod-configmap-env-var-valueFrom.yaml | 21 +++++++++++++++++++ .../examples/pods/pod-configmap-envFrom.yaml | 13 ++++++++++++ .../pod-configmap-volume-specific-key.yaml | 20 ++++++++++++++++++ .../examples/pods/pod-configmap-volume.yaml | 18 ++++++++++++++++ .../pod-multiple-configmap-env-variable.yaml | 21 +++++++++++++++++++ .../pod-single-configmap-env-variable.yaml | 19 +++++++++++++++++ 9 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 content/fr/examples/configmap/configmap-multikeys.yaml create mode 100644 content/fr/examples/configmap/configmaps.yaml create mode 100644 content/fr/examples/pods/pod-configmap-env-var-valueFrom.yaml create mode 100644 content/fr/examples/pods/pod-configmap-envFrom.yaml create mode 100644 content/fr/examples/pods/pod-configmap-volume-specific-key.yaml create mode 100644 content/fr/examples/pods/pod-configmap-volume.yaml create mode 100644 content/fr/examples/pods/pod-multiple-configmap-env-variable.yaml create mode 100644 content/fr/examples/pods/pod-single-configmap-env-variable.yaml diff --git a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md index 72e642b12d..ce2c14dc99 100644 --- a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md +++ b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md @@ -602,9 +602,9 @@ very Comme avant, tous les fichiers précédents dans le répertoire `/etc/config/` seront supprimés. {{< /caution >}} -### Clés de projet pour des chemins et des autorisations de fichiers spécifiques +### Projections de clés pour des chemins et des autorisations de fichiers spécifiques -You can project keys to specific paths and specific permissions on a per-file basis. +Vous pouvez projeter des clés vers des chemins spécifiques avec des autorisations spécifiques fichiers par fichiers. Le guide de l'utilisateur [Secrets](/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod) explique la syntaxe. ### Les ConfigMaps montées sont mises à jour automatiquement diff --git a/content/fr/examples/configmap/configmap-multikeys.yaml b/content/fr/examples/configmap/configmap-multikeys.yaml new file mode 100644 index 0000000000..289702d123 --- /dev/null +++ b/content/fr/examples/configmap/configmap-multikeys.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: special-config + namespace: default +data: + SPECIAL_LEVEL: very + SPECIAL_TYPE: charm diff --git a/content/fr/examples/configmap/configmaps.yaml b/content/fr/examples/configmap/configmaps.yaml new file mode 100644 index 0000000000..91b9f29755 --- /dev/null +++ b/content/fr/examples/configmap/configmaps.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: special-config + namespace: default +data: + special.how: very +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: env-config + namespace: default +data: + log_level: INFO diff --git a/content/fr/examples/pods/pod-configmap-env-var-valueFrom.yaml b/content/fr/examples/pods/pod-configmap-env-var-valueFrom.yaml new file mode 100644 index 0000000000..00827ec98a --- /dev/null +++ b/content/fr/examples/pods/pod-configmap-env-var-valueFrom.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Pod +metadata: + name: dapi-test-pod +spec: + containers: + - name: test-container + image: k8s.gcr.io/busybox + command: [ "/bin/echo", "$(SPECIAL_LEVEL_KEY) $(SPECIAL_TYPE_KEY)" ] + env: + - name: SPECIAL_LEVEL_KEY + valueFrom: + configMapKeyRef: + name: special-config + key: SPECIAL_LEVEL + - name: SPECIAL_TYPE_KEY + valueFrom: + configMapKeyRef: + name: special-config + key: SPECIAL_TYPE + restartPolicy: Never diff --git a/content/fr/examples/pods/pod-configmap-envFrom.yaml b/content/fr/examples/pods/pod-configmap-envFrom.yaml new file mode 100644 index 0000000000..70ae7e5bcf --- /dev/null +++ b/content/fr/examples/pods/pod-configmap-envFrom.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Pod +metadata: + name: dapi-test-pod +spec: + containers: + - name: test-container + image: k8s.gcr.io/busybox + command: [ "/bin/sh", "-c", "env" ] + envFrom: + - configMapRef: + name: special-config + restartPolicy: Never diff --git a/content/fr/examples/pods/pod-configmap-volume-specific-key.yaml b/content/fr/examples/pods/pod-configmap-volume-specific-key.yaml new file mode 100644 index 0000000000..72e38fd836 --- /dev/null +++ b/content/fr/examples/pods/pod-configmap-volume-specific-key.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Pod +metadata: + name: dapi-test-pod +spec: + containers: + - name: test-container + image: k8s.gcr.io/busybox + command: [ "/bin/sh","-c","cat /etc/config/keys" ] + volumeMounts: + - name: config-volume + mountPath: /etc/config + volumes: + - name: config-volume + configMap: + name: special-config + items: + - key: SPECIAL_LEVEL + path: keys + restartPolicy: Never diff --git a/content/fr/examples/pods/pod-configmap-volume.yaml b/content/fr/examples/pods/pod-configmap-volume.yaml new file mode 100644 index 0000000000..478c2e8d2b --- /dev/null +++ b/content/fr/examples/pods/pod-configmap-volume.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + name: dapi-test-pod +spec: + containers: + - name: test-container + image: k8s.gcr.io/busybox + command: [ "/bin/sh", "-c", "ls /etc/config/" ] + volumeMounts: + - name: config-volume + mountPath: /etc/config + volumes: + - name: config-volume + configMap: + # Indiquez le nom de la ConfigMap contenant les fichiers que vous souhaitez ajouter au conteneur + name: special-config + restartPolicy: Never diff --git a/content/fr/examples/pods/pod-multiple-configmap-env-variable.yaml b/content/fr/examples/pods/pod-multiple-configmap-env-variable.yaml new file mode 100644 index 0000000000..4790a9c661 --- /dev/null +++ b/content/fr/examples/pods/pod-multiple-configmap-env-variable.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Pod +metadata: + name: dapi-test-pod +spec: + containers: + - name: test-container + image: k8s.gcr.io/busybox + command: [ "/bin/sh", "-c", "env" ] + env: + - name: SPECIAL_LEVEL_KEY + valueFrom: + configMapKeyRef: + name: special-config + key: special.how + - name: LOG_LEVEL + valueFrom: + configMapKeyRef: + name: env-config + key: log_level + restartPolicy: Never diff --git a/content/fr/examples/pods/pod-single-configmap-env-variable.yaml b/content/fr/examples/pods/pod-single-configmap-env-variable.yaml new file mode 100644 index 0000000000..09d6f4a696 --- /dev/null +++ b/content/fr/examples/pods/pod-single-configmap-env-variable.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Pod +metadata: + name: dapi-test-pod +spec: + containers: + - name: test-container + image: k8s.gcr.io/busybox + command: [ "/bin/sh", "-c", "env" ] + env: + # Définie la variable d'environnement + - name: SPECIAL_LEVEL_KEY + valueFrom: + configMapKeyRef: + # La ConfigMap contenant la valeur que vous voulez attribuer à SPECIAL_LEVEL_KEY + name: special-config + # Spécifier la clé associée à la valeur + key: special.how + restartPolicy: Never From 6e1b8d8b2d62f054b057921f5664b08f17379484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Sun, 11 Apr 2021 12:27:16 +0200 Subject: [PATCH 5/7] Fix --- .../configure-pod-configmap.md | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md index ce2c14dc99..93c6d1725a 100644 --- a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md +++ b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md @@ -7,19 +7,16 @@ card: weight: 50 --- -{{% capture overview %}} + + Les ConfigMaps vous permettent de découpler les artefacts de configuration du contenu de l'image pour garder les applications conteneurisées portables. Cette page fournit une série d'exemples d'utilisation montrant comment créer des ConfigMaps et configurer des pods à l'aide des données stockées dans des ConfigMaps. -{{% /capture %}} - -{{% capture prerequisites %}} +## {{% heading "prerequisites" %}} {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} -{{% /capture %}} - -{{% capture steps %}} + ## Créer un ConfigMap @@ -619,9 +616,7 @@ Vous pouvez déclencher un rafraîchissement immédiat en mettant à jour l'une Un conteneur utilisant un ConfigMap comme volume [subPath](/docs/concepts/storage/volumes/#using-subpath) ne recevra pas les mises à jour de ConfigMap. {{< /note >}} -{{% /capture %}} - -{{% capture discussion %}} + ## Comprendre le lien entre les ConfigMaps et les Pods @@ -684,10 +679,6 @@ data: * Vous ne pouvez pas utiliser des ConfigMaps pour {{< glossary_tooltip text="static pods" term_id="static-pod" >}}, car le Kubelet ne le supporte pas. -{{% /capture %}} - -{{% capture whatsnext %}} +{{% heading "whatsnext" %}} * Suivez un exemple concret de [Configurer Redis en utilisant un ConfigMap](/docs/tutorials/configuration/configure-redis-using-configmap/). - -{{% /capture %}} From c32a1194687b362af9731418677cf8617eaacafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 23 Apr 2021 12:03:01 +0200 Subject: [PATCH 6/7] Update content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md Co-authored-by: Johan BONTEMPS --- .../tasks/configure-pod-container/configure-pod-configmap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md index 93c6d1725a..11e34afe2a 100644 --- a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md +++ b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md @@ -628,7 +628,7 @@ Les utilisateurs comme les composants du système peuvent stocker des données d {{< note >}} Les ConfigMaps doivent faire référence aux fichiers de propriétés, et non les remplacer. Pensez à la ConfigMap comme représentant quelque chose de similaire au répertoire `/etc` de Linux et à son contenu. -Par exemple, si vous créez un [volume Kubernetes] (/docs/concepts/storage/volumes/) à partir d'une ConfigMap, chaque élément de données de la ConfigMap est représenté par un fichier individuel dans le volume. +Par exemple, si vous créez un [volume Kubernetes](/docs/concepts/storage/volumes/) à partir d'une ConfigMap, chaque élément de données de la ConfigMap est représenté par un fichier individuel dans le volume. {{< /note >}} Le champ `data` de la ConfigMap contient les données de configuration. From f587b8711644fd785db50f3e663c032c3932d354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 23 Apr 2021 15:31:17 +0200 Subject: [PATCH 7/7] Fix --- .../tasks/configure-pod-container/configure-pod-configmap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md index 11e34afe2a..6e9c4c5ba6 100644 --- a/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md +++ b/content/fr/docs/tasks/configure-pod-container/configure-pod-configmap.md @@ -1,5 +1,5 @@ --- -title: Configure a Pod to Use a ConfigMap +title: Configurer un pod pour utiliser une ConfigMap content_template: templates/task weight: 150 card: