What Is the API Server in Kubernetes?

What Is the API Server in Kubernetes?

A plain-English guide to the front door of every Kubernetes cluster: what the API server is, how it checks and stores every request, how the rest of the cluster depends on it, and how to keep it fast, safe, and healthy.

Every time you press Enter on a Kubernetes command, something answers. Every time a new container starts, a crashed one is replaced, or a website update rolls out, something records the request and tells the right machines what to do. That something is the API server, and it is the single most important program in a Kubernetes cluster. If the cluster were a company, the API server would be the reception desk, the security guard, and the filing clerk, all rolled into one.

Beginners often skip past it because it does not run their application. It is not a place where your code lives. Yet almost every problem you will debug, every security review you will sit through, and every interview about Kubernetes internals will lead back to it. In this guide you will learn what the API server is, why it exists, how a request travels through it step by step, how it protects the cluster, how the other components use it, how to make it highly available, and what mistakes to avoid. No prior knowledge is assumed.

1What Is the API Server? The Short Answer

The API server is the front door of a Kubernetes cluster. Everyone and everything that wants to read or change the cluster must go through it.

First, what is an API?

An API (Application Programming Interface) is a menu of requests that a program is willing to answer, written in a strict format so that other programs can use it without human help. Think of a restaurant menu: you cannot walk into the kitchen and grab ingredients, but you can order any dish on the menu and the kitchen will respond in a predictable way. Kubernetes publishes its own menu, called the Kubernetes API, and it includes requests such as “create a Deployment,” “show me all Pods,” “delete this Service,” or “tell me whenever a Pod changes.”

And what is a server?

A server is simply a program that waits for requests and answers them. Put the two ideas together and the kube-apiserver is the program that receives requests written in the Kubernetes API format, checks them, carries them out, and returns an answer. It listens on a network port (6443 by default) and talks over an encrypted connection, so nobody on the network can read or tamper with the messages.

Everyday Analogy

Imagine a large hospital. Doctors, nurses, lab technicians, and visitors all need information from patient records, but nobody is allowed to wander into the records room. Instead there is one reception desk. The receptionist checks your identity badge, confirms you are allowed to see that record, makes sure your request is filled in correctly, and only then fetches or updates the file. The API server is that reception desk, and the records room is etcd, the cluster database.

The most important rule

Here is a rule that will simplify everything else you learn: in Kubernetes, every component talks to the API server, and the API server is the only one that talks to the database. Your command-line tool talks to it. The scheduler talks to it. The controllers talk to it. The kubelet on every worker machine talks to it. Even the Pods running inside the cluster can talk to it if you allow them. No component gives orders directly to another component. Instead they all read from and write to the shared record kept by the API server, and each one reacts to what it sees there.

flowchart LR
    KC["kubectl and other tools"] --> API
    CI["CI/CD pipelines"] --> API
    UI["Dashboards"] --> API
    SCH["Scheduler"] --> API
    CM["Controller Manager"] --> API
    KUB["kubelets on worker nodes"] --> API
    PODS["Pods with permission"] --> API
    API["kube-apiserver - the front door"] --> ETCD[("etcd - the cluster database")]
Figure 1. Everything talks to the API server, and only the API server talks to etcd.
i
Tip

When something in Kubernetes “just knows” about a change, it is almost never because two components spoke to each other privately. It is because both were watching the same record through the API server.

2Why the API Server Exists

To see why one front door is a clever design, imagine the alternative.

The chaotic alternative

Suppose every part of the cluster could write straight into the database. The scheduler might save a decision while a controller saves a different one at the same moment. Different programs could store data in slightly different formats. Anyone with a network connection to the database could read passwords and change settings. There would be no single place to check permissions, no single place to record who did what, and no way to upgrade one part without breaking the others.

The clean solution

Kubernetes solves this by placing one gatekeeper in front of the database. That gatekeeper gives the whole system four valuable gifts.

Gift 1

One place to check identity

Every request must prove who it comes from, whether that is a person, a pipeline, or a program. There is no side entrance.

Gift 2

One place to enforce rules

Permissions and cluster policies are checked in the same order for every request, so nobody can skip them.

Gift 3

One shared format

Every object follows a defined structure, so all components understand each other and the data stays consistent.

Gift 4

One record of history

Because every change passes through one door, it can be logged for audits: who changed what, and when.

6443
default secure port of the API server
1
component that talks directly to etcd
3
checks every request must pass before being stored
Everyday Analogy

Banks do not let customers walk into the vault. Every deposit and withdrawal goes through a teller who verifies identity, checks the account rules, writes a record of the transaction, and only then touches the vault. If ten thousand customers arrive, the bank simply opens more teller windows, and the vault stays as safe as before. The API server plays the teller, and adding more API servers is the same as opening more windows.

A design that keeps components simple

A hidden benefit is that the other components stay small and easy to replace. The scheduler does not need to know how to talk to a database, how to authenticate people, or how to store history. It only needs to know how to ask the API server for unscheduled Pods and how to tell it which node was chosen. Because of this design, you can even swap in a different scheduler, or run several at once, without changing anything else. The API is the shared contract that lets the whole cluster be built from independent, replaceable parts.

3Core Concepts: Resources, Objects, and Verbs

Before following a request through the API server, you need five small ideas.

Resources and objects

A resource type is a kind of thing the API knows about, such as Pods, Deployments, Services, Nodes, or Namespaces. An object is one specific instance of a resource type, such as “the Deployment named checkout in the shop namespace.” The API server stores objects and lets clients create, read, change, and delete them.

Spec and status: the two halves of every object

Almost every object has two main sections. The spec is what you want: “three copies of this container image.” The status is what actually exists right now: “two copies are running, one is starting.” You write the spec. The cluster’s components write the status. The gap between the two is what controllers work to close, which is the desired-state idea at the heart of Kubernetes.

Verbs: what you can do

VerbPlain meaningWeb request behind it
getRead one objectGET on a single object
listRead many objects at onceGET on a collection
watchKeep a connection open and hear about every changeGET with a watch option
createMake a new objectPOST
updateReplace an object entirelyPUT
patchChange part of an objectPATCH
deleteRemove an objectDELETE

API groups and versions

With hundreds of resource types, the API needs an orderly filing system. Resource types are placed in API groups, such as apps for Deployments or batch for Jobs, and each group has versions like v1 or v1beta1. When you write a configuration file, its first lines name the group and version, for example apps/v1. The oldest and most basic resources, such as Pods and Services, live in the “core” group, which has no name and is simply written as v1.

Namespaces

Many objects live inside a namespace, a named room in the cluster that keeps teams or environments tidy. Some objects, like Nodes, belong to the whole cluster and have no namespace. The API server uses the namespace as part of an object’s address and in its permission checks.

?
Good to know

The command-line tool kubectl is not magic. It is just a friendly program that turns your typed commands into web requests to the API server and prints the answers. Anything kubectl can do, a script, a program in any language, or a plain web request can also do, given the right credentials.

4Architecture and Components of the API Server

Although it is described as one program, the API server is built from several layers that each handle a different kind of API.

flowchart TB
    IN["Incoming request"] --> SEC["Security chain - authentication, authorization, admission"]
    SEC --> AGG["Aggregation layer - the traffic director"]
    AGG --> CORE["Built-in API - Pods, Deployments, Services"]
    AGG --> EXT["Extension API - custom resource definitions"]
    AGG --> ADD["Add-on API servers - for example metrics"]
    CORE --> STORE["Storage layer with watch cache"]
    EXT --> STORE
    STORE --> ETCD[("etcd")]
Figure 2. The layers inside the API server, from the front gate to the database.

The parts, one by one

Gate

Secure endpoint

The network listener that accepts encrypted connections. It handles the certificates that let clients trust the server, and the server trust the clients.

Guards

Security chain

The ordered set of checks for identity, permission, and policy. We study each in its own chapter.

Director

Aggregation layer

Sends each request to the right place. It allows extra API servers, such as the one behind the metrics server, to appear as part of the main API.

Built-in

Core API handlers

The code for the standard resource types that ship with Kubernetes: Pods, Nodes, Deployments, Jobs, and many more.

Extensions

Custom resource support

Lets you teach the API server brand-new resource types at runtime by registering a custom resource definition, without changing Kubernetes itself.

Storage

Storage layer and watch cache

Translates objects into the format saved in etcd and keeps a fast in-memory copy so that most reads and watches never need to bother the database.

Stateless by design

The API server keeps no permanent data of its own. Everything important lives in etcd, and whatever the API server holds in memory can be rebuilt from etcd in moments. This is a huge advantage: you can run several API servers side by side behind a load balancer, stop one for an upgrade, or lose one to a crash, and the cluster keeps working.

!
Watch out

Stateless does not mean unimportant. If every API server is down, running applications usually continue, but nobody can change, scale, or heal anything until at least one comes back.

5Internal Working: The Life of a Request

Every write request follows the same road. Learning this road once explains most of Kubernetes behavior.

sequenceDiagram
    participant C as Client
    participant A as Authentication
    participant Z as Authorization
    participant M as Mutating Admission
    participant V as Validating Admission
    participant S as Storage Layer
    participant E as etcd
    C->>A: Send request with credentials
    A->>Z: Identity confirmed
    Z->>M: Permission granted
    M->>V: Defaults and changes applied
    V->>S: Object is valid and allowed
    S->>E: Save the object
    E-->>S: Saved
    S-->>C: Success response
Figure 3. The ordered checkpoints every write request passes before it is stored.
1

The connection is secured

The client opens an encrypted connection. The server shows its certificate so the client knows it is talking to the real cluster and not an impostor.

2

Authentication: who are you?

The server examines the credentials, such as a certificate or a token, and works out the identity, including the user name and any groups. A request that proves nothing is rejected, or treated as anonymous if that is allowed.

3

Authorization: may you do this?

Knowing who you are, the server asks whether you may perform this verb on this resource in this namespace. If no rule says yes, the answer is no.

4

Mutating admission: fix and fill in

Special plugins may modify the request, for example by adding default values, injecting a helper container, or attaching labels.

5

Schema validation: is it well formed?

The server checks that the object matches the official structure of its type: correct field names, correct types, sensible values.

6

Validating admission: does it follow the rules?

Policy plugins look at the final version of the object and can reject it, for example if it asks for too much memory or runs as an administrator.

7

Persistence: write it down

The object is saved to etcd. Only after etcd confirms that a majority of its members stored it does the API server report success.

8

Notification: tell the watchers

Everyone watching this kind of object is told about the change, and the reaction of the cluster begins.

Why the order matters

The checks are arranged from cheap to expensive and from general to specific. There is no point examining the details of an object if the caller is not even allowed to be there, so identity and permission come first. Mutating plugins run before validating plugins so that the rules judge the object in its final form, including anything the mutating plugins added. And nothing reaches etcd unless it survives every checkpoint.

i
Tip

Read requests such as get and list skip the mutating and validating steps because they change nothing. They still pass through authentication and authorization, so a person without permission cannot even look.

6Authentication: Proving Who You Are

Kubernetes does not keep a list of human users. Instead it trusts outside systems to vouch for people and checks their proof.

This surprises many beginners. There is no “create user” request in the Kubernetes API. Identities come from somewhere else, such as a certificate authority, a company sign-in system, or the cluster’s own service account mechanism. The API server simply supports several ways of checking proof, and a cluster can enable more than one at the same time.

Certificates

Client certificates

The client presents a certificate signed by a certificate authority the cluster trusts. The name inside the certificate becomes the user name. Common for cluster components and administrators, but hard to revoke.

Programs

Service account tokens

Programs running inside the cluster receive a signed token that proves which service account they are. Modern clusters issue short-lived tokens tied to a specific Pod.

People

OpenID Connect

The cluster trusts an identity provider such as a company sign-in system. People log in there and receive a signed token to show the API server.

Custom

Webhook token authentication

The API server forwards a token to an outside service and asks it to say who the caller is. Cloud providers use this to link cluster identity to their own account systems.

Proxy

Authenticating proxy

A trusted front proxy handles login and adds identity headers, and the API server believes it.

Avoid

Static tokens and anonymous access

Fixed password or token files never expire and are easy to leak. Anonymous access lets unnamed callers in. Both should be avoided in real clusters.

Everyday Analogy

Consider the ways to enter an office building. Employees might wave a photo badge (client certificate). Contractors get a day pass that expires by evening (short-lived token). Visitors are vouched for by a receptionist at a partner company (OpenID Connect). A good building never leaves a spare key under the doormat, which is what an anonymous or permanent static credential is.

Groups and identities

After authentication, the API server knows a user name and often a list of groups. It does not remember these. They arrive with every request and are used in the next step, authorization, to decide what is allowed. Because identities live outside Kubernetes, removing someone from your company sign-in system also removes their access, which is far safer than managing passwords inside the cluster.

!
Common mistake

Handing out the main administrator certificate file to everyone “just to get started.” It never expires quickly, cannot be individually revoked, and makes it impossible to know who did what. Give each person their own identity.

7Authorization: Deciding What You May Do

Authentication says who you are. Authorization says what you are allowed to do. They are different questions.

The default is “no”

Kubernetes authorization is based on a friendly rule: everything is forbidden unless a rule says it is allowed. Rules only ever add permissions and never take them away, which keeps the system easy to reason about. The API server can use several authorization methods together and allows a request as soon as one of them says yes.

MethodWhat it doesTypical use
RBACRoles list allowed actions, and bindings give roles to users, groups, or service accountsThe standard choice for nearly every cluster
Node authorizerLets each kubelet read only the objects related to its own nodeLimits the damage if one worker machine is compromised
WebhookAsks an outside service to decideCustom company rules or central policy systems
ABACUses a static policy fileOlder approach; rarely recommended today

RBAC in plain English

Role-Based Access Control has four simple building blocks. A Role is a list of allowed actions inside one namespace, such as “may read Pods and Services.” A ClusterRole is the same idea but can cover the whole cluster or resources that have no namespace, such as Nodes. A RoleBinding hands a Role to a person, group, or service account inside a namespace. A ClusterRoleBinding hands a ClusterRole out across the entire cluster.

Everyday Analogy

A Role is like a job description that lists which rooms a job needs: “the cashier role may open the till and the stock cupboard.” A binding is the act of giving a named person that job. If the person changes teams, you remove the binding and the access disappears, without rewriting the job description. Many people can share one role, and one person can hold several roles.

How a decision is made

The API server builds a small question from every request: who is asking, which verb, which resource, in which namespace, and which specific object. It then searches the RBAC rules for a match. If it finds one, the request moves on. If not, the caller receives a “forbidden” answer, and that denial is recorded in the audit log. Because the check uses the identity established one step earlier, the two steps work together as a pair.

What RBAC does well

  • Clear, reviewable rules that can be stored as files
  • Fine-grained control by namespace, resource, and verb
  • Easy to grant and revoke without touching credentials
  • Built into every certified Kubernetes distribution

Where it needs care

  • Rules can pile up and become hard to audit
  • Powerful roles such as cluster-admin are easy to over-share
  • Some permissions, like reading secrets or creating Pods, allow indirect escalation
  • It cannot express conditions such as “only during business hours”

8Admission Control: The Final Safety Checks

A request can have a proven identity and full permission and still be a bad idea. Admission control is where the cluster applies its own common sense.

What admission control is

Admission controllers are plugins inside the API server that examine, and sometimes change, requests that would create, update, or delete objects. They run after authentication and authorization, and before anything is saved. They are the reason a cluster can enforce rules like “every container must declare its memory needs,” “no container may run as an administrator,” or “every Pod must carry a team label.”

flowchart LR
    A["Request passes authentication and authorization"] --> B["Mutating admission - may change the object"]
    B --> C["Schema validation - is it well formed"]
    C --> D["Validating admission - may reject the object"]
    D --> E[("Saved in etcd")]
    D -.->|Rejected| X["Error returned to the caller"]
Figure 4. The two admission phases, separated by schema validation.

Two kinds: mutating and validating

Phase one

Mutating admission

Can modify the object. Typical jobs: fill in default values, add labels, inject a helper container such as a network proxy, or attach a default storage class.

Phase two

Validating admission

Can only say yes or no. Typical jobs: block risky settings, require labels, forbid images from untrusted registries, or enforce resource limits.

Built-in and custom controllers

Kubernetes ships with many admission controllers already switched on. The LimitRanger applies default resource sizes. The ResourceQuota controller refuses to let a namespace exceed the total amount of resources it was granted. The Pod Security admission checks Pods against the built-in Pod Security Standards. The NamespaceLifecycle controller stops new objects from being created inside a namespace that is being deleted.

When these are not enough, you can add your own in two ways. Admission webhooks let the API server call a program you write, over the network, before deciding. This is how service meshes inject their helper containers and how policy tools such as Kyverno and Open Policy Agent Gatekeeper enforce company rules. Newer clusters also support ValidatingAdmissionPolicy, which lets you write simple rules in a small expression language that runs inside the API server itself, with no outside program needed. That makes it faster and removes a possible point of failure.

Everyday Analogy

Picture airport security after your passport has been checked and your ticket confirmed. Staff may still ask you to remove your belt (a mutating step: they change how you enter) and scan your bags for forbidden items (a validating step: you may be turned away). Your ticket was valid, but the airport still has safety rules that apply to everyone.

!
Watch out

An admission webhook that is slow or unreachable can make the entire API server slow, or even block all creation of Pods if it is configured to fail closed. Keep webhooks fast, run several copies, and exclude critical system namespaces from their reach.

9Watch and Informers: How the Cluster Reacts

The API server does not just answer questions. It also tells everyone else, instantly, when something changes.

The problem with asking again and again

Imagine a controller that wants to know about new Pods. It could ask the API server every second, “Any new Pods?” With one controller this is harmless. With hundreds of controllers, thousands of nodes, and millions of objects, it would bury the API server in useless questions. Kubernetes solves this with the watch.

How a watch works

A client first asks for a full list of the objects it cares about. The API server answers and includes a resource version, which is a marker for “the state of the world at this moment.” The client then opens a long-lived connection and says, “Tell me everything that changes after this marker.” From then on the API server pushes a tiny message whenever an object is added, modified, or deleted. If the connection breaks, the client reconnects from the last marker it saw, so it never misses a change.

flowchart LR
    ETCD[("etcd")] --> WC["API server watch cache"]
    WC -->|list then watch| INF["Informer inside the controller"]
    INF --> LC["Local in-memory copy"]
    INF --> Q["Work queue of changed objects"]
    Q --> CTRL["Controller logic"]
    CTRL -->|write results| API["API server"]
    API --> ETCD
Figure 5. How a controller stays informed without constantly asking questions.

Informers and the local copy

Programs that watch the API use a helper called an informer. The informer performs the list, keeps the watch alive, and stores a private copy of the objects in memory. When the controller needs to look something up, it reads its own copy instead of calling the API server. When something changes, the informer puts the object’s name in a work queue, and the controller handles it in its own time. This is the reason one API server can serve an entire cluster full of hungry watchers.

Everyday Analogy

Compare a noticeboard with a phone call. If a hundred employees each phoned the front desk every few minutes to ask whether the schedule had changed, the receptionist would do nothing else. Instead, the desk pins the schedule to a noticeboard and announces changes once. Each employee keeps a personal copy and only pays attention when an announcement is made. The watch is the announcement system, and the informer is each employee’s personal copy.

Optimistic concurrency: two writers, one winner

What if two components try to change the same object at the same time? The API server uses the resource version again. Every update must include the version the writer last saw. If the object has changed since then, the API server refuses the update with a conflict error, and the writer must read the fresh copy and try again. This “check the version before you write” method prevents accidental overwrites without slow locks. It is also why you sometimes see the message that an object “has been modified” when editing configuration by hand.

i
Tip

Modern Kubernetes also offers server-side apply, where the API server tracks which tool owns which field of an object. Several tools, such as a deployment pipeline and an autoscaler, can then manage different fields of the same object without stepping on each other.

10The API Server and etcd

The API server and etcd are a pair. One is the spokesperson and the other is the memory.

The only door to the database

etcd is a small, reliable database that stores the full state of the cluster. Only the API server is allowed to read from it or write to it. Everything else, from the scheduler to the kubelets, asks the API server. This means the security of etcd depends on the API server being the sole guardian, and that you can change how data is stored, encrypted, or backed up in one place without touching the other components.

How data is stored

Each object is saved under a path-like key that includes its type, namespace, and name. The API server converts the object into a compact stored form, usually binary, and writes it. When Kubernetes releases a new API version, the API server can read old stored objects and convert them on the fly, so a cluster survives upgrades without a painful data migration.

The watch cache: protecting the database

etcd is precise but not built for thousands of clients watching at once. To protect it, the API server keeps its own in-memory cache of recent objects and changes. Most list and watch requests are answered from this cache. Only writes, and the occasional read that must be perfectly fresh, go all the way to etcd. This layer is one of the main reasons that Kubernetes clusters can scale to thousands of nodes on a fairly small database.

Encryption at rest

By default, secrets are stored in etcd only encoded, not truly encrypted. Anyone who could read the etcd files would see them. The API server can be configured to encrypt selected resources, especially Secrets, before storage, using keys that you control or that are protected by a cloud key management service. This protects against stolen disks and backups.

QuestionAPI serveretcd
Main roleFront door, rule checker, notifierDurable memory of the cluster
Holds permanent data?No, statelessYes
How many copies are typical?Two or three, or more for loadThree or five, always an odd number
Who can talk to it?Any authorized clientOnly the API servers
If it failsOther copies keep servingThe cluster can lose its ability to change if a majority fails

11Extending the API Server

One of the smartest features of Kubernetes is that you can teach its API new words.

Custom resources

Suppose your company runs databases and wants to say, in the same simple style as a Deployment, “I want a database called orders with three replicas and daily backups.” With a CustomResourceDefinition, you register a new resource type such as Database. From then on the API server treats it like a built-in type: it validates it, stores it in etcd, checks permissions for it, and lets people list and watch it. The API server does not know what a database is. It only stores the wishes.

Controllers and operators

To make the wishes come true, you add a custom controller, a program that watches those custom objects through the API server and takes action, such as creating the Pods, disks, and backup jobs needed. When such a controller encodes the knowledge of a human expert, for example how to safely upgrade a particular database, it is called an operator. Popular tools like Argo CD, cert-manager, Istio, and the Prometheus operator all work this way: they add resource types to the API and controllers that react to them.

The aggregation layer

Sometimes you need an entirely separate API server with its own logic and storage. The aggregation layer lets you register such an extra server so that requests to certain paths are forwarded to it, while clients still see one unified API. The metrics server uses this to provide resource usage information through the normal Kubernetes API.

Easiest

CustomResourceDefinition

Best for adding new resource types whose data is stored in etcd. Most extensions use this route.

Advanced

Aggregated API server

Best when you need custom storage, unusual behavior, or very high performance for your own API.

Policy

Admission webhooks

Best for changing or blocking requests according to your own rules.

Action

Custom controllers

Best for making things happen when objects change. They sit outside the API server and talk to it like any other client.

?
Good to know

Each custom resource type adds load to the API server and etcd. A few types are no problem, but installing dozens of tools that each add many types and thousands of objects can slow a cluster noticeably. Extension is powerful, so measure its cost.

12API Versions and Stability

The API is a promise. Kubernetes has clear rules for how and when that promise can change.

Alpha, beta, and stable

A

Alpha (for example v1alpha1)

Experimental. Off by default. It may change in incompatible ways or vanish without warning. Use only in throwaway test clusters.

B

Beta (for example v1beta1)

Well tested and usually on by default, but details may still change. Kubernetes tries to give warning and a path to move forward, but beta is not a lifetime promise.

S

Stable (for example v1)

Considered dependable. The project commits to supporting stable APIs for a long period and to give ample notice before removing them.

Deprecation: retiring old versions

When a newer version of an API replaces an older one, the old version is first marked deprecated, and the API server starts returning a warning whenever it is used. After a defined number of releases it is removed, and any configuration that still uses it stops working. A famous example was the removal of several older beta versions in the release of 2022, which broke many tools that had not been updated. The lesson is to read upgrade notes carefully, scan your configuration files for deprecated versions before every upgrade, and keep your tools current.

Conversion behind the scenes

Because several versions of one type can exist at once, the API server can convert between them. A client may write using one version and another client may read using a different version of the same object. The API server keeps one storage version in etcd and converts on the way in and out. This is what allows old and new clients to coexist during upgrades and makes the API dependable.

i
Tip

Before upgrading a cluster, check the warnings that your current API server emits. They are a free early notice of exactly which of your files will break in the next version.

13Performance, Scalability, and High Availability

The API server is on the path of nearly every action in the cluster, so it must be fast and it must not be a single point of failure.

Running several copies

Because the API server is stateless, the standard way to make it dependable is to run two or three copies, ideally in different availability zones, behind a load balancer. Clients connect to the load balancer’s address, which forwards each request to a healthy copy. All the copies are active at the same time, share the same etcd, and produce identical answers. Losing one simply shifts traffic to the others.

flowchart TB
    CLIENTS["kubectl, controllers, kubelets, pipelines"] --> LB["Load balancer with one stable address"]
    LB --> A1["API server 1 in Zone A"]
    LB --> A2["API server 2 in Zone B"]
    LB --> A3["API server 3 in Zone C"]
    A1 --> E1[("etcd member 1")]
    A2 --> E2[("etcd member 2")]
    A3 --> E3[("etcd member 3")]
Figure 6. A highly available API server layer: three active copies behind one stable address.

Protecting the server from overload

What if a buggy program sends the API server a flood of requests? Older versions used a crude cap on the number of simultaneous requests, which meant one noisy client could crowd out important ones. Modern clusters use API Priority and Fairness. Requests are sorted into priority levels, such as system-critical traffic from the control plane and ordinary traffic from users, and within each level they are shared fairly between callers. When the server is busy, a runaway script waits in its own queue while the scheduler and kubelets carry on. Clients that are turned away receive a “too many requests” answer and are expected to slow down and retry.

Habits that keep the API server fast

  • Use watches instead of repeated lists. Programs that list everything every few seconds are the number one cause of API server overload.
  • Ask for pages. Large lists can be fetched in chunks, which avoids sudden memory spikes.
  • Filter on the server. Label and field selectors let the API server send only what you need.
  • Keep objects small. Huge objects and endless numbers of tiny ones both cost memory and etcd space.
  • Limit extension sprawl. Every webhook and every custom type adds work to the request path.
  • Size the machines properly. Bigger clusters need more memory and processor for the API servers, and fast disks for etcd.
Everyday Analogy

A busy post office opens several counters, gives urgent registered mail its own fast lane, and asks anyone with a thousand parcels to come during a quiet hour. API Priority and Fairness applies the same manners to requests, so a single customer with a giant pile cannot make everyone else wait forever.

!
Watch out

When the API server slows down, everything slows down: deployments hang, autoscalers stop reacting, and nodes may look unhealthy because their heartbeats arrive late. Slowness here is often mistaken for a problem somewhere else.

14Advantages, Disadvantages, and Trade-offs

The single front door is a brilliant idea, and like every idea it has costs.

Advantages

  • One consistent place for identity, permission, policy, and audit
  • Components stay simple and independent
  • Uniform format for every object and every tool
  • Watches allow instant, efficient reactions
  • Easy to extend with new resource types
  • Stateless, so it scales and recovers easily

Disadvantages

  • Every action depends on it, so an outage blocks changes
  • A large cluster can overload it with watches and lists
  • Slow or broken webhooks can stall the whole cluster
  • A powerful target for attackers
  • Learning the layers of checks takes time

Key trade-offs

ChoiceYou gainYou give up
Many admission policiesStrong, uniform guardrailsExtra latency and more places where requests can fail
Webhooks that fail closedNo unchecked objects slip throughRisk of blocking the cluster when the webhook is down
Public API endpointEasy access from anywhereA larger attack surface
Private API endpointA much smaller attack surfaceExtra setup for remote access, such as a VPN
Many custom resource typesA powerful, unified platformMore load on the API server and etcd
Self-managed API serversComplete control over flags and pluginsYou handle certificates, upgrades, and capacity
Managed control planeThe provider runs and scales itFewer settings you can change

15Securing the API Server

Whoever controls the API server controls the cluster, so it deserves the strongest protection you can give.

Everyday Analogy

Think of the API server as the main control room of a power plant. You would not leave its door open to the street, hand out master keys to every visitor, or skip the security cameras. You would limit who can walk up to the door, check identities at the entrance, give each worker only the switches their job needs, and record everything that happens. Each of those habits has a direct match in the cluster.

A layered defense

Reach

Limit network access

Do not expose the API server to the whole internet if you can avoid it. Use a private endpoint, or restrict access to known address ranges and a VPN or bastion.

Identity

Strong authentication

Connect to your company’s sign-in system, require multi-factor login for people, turn off anonymous access, and avoid shared or static credentials.

Permission

Least-privilege RBAC

Give every person and program only the permissions needed for their job. Review who holds powerful roles such as cluster administrator, and remove what is not needed.

Programs

Careful service accounts

Pods should not automatically receive credentials that they never use. Give each app its own service account with tiny permissions, and use short-lived tokens.

Rules

Admission policies

Enforce the Pod Security Standards and your own rules so dangerous objects are rejected at the door.

Data

Encrypt secrets at rest

Turn on encryption for Secrets in etcd and protect the keys, preferably in a cloud key management service.

Transport

TLS everywhere

All traffic to and from the API server should be encrypted, with certificates renewed before they expire.

Memory

Audit logging

Record who called the API, what they asked, and what happened, and send those logs to a safe place that attackers cannot easily edit.

A real lesson from the field

Security researchers have repeatedly found clusters whose management interfaces were reachable from the open internet with no password. In one widely reported case in 2018, attackers found an exposed Kubernetes console at a large company and used it to run cryptocurrency mining software on the company’s cloud account. The attack did not require clever hacking. It only needed a door that had been left open, and it is a perfect reminder that the first layer of defense is simply not exposing the API server carelessly.

!
Common mistake

Believing that “authenticated” means “safe.” A stolen laptop with a valid access file, or a leaked token in a code repository, is fully authenticated. Short lifetimes, least privilege, network limits, and audit logs are what keep a stolen credential from becoming a disaster.

Managed services and shared responsibility

On Amazon EKS, Google GKE, and Azure AKS, the provider runs and patches the API servers for you, and it offers options for private endpoints and for sending audit logs to its logging service. You are still responsible for who has access, what those people can do, and which policies are enforced. The provider secures the building; you decide who gets a key.

16Monitoring, Logging, and Metrics

Because the API server sits in the path of everything, its health is the cluster’s health. Watch it closely.

Is it alive? Health endpoints

The API server exposes simple health-check addresses. The livez endpoint answers “is the process alive?”, the readyz endpoint answers “is it ready to serve traffic?”, and both can show the result of each internal check. Load balancers use these answers to decide which copies should receive requests, and cloud providers use them to replace unhealthy control plane machines.

How is it doing? Metrics

The API server publishes detailed measurements in a format that tools like Prometheus can collect. A handful of them tell most of the story.

