Kubernetes の ConfigMap でファイルをマウントする

2023-03-11 01:01 (3 years ago)
SubPath Mount
この記事をテーマにした曲を再生

ローカルにあるファイルで ConfigMap を作り、Podにマウントさせる方法です。

ファイルから ConfigMap を作成する

kubectl -n my-namespace create configmap my-config-file --from-file=../my-config-file.conf

deployments でマウントする

apiVersion: apps/v1
kind: Deployment
  namespace: torico
spec:
  ...
  template:
    spec:
      containers:
          volumeMounts:
            - name: my-config-file-volume
              mountPath: /app/config/my-config-file.conf
              subPath: my-config-file.conf
      volumes:
        - name: my-config-file-volume
          configMap:
            name: my-config-file

my-config-file-volume の中の my-config-file.conf というファイルのみ、 /app/config/my-config-file.conf としてマウントさせる

評価をお願いします
まだ評価がありません
著者は、アプリケーション開発会社 Cyberneura を運営しています。
開発相談をお待ちしています。

アーカイブ