Home > Mobile >  Provide certificate file into pod in k8s
Provide certificate file into pod in k8s

Time:11-03

We a pod which needs certificate file We need to provide a path to a certificate file, (we have this certificate) how should we put this certificate file into k8s that the pod will have an access to it e.g. that we were able to provide it like the following to the pod "/path/to/certificate_authority.crt” Should we use secret/ configmap, if yes than how?

CodePudding user response:

Create a secret, then mount it in the desired folder.

Official docs here: https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod

CodePudding user response:

Create a TLS secret then mount it to the desired folder.

apiVersion: v1
kind: Secret
metadata:
  name: secret-tls
type: kubernetes.io/tls
data:
  # the data is abbreviated in this example
  tls.crt: |
        MIIC2DCCAcCgAwIBAgIBATANBgkqh ...
  tls.key: |
        MIIEpgIBAAKCAQEA7yn3bRHQ5FHMQ ...

Documentation

To mount the secret in a volume from your pod:

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: mypod
    image: redis
    volumeMounts:
    - name: foo
      mountPath: "/path/to/"
      readOnly: true
  volumes:
  - name: foo
    secret:
      secretName: secret-tls

Documentation

  • Related