This git repo illustrates a small application which can access kubernetes secrets.
To test the application build the docker image which builds the small application. Run the command:
docker build -t kubernetes-secret .
docker tag kubernetes-secret:latest kubernetes-secret:v0.0.1
Get the Docker desktop context.
kubectl config get-contexts
kubectl config use-context docker-desktop
Apply the kubernetes files to the cluster:
kubectl apply -f kubernetes
Check that on deployment
kubectl get deployments -n mynamespace
Check on the pods
kubectl get pods -n mynamespace
Get the logs from the pod
kubectl logs kubernetes-secrets-xxxxx -n mynamespace
To clean up after run:
kubectl delete secret mysecret -n mynamespace
kubectl delete deployment kubernetes-secrets -n mynamespace
kubectl delete role secret-reader -n mynamespace
kubectl delete rolebinding read-secrets -n mynamespace
kubectl delete serviceaccount my-service-account -n mynamespace