How to Delete Kubectl Service

How to Delete Kubectl Service

I executed the following command: % kubectl get service

It returned this list of services that were created at one point in time with kubectl:

NAME                     CLUSTER-IP   EXTERNAL-IP   PORT(S)                         AGE
car-example-service      10.0.0.129   <nodes>       8025:31564/TCP,1025:31764/TCP   10h
circle-example-service   10.0.0.48    <nodes>       9000:30362/TCP                  9h
demo-service             10.0.0.9     <nodes>       8025:30696/TCP,1025:32047/TCP   10h
example-servic           10.0.0.168   <nodes>       8080:30231/TCP                  1d
example-service          10.0.0.68    <nodes>       8080:32308/TCP                  1d
example-service2         10.0.0.184   <nodes>       9000:32727/TCP                  13h
example-webservice       10.0.0.35    <nodes>       9000:32256/TCP                  1d
hello-node               10.0.0.224   <pending>     8080:32393/TCP                  120d
kubernetes               10.0.0.1     <none>        443/TCP                         120d
mouse-example-service    10.0.0.40    <nodes>       9000:30189/TCP                  9h
spring-boot-web          10.0.0.171   <nodes>       8080:32311/TCP                  9h
spring-boot-web-purple   10.0.0.42    <nodes>       8080:31740/TCP                  9h

I no longer want any of these services listed, because when I list resources: % kubectl get rs

I am expecting that I only see the spring-boot-web resource listed.

NAME                         DESIRED   CURRENT   READY     AGE
spring-boot-web-1175758536   1         1         0         18m

Please help clarify why I am seeing services that are listed , when the resources only show 1 resource.

1

5 Answers

Simply call this command.

1/Get all available services:

kubectl get service -o wide

2/ Then you can delete any services like this:

kubectl delete svc <YourServiceName>
1

show deployment

$ kubectl get deployments;

NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
spring-hello      1         1         1            1           22h
spring-world      1         1         1            1           22h
vfe-hello-wrold   1         1         1            1           14m
Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.