O'Reilly logo

Docker and Kubernetes for Java Developers by Jaroslaw Krochmalski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cleaning up

If you finish playing with your deployment and services or would like to start from the beginning, you can do some cluster cleaning by removing the deployment or services:

$ kubectl delete deployment rest-example
$ kubectl delete service rest-example      

This code can also be combined in one command, for example:

$ kubectl delete service,deployment rest-example

The kubectl delete supports label selectors and namespaces. Let's see some other examples of the command in a table:

Example command

Meaning

kubectl delete pod,service baz foo

Delete pods and services with same names baz and foo

kubectl delete pods,services -l name=myLabel

Delete pods and services with label name=myLabel

kubectl -n my-ns delete po,svc ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required