Kubernetes Secret Creation - DBName, Username, Password and Encryption Key
In this section, you will learn to create a secret to store database name, username, password, and encryption key.
- Create a yaml file with dbname, dbusername, dbpassword,
encryptionKey using the syntax given
below:
ocudr-secret.yaml apiVersion: v1 kind: Secret metadata: name: ocudr-secrets type: Opaque data: dbname: dWRyZGI= dsusername: dWRydXNlcg== dspassword: dWRycGFzc3dk encryptionkey: TXkgc2VjcmV0IHBhc3NwaHJhc2U=
Note:
The name used to define a secret above should be same as given in the dbCredSecretName configuration under global section in values.yaml.The values of dbname, dsusername, dspassword, encryptionKey are base64 encoded. These are created by executing the following commands:
echo -n "<db name>" | base64
echo -n "<db username>" | base64
echo -n "<db password>" | base64
echo -n "<encryptionKey string>" | base64
Note:
You will create a secret using this yaml file. - Execute the following command to create a namespace where
deployment is done.
kubectl create namespace <namespace>
Note:
To create a secret, you need a namespace where deployment is done. - Execute the following command to create a secret:
kubectl create -f <secret File Name> -n <namespace>
- Execute the following command to verify a secret creation:
kubectl describe secret <secret name> -n <namespace>