To see how these components work together, let’s consider an example.Īssume, you just executed kubectl create -f replicaset.yaml, upon which kubectl made an HTTP POST request to the create ReplicaSet API endpoint (passing along your ReplicaSet resource definition). Scheduler: schedules Pods to worker nodesĪnd this is the most important component on the worker nodes: Kubelet: manages execution of containers on a worker node These are the most important components on the master nodes: Storage backend: stores resource definitions (usually etcd is used)ĪPI server: provides Kubernetes API and manages storage backendĬontroller manager: ensures resource statuses match specifications
Some components run on the master nodes and others run on the worker nodes, and each component has a very specific function. Kubernetes consists of a set of independent components that run as separate processes on the nodes of a cluster. To this end, let’s briefly dive into the Kubernetes internals. But there is much more about the Kubernetes API that every kubectl user should know.
These are the basics of what kubectl is and how it works. Kubectl just makes it easier for you to use the Kubernetes API. Note that it’s totally possible to control Kubernetes with a tool like curl by manually issuing HTTP requests to the Kubernetes API. In all these cases, kubectl simply makes HTTP requests to the appropriate Kubernetes API endpoints. This is how kubectl works for all commands that interact with the Kubernetes cluster. The ReplicaSet definition (that you provided in the replicaset.yaml file) is passed in the body of the request. To make an actual request to an endpoint, you need to prepend the URL of the API server to the endpoint paths that are listed in the API reference.Ĭonsequently, when you execute the above command, kubectl makes an HTTP POST request to the above API endpoint.
You can find the API endpoints of all Kubernetes operations in the API reference (including the above endpoint). POST /apis/apps/v1/namespaces//replicasets To do so, you would define the ReplicaSet in a file named replicaset.yaml file, and then run the following command: Imagine you want to create a ReplicaSet resource. For this reason, the Kubernetes API reference is organised as a list of resource types with their associated operations. You fully control Kubernetes by manipulating these resources (and Kubernetes figures out what to do based on the current state of resources). That means, Kubernetes maintains an internal state of resources, and all Kubernetes operations are CRUD operations on these resources. Kubernetes is a fully resource-centred system. This means that every Kubernetes operation is exposed as an API endpoint and can be executed by an HTTP request to this endpoint.Ĭonsequently, the main job of kubectl is to carry out HTTP requests to the Kubernetes API: Kubernetes is fully controlled through this API. This API is the real Kubernetes user interface. It allows you to perform every possible Kubernetes operation.įrom a technical point of view, kubectl is a client for the Kubernetes API.
What is kubectl? | dockerlabs Star Fork Watch Follow What is kubectl? Docker - Beginners | Intermediate | Advanced View on GitHub Join Slack Docker Cheatsheet Docker Compose Cheatsheet What is kubectl?īefore learning how to use kubectl more efficiently, you should have a basic understanding of what it is and how it works.įrom a user’s point of view, kubectl is your cockpit to control Kubernetes.