LoginSignup
1
0

More than 3 years have passed since last update.

configMapを用いて、Podに複数のconfigをマウントする

Last updated at Posted at 2020-12-02

configMapを用いて、Podに複数のconfigをマウントする

ディレクトリ配下にある複数のconfigファイルから、configMap のyamlを作成し、それをPodからマウントする。

configファイルの確認

$ ls config
amfcfg.conf   free5GC.conf

ディレクトリ名を指定して、f5gcs3-configという名前で、ConfigMapを作成する。

$ kubectl create configmap f5gcs3-config --from-file=config
$ kubectl get configmap
NAME            DATA   AGE
f5gcs3-config   16     33s

yaml ファイルを作成する

$ kubectl get configmap f5gcs3-config -o yaml >> configmap.yaml

Podから、configmapの複数のkeyを参照する設定を行う

cat <<EOF > pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: configmap-pod
spec:
  containers:
    - name: configmap-cnt
      image: ubuntu:latest
      volumeMounts:
        - name: config-vol
          mountPath: /home
      command: ["tail",  "-f", "/dev/null"]
  volumes:
    - name: config-vol
      projected:
        sources:
        - configMap:
            name: f5gcs3-config
            items:
            - key: amfcfg.conf
              path: amfcfg.conf
        - configMap:
            name: f5gcs3-config
            items:
            - key: free5GC.conf
              path: free5GC.conf
EOF

configMap, Pod をデプロイし、確認する

$ kubectl create -f configmap.yaml
$ kubectl create -f pod.yaml

$ kubectl exec -it configmap-pod -- ls /home/
amfcfg.conf  free5GC.conf
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0