configmap的创建及yaml渲染

1.configmap的创建

①存储文件

kubectl create configmap cm-name --from-file=xx.pem

②存储key-value

kubectl create configmap cm-name --from-literal=ip='127.0.0.1'

③对于混合存储

kubectl create configmap cm-name --from-file=xx.pem --from-literal=ip='127.0.0.1'

2.configmap在yaml中的渲染

spec:
      containers:
          env:
          - name: ETCD_HOST
            valueFrom:
              configMapKeyRef:
                name: cm-name
                key: ip
          - name: CLIENT_CERT_FILE
            value: "/cert/client.pem"
          - name: CLIENT_KEY_FILE
            value: "/cert/client-key.pem"
          - name: TRUSTED_CA_FILE
            value: "/cert/ca.pem"
          volumeMounts:
          - name: etcd-cf
            mountPath: /cert 
      volumes:
      - name: etcd-cf
        configMap:
          name: cm-name
          items:
          - key: ca.pem
            path: ca.pem      
          - key: client.pem
            path: client.pem  
          - key: client-key.pem
            path: client-key.pem

2.configmap编辑

kubectl edit configmap cm-name

 

你可能感兴趣的:(k8s)