Kubernetes REST API
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The Kubernetes REST API is the control surface behind kubectl, controllers, and most cluster automation. If you can authenticate to the API server and understand the resource paths, you can list, inspect, create, and update Kubernetes objects directly over HTTP.
Core API Structure
Kubernetes exposes two main path families.
- '
/apifor core resources such as pods, services, namespaces, and config maps' - '
/apisfor grouped APIs such as deployments inapps/v1'
For example, listing pods in the default namespace uses the core API path:
A deployment list uses the grouped API path:
The Easiest Way to Explore: kubectl proxy
Direct API-server authentication can be noisy while you are learning. A practical starting point is kubectl proxy, which opens a local HTTP endpoint and forwards authenticated traffic using your current kubeconfig.
After that, basic GET requests become easy:
That is useful for debugging, scripting, and understanding what kubectl commands map to under the hood.
Reading and Writing Resources
The API is resource-oriented. A GET reads objects, a POST creates one, a PUT replaces one, and a PATCH updates part of one.
Here is a simple create request for a config map through the proxy:
The server validates the object and stores it in etcd through the normal Kubernetes control-plane path.
Authentication Outside kubectl proxy
In production integrations, clients usually authenticate with a kubeconfig credential, a service-account token, or an external identity provider. Inside a pod, Kubernetes mounts service-account credentials by default unless that behavior is disabled.
A direct in-cluster call often looks like this:
That pattern is common in operators, sidecars, and diagnostic tools running inside the cluster.
Namespaces, Versions, and Discovery
Resource URLs include both version and scope. Some resources are namespaced, such as pods and secrets. Others are cluster-scoped, such as nodes and namespaces.
You can discover what the server supports through endpoints such as:
That is useful because Kubernetes evolves over time, and not every cluster exposes the same CRDs or API groups.
Watch Requests and Automation
The REST API also supports watch semantics so clients can follow resource changes over time instead of polling repeatedly.
Controllers and operators rely heavily on this model. They read the current state, watch for changes, and reconcile toward the desired state.
Common Pitfalls
A common mistake is calling the wrong path family, such as using /api for deployments instead of /apis/apps/v1. Another is forgetting namespace scope and then wondering why a resource is not found. Developers also often test through kubectl proxy successfully but then omit authentication and TLS details when switching to direct API-server calls. Finally, writing objects with outdated API versions can fail even if an old example looked correct on a different cluster.
Summary
- The Kubernetes REST API is the HTTP interface behind most cluster operations.
- Use
/apifor core resources and/apisfor grouped resources. - '
kubectl proxyis the easiest way to explore the API locally.' - Direct calls need proper authentication, TLS, and the correct namespace scope.
- Discovery endpoints help you confirm supported API groups and versions before automating against them.
Related reading
- Kubernetes rolling deployments and database migrations
- Kubernetes Rolling Update not obeying 'maxUnavailable' replicas when redeployed in autoscaled conditions
- Kubernetes Rolling Updates Respect pod readiness before updating
- Kubernetes Secrets - What is the purpose of type Opaque in secret definitions
- Kubernetes, simple SpringBoot app OOMKilled
- kubernetes Single service definition with multiple pod selectors
- Kubernetes service external ip pending
- Kubernetes set-up on ubuntu on Google compute

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.