Move Understanding Configmaps to a separate concept file
This commit is contained in:
parent
c27fc13f56
commit
71bd80d7bc
|
@ -11,7 +11,7 @@ redirect_from:
|
||||||
|
|
||||||
{% capture overview %}
|
{% capture overview %}
|
||||||
|
|
||||||
This page shows you how to configure an application using a ConfigMap.
|
This page shows you how to configure an application using a ConfigMap.
|
||||||
|
|
||||||
{% endcapture %}
|
{% endcapture %}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ This page shows you how to configure an application using a ConfigMap.
|
||||||
|
|
||||||
{% capture steps %}
|
{% capture steps %}
|
||||||
|
|
||||||
## Use kubectl to create a ConfigMap
|
## Use kubectl to create a ConfigMap
|
||||||
|
|
||||||
Use the `kubectl create configmap` command to create configmaps from [directories](#creating-configmaps-from-directories), [files](#creating-configmaps-from-files), or [literal values](#creating-configmaps-from-literal-values):
|
Use the `kubectl create configmap` command to create configmaps from [directories](#creating-configmaps-from-directories), [files](#creating-configmaps-from-files), or [literal values](#creating-configmaps-from-literal-values):
|
||||||
|
|
||||||
|
@ -33,17 +33,17 @@ kubectl create configmap <map-name> <data-source>
|
||||||
```
|
```
|
||||||
|
|
||||||
where \<map-name> is the name you want to assign to the ConfigMap and \<data-source> is the directory, file, or literal value to draw the data from.
|
where \<map-name> is the name you want to assign to the ConfigMap and \<data-source> 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
|
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
|
* 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.
|
* value = the file contents or the literal value you provided on the command line.
|
||||||
|
|
||||||
You can use [`kubectl describe`](docs/user-guide/kubectl/v1.6/#describe) or [`kubectl get`](docs/user-guide/kubectl/v1.6/#get) to retrieve information about a ConfigMap. The former shows a summary of the ConfigMap, while the latter returns the full contents of the ConfigMap.
|
You can use [`kubectl describe`](docs/user-guide/kubectl/v1.6/#describe) or [`kubectl get`](docs/user-guide/kubectl/v1.6/#get) to retrieve information about a ConfigMap. The former shows a summary of the ConfigMap, while the latter returns the full contents of the ConfigMap.
|
||||||
|
|
||||||
### Create ConfigMaps from directories
|
### Create ConfigMaps from directories
|
||||||
|
|
||||||
You can use `kubectl create configmap` to create a ConfigMap from multiple files in the same directory.
|
You can use `kubectl create configmap` to create a ConfigMap from multiple files in the same directory.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
@ -110,10 +110,10 @@ metadata:
|
||||||
|
|
||||||
You can use `kubectl create configmap` to create a ConfigMap from an individual file, or from multiple files.
|
You can use `kubectl create configmap` to create a ConfigMap from an individual file, or from multiple files.
|
||||||
|
|
||||||
For example,
|
For example,
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl create configmap game-config-2 --from-file=docs/user-guide/configmap/kubectl/game.properties
|
kubectl create configmap game-config-2 --from-file=docs/user-guide/configmap/kubectl/game.properties
|
||||||
```
|
```
|
||||||
|
|
||||||
would produce the following ConfigMap:
|
would produce the following ConfigMap:
|
||||||
|
@ -131,9 +131,9 @@ game.properties: 158 bytes
|
||||||
```
|
```
|
||||||
|
|
||||||
You can pass in the `--from-file` argument multiple times to create a ConfigMap from multiple data sources.
|
You can pass in the `--from-file` argument multiple times to create a ConfigMap from multiple data sources.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl create configmap game-config-2 --from-file=docs/user-guide/configmap/kubectl/game.properties --from-file=docs/user-guide/configmap/kubectl/ui.properties
|
kubectl create configmap game-config-2 --from-file=docs/user-guide/configmap/kubectl/game.properties --from-file=docs/user-guide/configmap/kubectl/ui.properties
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -158,8 +158,8 @@ kubectl create configmap game-config-3 --from-file=<my-key-name>=<path-to-file>
|
||||||
```
|
```
|
||||||
|
|
||||||
where `<my-key-name>` is the key you want to use in the ConfigMap and `<path-to-file>` is the location of the data source file you want the key to represent.
|
where `<my-key-name>` is the key you want to use in the ConfigMap and `<path-to-file>` is the location of the data source file you want the key to represent.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl create configmap game-config-3 --from-file=game-special-key=docs/user-guide/configmap/kubectl/game.properties
|
kubectl create configmap game-config-3 --from-file=game-special-key=docs/user-guide/configmap/kubectl/game.properties
|
||||||
|
@ -219,37 +219,6 @@ metadata:
|
||||||
|
|
||||||
{% endcapture %}
|
{% endcapture %}
|
||||||
|
|
||||||
{% capture discussion %}
|
|
||||||
|
|
||||||
## Understanding ConfigMaps
|
|
||||||
|
|
||||||
ConfigMaps allow you to decouple configuration artifacts from image content to keep containerized applications portable.
|
|
||||||
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 a 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.
|
|
||||||
|
|
||||||
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
|
|
||||||
kind: ConfigMap
|
|
||||||
apiVersion: v1
|
|
||||||
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
|
|
||||||
```
|
|
||||||
|
|
||||||
{% endcapture %}
|
|
||||||
|
|
||||||
{% capture whatsnext %}
|
{% capture whatsnext %}
|
||||||
* See [Using ConfigMap Data in Pods](/docs/tasks/configure-pod-container/configure-pod-configmap).
|
* See [Using ConfigMap Data in Pods](/docs/tasks/configure-pod-container/configure-pod-configmap).
|
||||||
* Follow a real world example of [Configuring Redis using a ConfigMap](/docs/tutorials/configuration/configure-redis-using-configmap/).
|
* Follow a real world example of [Configuring Redis using a ConfigMap](/docs/tutorials/configuration/configure-redis-using-configmap/).
|
||||||
|
|
Loading…
Reference in New Issue