Hany Habib
Hany Habib

Reputation: 1405

Delete a configmap itself from Kubernetes

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 ?

Upvotes: 24

Views: 51058

Answers (4)

Fermin
Fermin

Reputation: 36111

You can delete a configMap by it's name. If you are unsure you can check the configMaps within a namespace by using:

kubectl get configmap -n namespacename`

once you have them you can run a delete command:

kubectl delete configmap <configmapname> -n namespacename

Upvotes: 5

Kamol Hasan
Kamol Hasan

Reputation: 13536

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

Upvotes: 64

weibeld
weibeld

Reputation: 15302

Easiest way if you created the ConfigMap with a YAML file is to delete it by referencing the YAML file as well:

kubectl delete -n <namespacename> -f configmap.yaml

Upvotes: 1

Tommy Brettschneider
Tommy Brettschneider

Reputation: 1500

Should work this way:

kubectl delete configmap <configmap-name> -n <namespace-name>

Your configmap's name should be defined in your configmap.yaml file.

Upvotes: 1

Related Questions