6

How to mount multiple Kubernetes secrets into one directory

 2 years ago
source link: http://www.donghao.org/2021/09/17/how-to-mount-multiple-kubernetes-secrets-into-one-directory/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to mount multiple Kubernetes secrets into one directory

As the title, Kubernetes already has a new component called `projected volume` that support the mounting of multiple secrets into one directory.

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-app
  name: my-app
spec:
  containers:
  - command:
    - sleep
    - "3600"
    image: alpine
    name: alpine-secret
    volumeMounts:
    - name: my_secrets
      mountPath: "/var/secrets/"
      readOnly: true
  volumes:
  - name: my_secrets
    projected:
      sources:
      - secret:
          name: my-secret-one
      - secret:
          name: my-secret-two
Python
xxxxxxxxxx
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-app
  name: my-app
spec:
  containers:
  - command:
    - sleep
    - "3600"
    image: alpine
    name: alpine-secret
    volumeMounts:
    - name: my_secrets
      mountPath: "/var/secrets/"
      readOnly: true
  volumes:
  - name: my_secrets
    projected:
      sources:
      - secret:
          name: my-secret-one
      - secret:
          name: my-secret-two

Like this:

Loading...
3:00 am ROBIN DONG ops
Kubernetes
Leave a comment

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK