How to copy all certificates from Kubernetes on one server to Kubernetes on another one?

7/27/2019

How to copy all certificates from Kubernetes on one server to Kubernetes on another one?

How to export them?

Possible import step

kubectl create secret tls {{ .Release.Name }}-ingress-tls-secret  --key /tmp/tls.key --cert /tmp/tls.crt [--namespace namespace]

Which actions should be after import step?

I want to see same certs on another server.

-- Arthur
certificate
kubernetes

1 Answer

7/28/2019

kubernetes store the certificate in the secret.

you can simply export the secret and import it on to new kubernetes cluster.

here is one example to export the secret locally

kubectl get secret my-secret-name(secret name) --export -o yaml > my-secret-name.yaml

my-secret-name.yaml file will be created

now on the new cluster, you can simply import the certificate using generated yaml file

kubectl apply -f my-secret-name.yaml -n namespace-name

(if want to set in a specific namespace)

after importing the certificate you can simply use them in ingress.

-- Harsh Manvar
Source: StackOverflow