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

投稿者: ytyng 1年, 1ヶ月 前

ローカルにあるファイルで 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 としてマウントさせる

現在未評価

コメント

アーカイブ

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011