kubectl, controllers, and kubelets) communicate with the cluster by talking to the kube-apiserver. The API server authenticates and validates requests, persists cluster state in etcd, and returns responses to clients.
Key concepts: kube-apiserver, Kubernetes control plane, etcd, authentication, authorization, admission controllers, TLS.
How the API server fits in the control plane
High-level request lifecycle:- A client (e.g.,
kubectl) sends a request to the kube-apiserver. - The kube-apiserver authenticates and authorizes the request, validates it, and reads or writes API objects in
etcd. - The kube-apiserver responds to the client with the requested information or the result of the mutation.
Creating a Pod — step-by-step (high-level)
- A client (for example
kubectlor a program calling the REST API) submits a Pod creation request to the kube-apiserver. - The kube-apiserver authenticates and validates the request and creates a Pod object in
etcd. At this point, the Pod has no Node assigned. - The scheduler watches the API server, detects the new Pod without a Node, selects a Node, and updates the Pod object (via the API server) by setting
spec.nodeName. - The kube-apiserver updates
etcdwith the assigned Node. - The appropriate kubelet observes the Pod spec (via the API server) and creates the Pod on the Node by talking to the container runtime.
- The kubelet updates the Pod
statusback to the API server, and the kube-apiserver persists the status intoetcd.
Calling the API directly
You can bypasskubectl and POST directly to the API (for example when scripting):
Most kube-apiserver flags reference certificate files (CA, server cert/key, client certs) used to secure control-plane communication. Understanding SSL/TLS certificates and how they secure control-plane communication is important when configuring these flags.
Do not access
etcd directly from external tools or custom components unless absolutely necessary. Direct access bypasses API-server admission and authorization checks and can lead to inconsistent or insecure cluster state. Prefer the kube-apiserver as the single source of truth.Important operational points
- The kube-apiserver is the only control-plane component that should talk directly to
etcdin a typical setup. Other components (scheduler, controller-manager, kubelets, etc.) read and update state by calling the kube-apiserver. - kube-apiserver flags control authentication, authorization, admission controllers, TLS certificates, feature gates, and more. These options determine how cluster components find and secure each other.
- When debugging control-plane connectivity or authentication, first inspect the kube-apiserver flags, logs, and certificate configuration.
Common kube-apiserver flags (summary)
Always verify which flags are supported in the Kubernetes version you run; some flags are deprecated or changed across releases. See Kubernetes documentation for version-specific details.
Obtaining the kube-apiserver binary
- If you bootstrap with
kubeadm, you usually don’t need to manage the binary manually. - For “hard way” or custom installs, download the binary from Kubernetes releases. Replace
vX.Y.Zwith the version you need:
Example systemd unit (kube-apiserver.service)
Below is an examplesystemd unit (the ExecStart with common flags) — if you use a different method (for example kubeadm), the API server might be run as a static pod manifest instead.
--apiserver-count, --enable-swagger-ui, and certain runtime-config values) may be deprecated in newer Kubernetes releases. Always consult official docs for your version.
How to view runtime kube-apiserver options
How you inspect kube-apiserver depends on how Kubernetes was installed:
Examples:
- List system pods to find the api-server pod on a
kubeadmcluster:
- To inspect the static pod manifest:
- For systemd-managed API server:
- To inspect the running process and flags:
Summary
- kube-apiserver is the central API endpoint for a Kubernetes cluster; it handles authentication, validation, authorization, admission control, and persistence of cluster state in
etcd. - All cluster components and clients use the kube-apiserver to read and mutate state; treat it as the single entry point for control-plane interactions.
- When deploying or troubleshooting the control plane, inspect the kube-apiserver flags, certificate configuration, and logs to understand authentication, connectivity, and authorization behavior.