Removal of Pods utilizes the kubectl command. Before we start with the removal of a single Pod, we need to list existing Pods. To list all Pods, we can use the kubectl get pods command:
Figure 6.50 – Listing of existing Pods with kubectl command
To delete a single Pod, we can issue the kubectl delete pod frontend-4rk4w command. The Pod is deleted immediately, but we might ask ourselves the following: How do I know if the Pod is part of the deployment or otherwise? How was the Pod deployed in the first place?
To find this out, we can review the Pod configuration by using the kubectl describe pod frontend-dc4n4 command.
The command output contains a lot of information, and we need to scroll to the Controlled By: section:
Figure 6.51 – Detailed information about the Pod
The Controlled By: section allow us to identify how a Pod or set of Pods deployment has been done. Once we know that the Pod is part of a ReplicaSet, we need to find the name of the ReplicaSet. To find this out, we can use the kubectl get replicaset command:
Figure 6.52 – Existing ReplicaSet deployments
So, we discovered that the ReplicaSet with the name frontend contains six replicas and Pods associated with it:
Figure 6.53 – Detailed information about the frontend ReplicaSet
Finally, to delete it, we need to run the kubectl delete replicaset frontend command. After a moment, deletion completes.
We learned a lot about Pods, including how to deploy, manage and remove them. Our journey doesn’t stop here. We will now move to the services section, where we will learn about different types of services and how we can use them in GKE.
Services are a crucial part of GKE. GKE uses services to group Pods into a single resource that is going to be accessed from outside of the GKE cluster. After the deployment of the application, we can choose different ways to access applications running in GKE.
We have a handful selection of services to choose from, as follows:
- ClusterIP—This is a default service where clients’ requests are sent to an internal IP address.
- NodePort—Clients send requests to the IP address of a node with a specific, configurable port value.
- LoadBalancer—Clients access the application by using the IP address of the load balancer.
- ExternalName—Clients access the application by using the DNS address.
- Headless—A headless service that can be used to group Pods without an IP address.
Both the Kubernetes and GKE documentation describe in detail services with all their options, and we recommend diving deep if you want to learn more beyond the scope of the book: