Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add how to mount a specific key in configmap/secret to container directory #76

Open
life1347 opened this issue Nov 29, 2021 · 0 comments

Comments

@life1347
Copy link
Contributor

apiVersion: v1
kind: ConfigMap
metadata:
  name: core-env
data:
  .foo: |
    APP=xxx
  .bar: |
    APP=xxx
        - mountPath: /var/www/html/.foo
          name: env-config
          subPath: .foo
      volumes:
      - name: env-config
        configMap:
          name: core-env
          defaultMode: 420

此處只會將 configmap 內的 .foo key 的內容掛載進去
和下面的方式主要差異在於,上面是將內容直接以檔案形式放進去,不會影響到 /var/www/html/ 裡的內容
下面為將 volume 掛在 /etc/config,此方式會導致原先在 /etc/config 內的東西消失

apiVersion: v1
kind: Pod
metadata:
  name: configmap-pod
spec:
  containers:
    - name: test
      image: busybox
      volumeMounts:
        - name: config-vol
          mountPath: /etc/config
  volumes:
    - name: config-vol
      configMap:
        name: log-config
        items:
          - key: log_level
            path: log_level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant