Kubernetesk8s那点事儿k8s入门

K8S configMap 作为统一配置文件中心

2019-06-12  本文已影响4人  lyy910203
timg (2).jpg

使用范围:

统一配置中心,保存在etcd集群中,更新不是很及时

configmap和secret区别

configMap作为配置文件使用

创建文件类型
kubectl create configmap my-config --from-file=key1=/path/to/bar/file1.txt
使用
    在pod中定义使用
apiVersion: v1
kind: Pod
metadata:
  name: configmap-pod
spec:
  containers:
    - name: test
      image: busybox
      volumeMounts:
        - name: config-vol
          mountPath: /etc/config
  volumes:
    - name: config-vol
      configMap:
        name: my-config
然后文件my-config就挂载在pod /etc/config目录下

key value的configmap
    kubectl create configmap my-config key=value

注意

volumeMounts:
  - name: config-vol
    mountPath: /etc/config.conf  
    subPath: config.conf   #如果加上subPath  写上文件名,代表挂载的是文件,不会将原目录覆盖,但是如果有源文件会被覆盖
上一篇 下一篇

猜你喜欢

热点阅读