I just started to explore Kubernetes and I deployed a service in a container on Kubernetes which is running on a cloud.
My service requires to make a call to a database which requires a certificate for authentication. I am wondering what would be the best practice to store/install the certificate on Kubernetes
I need to access the certificate from my code which I am using as follows
const (
serverCertificate = "./cert/api.cer"
serverPrivateKey = "./cert/api.key"
)
creds, err := credentials.NewServerTLSFromFile(serverCertificate, serverPrivateKey)
You could store the certificate in a Kubernetes Secret: https://kubernetes.io/docs/concepts/configuration/secret/
Here is an example on how to do so: https://kubernetes.io/docs/concepts/configuration/secret/#creating-a-secret-using-kubectl-create-secret