华为云计算 云知识 Pod中使用ConfigMap的方法
Pod中使用ConfigMap的方法

在Pod中使用ConfigMap配置环境变量:

apiVersion: v1
kind: Pod
metadata:
  name: configmap-demo-pod
spec:
  containers:
    - name: demo
      image: alpine
      command: ["sleep", "3600"]
      env:
        - name: PLAYER_INITIAL_LIVES
          valueFrom:
            configMapKeyRef:
              name: my-config
              key: player_initial_lives
        - name: UI_PROPERTIES_FILE_NAME
          valueFrom:
            configMapKeyRef:
              name: my-config
              key: ui_properties_file_name

在Pod中使用ConfigMap挂载配置文件:

apiVersion: v1
kind: Pod
metadata:
  name: configmap-demo-pod
spec:
  containers:
    - name: demo
      image: alpine
      command: ["sleep", "3600"]
      volumeMounts:
      - name: config
        mountPath: "/config"
        readOnly: true
  volumes:
    - name: config
      configMap:
        name: my-config
        items:
        - key: "game.properties"
          path: "game.properties"

上一篇:查询中转IP实例ListTransitIpsByTags 下一篇:Memtester有什么用