Delete a configmap itself from Kubernetes

Hany Habib picture Hany Habib · Dec 12, 2019 · Viewed 11.6k times · Source

I am trying to delete a configmap from a k8s namespace .. i created the configmap using the command below

kubectl -n namespacename create -f configmap.yaml

checking the k8s cheat sheet https://kubernetes.io/docs/reference/kubectl/cheatsheet/ i didn't find anything related .. kindly advise how to do that ?

Answer

Kamol Hasan picture Kamol Hasan · Dec 12, 2019

To delete configmap using configmap name:

# kubectl delete configmap  <configmap-name>  -n  <namespace-name> 
$ kubectl delete configmap    my-cofigmap     -n   namespacename 

To delete configmap using configmap yaml file:

# kubectl delete -f <file-directory> -n <namespace-name>
$ kubectl delete -f  configmap.yaml  -n  namespacename