Skip to main content
Kubernetes internalsLesson 1 of 12

How an API Request Gets Stored

A request sent by a dashboard [Create] button or by kubectl apply passes several gates inside the API server before it is stored. Which gate rejects it decides the error the user sees. Authentication and authorization are covered in Who Can Do What (RBAC), and what happens after storage is covered in How a Pod Starts. This lesson focuses on what lies between: admission, storage and conflicts.

Current gate—
Response—
resourceVersion—
User Akubectl / dashboardUser Bedits same objectAPI serverentry for all requestsAuthN / AuthZwho · allowed?Mutating hookmodifies valuesSchema checkchecks formatValidating hookpolicy decisionetcdstate storeControllerwatch subscriberPOST web
RequestResponse / reportWatchAppears in a later step

What you will learn

  • Order: authN → authZ → admission → storage
  • Why the stored YAML differs from what you sent
  • Why one webhook can block all creation
  • The difference between "stored" and "applied"
  • Why 409 Conflict happens and how to handle it

Errors by gate​

GateIf rejectedWhat the user sees
Authentication401 UnauthorizedLogged out, or credentials expired
Authorization (RBAC)403 ForbiddenNo permission. The message names the user, verb and resource
Mutating admissionRarely rejectsThe stored YAML looks different from what you sent
Schema validation422 Unprocessable EntityA "field is invalid" error
Validating admission403 or a policy-specific message"exceeded quota", admission webhook "..." denied the request
Webhook server not answeringfailed calling webhookTimeout. Every create in that webhook's scope can fail
Storage409 ConflictThe name already exists, or someone else changed it first

Try it yourself​

kubectl get pods -n kube-system -v=6 # One HTTP request: method, URL, response code
kubectl auth can-i create deployments -n <namespace> # Would authorization pass, or 403?
kubectl get mutatingwebhookconfigurations,validatingwebhookconfigurations -o custom-columns=NAME:.metadata.name,FAILURE:.webhooks[*].failurePolicy # Webhooks in the path and their failurePolicy
kubectl create deployment demo --image=nginx --dry-run=server -o yaml # Passes every gate but is not stored; see added fields
kubectl get deployment <name> -o jsonpath='{.metadata.resourceVersion}' # Changes on every write

Check yourself

  1. You wrote a Pod with one container, but the stored Pod shows two. What is most likely?
  2. Suddenly every Pod creation in the cluster fails with failed calling webhook. What should you check first?
  3. You leave kubectl edit open for a while, then save and get 409 Conflict. What should you do?

Further reading: Controlling Access to the Kubernetes API · Admission controllers · API concepts — resourceVersion