<p>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?</p>

<p>You could export all your resources and grep for the config map name.</p>
<p>You can use this script to export all selected resources (select resources in the RESOURCES category)</p>
<pre><code>NAMESPACE=&quot;your_namespace&quot;
RESOURCES=&quot;configmap secret daemonset deployment service&quot;

for resource in ${RESOURCES};do
  rsrcs=$(kubectl -n ${NAMESPACE} get -o json ${resource}|jq '.items[].metadata.name'|sed &quot;s/\&quot;//g&quot;)
  for r in ${rsrcs};do
    dir=&quot;${NAMESPACE}/${resource}&quot;
    mkdir -p &quot;${dir}&quot;
    kubectl -n ${NAMESPACE} get -o yaml ${resource} ${r} &gt; &quot;${dir}/${r}.yaml&quot;
  done
done
</code></pre>
<p>Next, you can use <code>grep -nr your_config_map_name your_directory(your name space in this case)</code></p>
<p>this will show you the files that contain the config map, I.E resources that use it.</p>