What to watchWhat it tells youWorrying sign
Request rate by verb and resourceWho is making calls, and how manyA sudden spike from one client
Request durationHow long answers takeRising slow-response times, especially for writes
Error counts by status codeFailures, denials, and conflictsGrowing 5xx errors or floods of 429 “slow down” answers
In-flight requestsHow busy the server is right nowNumbers that stay near the limit
Priority and fairness queuesWhether requests are waiting or rejectedLong waits in important priority levels
etcd request latencyHow fast the database respondsSlow storage, which slows every write
Webhook latency and failuresDelays caused by admission pluginsSlow or timing-out webhooks
Certificate expiryDays until credentials stop workingLess than a few weeks remaining

Audit logs: the cluster’s black box

Audit logging records a trail of requests passing through the API server. You write an audit policy that says how much detail to record for each kind of request, from just the basic facts (who, what, when) to the full request and response bodies. A common approach is to record light information for most calls and detailed information for sensitive ones, like changes to permissions or access to Secrets. Audit logs answer questions such as “who deleted this Deployment last Tuesday?” and “which account has been trying to list Secrets?”

Application logs and events

The API server also writes its own text logs, which are crucial when a request is unexpectedly refused or a webhook misbehaves. On managed services, the provider offers these as control plane logs that you can turn on. Do not forget Kubernetes events, the short notes that the cluster writes about itself. They are stored through the API server too, and they are the first place to look when a Pod will not start.

i
Tip

Alert on patterns customers and operators feel: rising errors, slow writes, and long queues, not on every single failed request. A few denied calls are normal. A sudden wave of them is a story worth reading.

17Design Patterns and Anti-Patterns

Patterns are habits that healthy teams share. Anti-patterns are shortcuts that feel smart today and hurt later.

Patterns that work

Pattern

Watch, don’t poll

Any program that needs to react to cluster changes should use informers and watches instead of repeating the same list request.

Pattern

Declarative configuration

Keep the desired state in files under version control and apply it through the API. Every change is reviewed and reproducible.

Pattern

Policy as code

Express company rules as admission policies that live in version control, so the API server enforces them on every request.

Pattern

One identity per actor

Every person, pipeline, and application gets its own identity and minimal permissions. Auditing then tells a clear story.

Pattern

Custom resource plus controller

Extend Kubernetes with a new resource type and a controller that reconciles it, so your own systems feel native.

Pattern

Private endpoint, public app

Keep the management API reachable only through private networks while the applications it runs face the public.

Anti-patterns to avoid

ANTI-PATTERN 01Avoid
What it looks like

A script or dashboard asks the API server for the full list of Pods every few seconds.

Why it hurts

Each call forces the server to gather and send a large response. Several such tools can consume the memory and processor the control plane needs for real work, and slow every deployment.

Do this instead

Use an informer or a watch so that the server only sends changes, and read from a local copy.

ANTI-PATTERN 02Avoid
What it looks like

Giving every developer and every pipeline the cluster-admin role.

Why it hurts

One leaked file or one typing mistake can delete everything or expose all Secrets, and audit logs cannot show who was responsible.

Do this instead

Grant narrow roles per namespace and per job, and keep administrator access for a few people with strong protections.

ANTI-PATTERN 03Avoid
What it looks like

A single admission webhook that is slow, runs as one copy, and applies to every namespace including the system ones.

Why it hurts

If the webhook is down or restarts, the API server cannot get an answer, and requests may fail, including those needed to bring the webhook itself back.

Do this instead

Run several copies across zones, set short timeouts, exclude system namespaces, and prefer built-in ValidatingAdmissionPolicy for simple rules.

ANTI-PATTERN 04Avoid
What it looks like

Exposing the API server to the public internet with anonymous or weakly protected access, for convenience.

Why it hurts

Automated scanners find open cluster endpoints within hours, and a single weakness gives an attacker control of every workload.

Do this instead

Use private endpoints or strict address allow-lists, disable anonymous access, and require strong sign-in.

18Best Practices and Common Mistakes

These lessons are usually learned painfully. You can learn them here for free.

Best practices

  • Run at least two, preferably three, API servers across zones behind a load balancer, or use a managed control plane that does this for you.
  • Keep Kubernetes current. Upgrade one version at a time, test in staging, and read the notes about removed API versions first.
  • Enable audit logging with a sensible policy, and ship logs to a protected, separate system.
  • Use short-lived credentials. Prefer sign-in through an identity provider and bound service account tokens over long-lived files.
  • Apply least privilege. Review RBAC regularly and remove old bindings.
  • Turn on encryption for Secrets at rest and protect the keys.
  • Tune client behavior. Make your own programs use watches, pagination, and back-off when told to slow down.
  • Watch the numbers. Track request latency, error rates, queue depth, and etcd health, and set alerts.
  • Test your extensions. Load-test webhooks and controllers, and decide deliberately whether each should fail open or closed.
  • Practice recovery. Rehearse losing one API server, then the load balancer, then restoring etcd from a backup.

Common mistakes

