mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Merge pull request #19923 from pmorie/config-volume-proposal
Auto commit by PR queue bot
This commit is contained in:
commit
6f1ec1b946
@ -31,12 +31,12 @@ Documentation for other releases can be found at
|
|||||||
|
|
||||||
## Abstract
|
## Abstract
|
||||||
|
|
||||||
This proposal proposes a new API resource, `ConfigMap`, that stores data used for the configuration
|
The `ConfigMap` API resource stores data used for the configuration of applications deployed on
|
||||||
of applications deployed on `Kubernetes`.
|
Kubernetes.
|
||||||
|
|
||||||
The main focus points of this proposal are:
|
The main focus of this resource is to:
|
||||||
|
|
||||||
* Dynamic distribution of configuration data to deployed applications.
|
* Provide dynamic distribution of configuration data to deployed applications.
|
||||||
* Encapsulate configuration information and simplify `Kubernetes` deployments.
|
* Encapsulate configuration information and simplify `Kubernetes` deployments.
|
||||||
* Create a flexible configuration model for `Kubernetes`.
|
* Create a flexible configuration model for `Kubernetes`.
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ consumed in environment variables will not be updated.
|
|||||||
|
|
||||||
### API Resource
|
### API Resource
|
||||||
|
|
||||||
The `ConfigMap` resource will be added to the `extensions` API Group:
|
The `ConfigMap` resource will be added to the main API:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package api
|
package api
|
||||||
@ -180,15 +180,22 @@ type VolumeSource struct {
|
|||||||
ConfigMap *ConfigMapVolumeSource `json:"configMap,omitempty"`
|
ConfigMap *ConfigMapVolumeSource `json:"configMap,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigMapVolumeSource represents a volume that holds configuration data
|
// Represents a volume that holds configuration data.
|
||||||
type ConfigMapVolumeSource struct {
|
type ConfigMapVolumeSource struct {
|
||||||
// A list of configuration data keys to project into the volume in files
|
LocalObjectReference `json:",inline"`
|
||||||
Files []ConfigMapVolumeFile `json:"files"`
|
// A list of keys to project into the volume.
|
||||||
|
// If unspecified, each key-value pair in the Data field of the
|
||||||
|
// referenced ConfigMap will be projected into the volume as a file whose name
|
||||||
|
// is the key and content is the value.
|
||||||
|
// If specified, the listed keys will be project into the specified paths, and
|
||||||
|
// unlisted keys will not be present.
|
||||||
|
Items []KeyToPath `json:"items,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigMapVolumeFile represents a single file containing configuration data
|
// Represents a mapping of a key to a relative path.
|
||||||
type ConfigMapVolumeFile struct {
|
type KeyToPath struct {
|
||||||
ConfigMapSelector `json:",inline"`
|
// The name of the key to select
|
||||||
|
Key string `json:"key"`
|
||||||
|
|
||||||
// The relative path name of the file to be created.
|
// The relative path name of the file to be created.
|
||||||
// Must not be absolute or contain the '..' path. Must be utf-8 encoded.
|
// Must not be absolute or contain the '..' path. Must be utf-8 encoded.
|
||||||
@ -200,22 +207,27 @@ type ConfigMapVolumeFile struct {
|
|||||||
**Note:** The update logic used in the downward API volume plug-in will be extracted and re-used in
|
**Note:** The update logic used in the downward API volume plug-in will be extracted and re-used in
|
||||||
the volume plug-in for `ConfigMap`.
|
the volume plug-in for `ConfigMap`.
|
||||||
|
|
||||||
|
### Changes to Secret
|
||||||
|
|
||||||
|
We will update the Secret volume plugin to have a similar API to the new ConfigMap volume plugin.
|
||||||
|
The secret volume plugin will also begin updating secret content in the volume when secrets change.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
#### Consuming `ConfigMap` as Environment Variables
|
#### Consuming `ConfigMap` as Environment Variables
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: extensions/v1beta1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: etcd-env-config
|
name: etcd-env-config
|
||||||
data:
|
data:
|
||||||
number_of_members: 1
|
number-of-members: 1
|
||||||
initial_cluster_state: new
|
initial-cluster-state: new
|
||||||
initial_cluster_token: DUMMY_ETCD_INITIAL_CLUSTER_TOKEN
|
initial-cluster-token: DUMMY_ETCD_INITIAL_CLUSTER_TOKEN
|
||||||
discovery_token: DUMMY_ETCD_DISCOVERY_TOKEN
|
discovery-token: DUMMY_ETCD_DISCOVERY_TOKEN
|
||||||
discovery_url: http://etcd-discovery:2379
|
discovery-url: http://etcd-discovery:2379
|
||||||
etcdctl_peers: http://etcd:2379
|
etcdctl-peers: http://etcd:2379
|
||||||
```
|
```
|
||||||
|
|
||||||
This pod consumes the `ConfigMap` as environment variables:
|
This pod consumes the `ConfigMap` as environment variables:
|
||||||
@ -239,30 +251,30 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
configMap:
|
configMap:
|
||||||
configMapName: etcd-env-config
|
configMapName: etcd-env-config
|
||||||
key: number_of_members
|
key: number-of-members
|
||||||
- name: ETCD_INITIAL_CLUSTER_STATE
|
- name: ETCD_INITIAL_CLUSTER_STATE
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMap:
|
configMap:
|
||||||
configMapName: etcd-env-config
|
configMapName: etcd-env-config
|
||||||
key: initial_cluster_state
|
key: initial-cluster-state
|
||||||
- name: ETCD_DISCOVERY_TOKEN
|
- name: ETCD_DISCOVERY_TOKEN
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMap:
|
configMap:
|
||||||
configMapName: etcd-env-config
|
configMapName: etcd-env-config
|
||||||
key: discovery_token
|
key: discovery-token
|
||||||
- name: ETCD_DISCOVERY_URL
|
- name: ETCD_DISCOVERY_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMap:
|
configMap:
|
||||||
configMapName: etcd-env-config
|
configMapName: etcd-env-config
|
||||||
key: discovery_url
|
key: discovery-url
|
||||||
- name: ETCDCTL_PEERS
|
- name: ETCDCTL_PEERS
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMap:
|
configMap:
|
||||||
configMapName: etcd-env-config
|
configMapName: etcd-env-config
|
||||||
key: etcdctl_peers
|
key: etcdctl-peers
|
||||||
```
|
```
|
||||||
|
|
||||||
### Consuming `ConfigMap` as Volumes
|
#### Consuming `ConfigMap` as Volumes
|
||||||
|
|
||||||
`redis-volume-config` is intended to be used as a volume containing a config file:
|
`redis-volume-config` is intended to be used as a volume containing a config file:
|
||||||
|
|
||||||
@ -293,19 +305,19 @@ spec:
|
|||||||
- name: config-map-volume
|
- name: config-map-volume
|
||||||
mountPath: /mnt/config-map
|
mountPath: /mnt/config-map
|
||||||
volumes:
|
volumes:
|
||||||
- name: config-map-volume
|
- name: config-map-volume
|
||||||
configMap:
|
configMap:
|
||||||
files:
|
name: redis-volume-config
|
||||||
- path: "etc/redis.conf"
|
items:
|
||||||
configMapName: redis-volume-config
|
- path: "etc/redis.conf"
|
||||||
key: redis.conf
|
key: redis.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
### Future Improvements
|
## Future Improvements
|
||||||
|
|
||||||
In the future, we may add the ability to specify an init-container that can watch the volume
|
In the future, we may add the ability to specify an init-container that can watch the volume
|
||||||
contents for updates and respond to changes when they occur.
|
contents for updates and respond to changes when they occur.
|
||||||
|
|
||||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||||
[]()
|
[]()
|
||||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
Loading…
Reference in New Issue
Block a user