I want to know the Object(Deployment/Statefulset/..) which is using a secret. Is there a way to find this out from a secret? Is there a tool in Kubernetes community to do this?
I want to know the Object(Deployment/Statefulset/..) which is using a secret. Is there a way to find this out from a secret? Is there a tool in Kubernetes community to do this?
Seems like there is nothing built in, but you can use kubectl in conjuction with jq to figure it out. Here is the example for deployments
kubectl get deployment -o json | jq '.items[] | select(.spec.template.spec.volumes[]? | .secret.secretName=="<secret name>") | .metadata.name'
You can use this command to show the labels of the Object(Deployment/Statefulset) that matches the labels of the Secret
The Pods for example
kubectl get pods [pod_name] --show-labels
or
To get the label of the Secrets
kubectl describe secrets [secret_name]
kubectl get secrets