kubernetes cluster
echo "**** Installing kubeseal ****"
export VERSION_KUBESEAL=0.17.5
curl -LO https://github.com/bitnami-labs/sealed-secrets/releases/download/v${VERSION_KUBESEAL}/kubeseal-${VERSION_KUBESEAL}-linux-amd64.tar.gz
tar -xzvf kubeseal-${VERSION_KUBESEAL}-linux-amd64.tar.gz
chmod +x kubeseal
mv kubeseal /usr/bin/
wget https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.18.0/controller.yaml
kubectl apply -f controller.yaml
You can check the status of your deployment by using the following command
kubectl get pods -n kube-system | grep sealed-secrets-controller
---
apiVersion: v1
kind: Secret
metadata:
name: <name-of-secret>
data:
user: <base64encode>
password: <base64encode>
kubeseal --fetch-cert > master-key.pem
kubeseal --cert=master-key.pem --format=yaml < <secret-file>.yaml > sealed-secret.yaml
kubectl apply -f sealed-secret.yaml
kubeseal --fetch-cert > master.pem
kubeseal --cert=master.pem --format=yaml < secrets.yml > sealed-secret-mysql.yaml
kubectl apply -f pv.yml
kubectl apply -f pvc.yml
kubectl apply -f configmaps.yml
kubectl apply -f sealed-secret-mysql.yaml # This secret will be unseal using controller and master.pem file
kubectl apply -f deployment.yml
Note:
Push sealed secret file to Github and share master.pem personally who required to unseal, Here I have given master key for understanding
kubectl exec -it <pod-name> -- /bin/bash
mysql -u naresh -p
Provide password for mysql
use mysqldb
create table employee( empno varchar(40), ename varchar(40));
insert into employee(empno, ename) values("101","Naresh");
select * from employee;