当前位置:网站首页>kubernetes comfig subpath

kubernetes comfig subpath

2022-06-23 12:37:00 Matthew__ M

 docker Medium volume Sure mount Files to a specific directory , At the same time, keep the original directory unchanged ; alike mount Put it in Kubernetes But it became : Just put mount Several files of are directly put into the root directory , The files in the original directory disappear . In many scenarios , We would like to just mount a file to Containers An internal directory , Without affecting the original directory .

apiVersion: v1
kind: ConfigMap
metadata:
  name: special-config
  namespace: default
data:
  special.level: very
  special.type: |-
    property.1=value-1
    property.2=value-2
    property.3=value-3
---
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  containers:
    - name: test-container
      image: busybox:latest
      imagePullPolicy: IfNotPresent
      command: [ "/bin/sh", "-c", "ls /etc/", "-c", "ls /usr" ]
      volumeMounts:
      - name: config-volume
        mountPath: /etc/special.level
        subPath: special.level
      - name: config-volume
        mountPath: /usr/special.type
        subPath: special.type
  volumes:
    - name: config-volume
      configMap:
        # Provide the name of the ConfigMap containing the files you want
        # to add to the container
        name: special-config
  restartPolicy: Never

原网站

版权声明
本文为[Matthew__ M]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231212421308.html