Creating a Kubernetes Secret for Storing Database Username and Password
To create a kubernetes secret for storing database username
and password:
- Create a yaml file with the
username and password with the syntax shown below:
apiVersion: v1 kind: Secret metadata: name: <secret-name> type: Opaque data: mysql-username: cGNmdXNy mysql-password: cGNmcGFzc3dk
Note:
The values for mysql-username and mysql-password should be base64 encoded. - Execute the following
command to create the kubernetes secret:
kubectl create -f yaml_file_name -n namespace
where:yaml_file_name is a name of the yaml file that is created in step 1.
namespace is the deployment namespace used by the helm command.
Note:
If namespace is not already present, create the namespace using the following command:kubectl create ns namespace