configmapの作成とyamlレンダリング
1285 ワード
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