How kubectl Communicates with Kubernetes
As we saw in the previous chapter, the API server manages communications between the end-user and Kubernetes, and it also acts as an API gateway to the cluster. To achieve this, it implements the RESTful API over the HTTP and HTTPS protocols to perform CRUD operations to populate and modify Kubernetes API objects such as pods, services, and more based upon the instructions sent by a user via kubectl. These instructions can be in various forms. For example, to retrieve information for pods running in the cluster, we would use the kubectl get pods
command, while to create a new pod, we would use the kubectl run
command.
First, let's take a look at what happens behind the scenes when you run a kubectl
command. Take a look at the following illustration, which provides an overview of the process, and then we will take a closer look at the different details of the process: