I am on a GCP k8s cluster. I want to be sure that no pods or other kubernetes resources are using a particular ConfigMap first, before deleting the ConfigMap. Is there a kubectl command that I can use to check what is using a ConfigMap?
I am on a GCP k8s cluster. I want to be sure that no pods or other kubernetes resources are using a particular ConfigMap first, before deleting the ConfigMap. Is there a kubectl command that I can use to check what is using a ConfigMap?
You could export all your resources and grep for the config map name.
You can use this script to export all selected resources (select resources in the RESOURCES category)
NAMESPACE="your_namespace"
RESOURCES="configmap secret daemonset deployment service"
for resource in ${RESOURCES};do
rsrcs=$(kubectl -n ${NAMESPACE} get -o json ${resource}|jq '.items[].metadata.name'|sed "s/\"//g")
for r in ${rsrcs};do
dir="${NAMESPACE}/${resource}"
mkdir -p "${dir}"
kubectl -n ${NAMESPACE} get -o yaml ${resource} ${r} > "${dir}/${r}.yaml"
done
done
Next, you can use grep -nr your_config_map_name your_directory(your name space in this case)
this will show you the files that contain the config map, I.E resources that use it.