通过环境变量方式使用ConfigMap:

通过环境变量方式使用ConfigMap:


apiVersion: v1
kind: ConfigMap
metadata:
  name: appvar
data:
  # 类属性键;每一个键都映射到一个简单的值
  player_initial_lives: "3"
  ui_properties_file_name: "user-interface.properties"
  #
  # 类文件键
  game.properties: |
    enemy.types=aliens,monsters
    player.maximum-lives=5
  user-interface.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true

apiVersion: v1
kind: Pod
metadata:
  name: pod-test
spec:
  containers:
    - name: test
      image: busybox
      command: [ "/bin/sh", "-c", "env" ]
      envFrom:
      - configMapRef:
          name: appvar
  restartPolicy: Never


[root@master Chapter9]# kc get configmap
NAME             DATA   AGE
special-config   2    

上一篇:使用kuboard界面管理k8s集群时使用ConfigMap挂载挂载到pod容器中,映射成一个文件夹


下一篇:Error getting ConfigMap kube-system:kube-dns err: configmaps “kube-dns“ not found