MistakeWhat happensBetter habit
Sharing the admin kubeconfig fileNo accountability, and one leak exposes everythingIndividual identities with limited roles
Ignoring deprecation warningsUpgrades break tools and pipelinesScan configuration files and update before upgrading
No audit logsIncidents cannot be investigatedEnable and protect audit logs from day one
Letting certificates expireComponents stop trusting each other and the cluster stallsTrack expiry dates and automate renewal
Polling instead of watchingOverloaded control planeUse informers and caches
Fail-closed webhooks without redundancyCluster locked out of creating PodsMultiple copies, timeouts, and namespace exclusions
Storing secrets unencryptedAnyone with etcd access reads themEncrypt at rest and consider an external secrets manager
Treating the API server as a databaseHuge objects and heavy traffic slow etcdStore application data in a real database

19Real-World and Industry Examples

These examples come from what organizations and projects have shared publicly. Details may have changed since.

Managed services hide the API server for you

On Amazon EKS, Google GKE, and Azure AKS, the cloud provider runs the API servers across several zones, patches them, and scales them. Customers see only an endpoint address. This is why a large share of companies never touch an API server’s settings directly, and why “the control plane is managed” is one of the biggest selling points of these services.

OpenAI’s very large clusters

OpenAI has written publicly about running Kubernetes clusters of several thousand nodes for machine learning research. Their write-ups describe how growth exposed pressure on the API servers and etcd, for example from very large lists of network endpoints, and how they tuned the system and adjusted how components watch data. It shows how a design that works well at a small scale needs careful attention at a very large one.

The tools that extend the API

Well-known open-source projects such as Argo CD for continuous delivery, cert-manager for certificates, and Istio for service networking all add custom resource types to the API server. Teams describe what they want, such as a certificate for a website or a rollout of an application, as ordinary objects, and controllers make it happen. This pattern is the main reason Kubernetes became a platform for building platforms.

The exposed console incident

The 2018 case of attackers using an unprotected Kubernetes console to mine cryptocurrency on a company’s cloud account, widely reported at the time, showed how costly an open management interface can be. Since then, cloud providers have made private endpoints and stronger defaults much easier to choose.

A typical online store

A store’s engineers merge a code change. The pipeline signs in with its own short-lived identity and sends an updated Deployment to the API server. The server confirms the identity, checks the pipeline’s role, lets an admission policy add the company’s standard labels and reject any container that runs as an administrator, saves the object, and notifies watchers. Controllers create the new Pods, the scheduler places them, and the kubelets start them, all coordinated through the same door. The audit log records every step, so if anything goes wrong, the team can see exactly who changed what.

20Frequently Asked Questions

Q1In one sentence, what is the Kubernetes API server?
It is the front door of the cluster: the program that receives every request, checks identity, permission, and rules, stores the result in etcd, and notifies everyone who needs to know.
Q2Is the API server the same as kubectl?
No. Kubectl is a client tool that sends requests. The API server is the program inside the cluster that receives and answers them.
Q3Why does only the API server talk to etcd?
It keeps the database protected behind one strong gate, gives every object a consistent format and rule check, and lets everything else stay simple. It also lets the storage details change without affecting other components.
Q4What happens if the API server goes down?
Applications that are already running normally keep running, because kubelets continue to manage their containers. But nobody can make changes, and self-healing and autoscaling pause until a server returns. This is why production clusters run several copies.
Q5What is the difference between authentication and authorization?
Authentication proves who you are. Authorization decides what you are allowed to do. A caller can pass the first and still fail the second.
Q6What is admission control for?
It applies the cluster’s own rules to permitted requests. Mutating plugins can adjust an object, for example by adding defaults, and validating plugins can reject it, for example if it is unsafe.
Q7What is a watch, and why is it important?
A watch is a long-lived connection over which the API server pushes changes as they happen. It lets controllers react quickly without repeatedly asking for the same data, which keeps the server from being overloaded.
Q8Can I run more than one API server?
Yes, and you should in production. They are stateless and can all serve traffic at once behind a load balancer, sharing the same etcd.
Q9How do I add my own resource types?
Register a CustomResourceDefinition, which teaches the API server a new type. Then write a controller that watches those objects and acts on them. For more special needs, an aggregated API server is available.
Q10Is the API server public by default?
That depends on how the cluster was created. Many managed services offer a public endpoint by default for convenience, along with options for private access. Always check and restrict it according to your needs.
Q11What does a “forbidden” error mean?
Your identity was accepted, but no rule allows the action you tried. The fix is to grant the proper role through a binding, not to widen access to everything.
Q12What does a “too many requests” error mean?
The server is protecting itself. Its priority and fairness system decided that your client is asking for too much at once. The client should wait and retry with growing pauses, and its owners should look for polling loops.
Q13How can I see who made a change?
Use audit logs. If audit logging was enabled with a suitable policy, they record the identity, the action, the object, and the time of each request.

21Summary and Key Takeaways

Key Takeaways

  • The API server is the single front door. Every person, tool, and component reaches the cluster through it, and it is the only component that talks to etcd.
  • Every write passes the same checkpoints. Authentication, authorization, mutating admission, schema validation, validating admission, and only then storage, in that order.
  • Objects have a spec and a status. You declare what you want, components report what exists, and controllers close the gap using the API as their shared record.
  • Watches make the cluster reactive and efficient. Informers keep local copies and hear about changes instantly, so clients should watch instead of polling.
  • It is stateless and extensible. Run several copies behind a load balancer for availability, and extend it with custom resources, controllers, and admission policies.
  • Protect and observe it above everything else. Use private access, least-privilege permissions, short-lived credentials, encrypted secrets, audit logs, and metrics, because whoever controls the API server controls the cluster.