Kubernetes Basics For Go
Fast recall
Quick revision
Core answer
Whether you understand Kubernetes Basics For Go beyond memorized syntax.
Giving a definition without explaining a practical trade-off.
Connect the concept to a small production example and state its complexity or failure mode.
Interview-ready guide
Interview answer
The minimum mental model:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels: {app: myapp}
template:
metadata:
labels: {app: myapp}
spec:
containers:
- name: myapp
image: registry/myapp:v1.2.3
ports: [{containerPort: 8080}]
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef: {name: db-secret, key: url}
livenessProbe:
httpGet: {path: /healthz, port: 8080}
readinessProbe:
httpGet: {path: /readyz, port: 8080}
resources:
requests: {cpu: 100m, memory: 128Mi}
limits: {cpu: 500m, memory: 256Mi}
---
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
selector: {app: myapp}
ports: [{port: 80, targetPort: 8080}]The objects a Go developer needs:
- POD: your container + its env — the unit of scheduling (you write a Deployment, not pods)
- DEPLOYMENT: replicas + rolling update (change the image tag → kubectl apply → the new version rolls out)
- SERVICE: the stable DNS name (myapp.namespace.svc) — the pod IPs change; the service routes
- configMap/secret: the env vars — mounted into the container
- INGRESS: the external traffic → the service
The Go-specific integration points:
- The /healthz and /readyz endpoints (the probes poll them — the health-check topic)
- The graceful shutdown (SIGTERM on pod stop → http.Server.Shutdown drains in-flight)
- GOMAXPROCS: Kubernetes sets CPU limits (resources.limits.cpu) — Go's scheduler reads it (1.25 reads the cgroup) or set GOMAXPROCS explicitly (the automaxprocs library for older versions)
- The rolling update's zero-downtime: readiness goes false on the old pods, the new pods come up, traffic shifts — your graceful shutdown completes the story
Kubernetes Basics For Go
Direct Answer
The pod (your Go container), the deployment (replicas + rolling updates), the service (the stable network name), the configMap/secret (env vars), probes (liveness/readiness). Your Dockerfile + a YAML = deployed.
Deep Dive & Architecture
The rolling update mechanics (the interview depth): the Deployment's strategy (maxSurge, maxUnavailable) controls the pace — v2 pods come up (surge), ready (probes pass), the service routes to them, the v1 pods stop (unavailable). The image pull policy, the readiness gate, and the service selector tie the loop. The Go app's part: the readiness endpoint that goes non-200 when draining, and the graceful shutdown that finishes in-flight requests before the container exits.
The resource requests/limits (the scheduling): requests = the scheduler's placement input (the pod gets a node with 100m spare); limits = the cgroup ceiling (500m = the throttled maximum). Go's memory: the limit is the OOM-kill threshold — the GC sees the cgroup limit (Go 1.19+) and runs harder as it approaches. The CPU limit: Go's GOMAXPROCS should match the limit's core count — automaxprocs or the 1.25 cgroup awareness.
The config hierarchy, from the Go binary's perspective: the app sees ENV VARS (the container spec's env, from configMaps and secrets). The same binary, the same image, different YAML per environment — the Kubernetes manifest IS the environment's definition, the env vars are the app's runtime config, and the separation (image vs config) is the 12-factor principle at the orchestrator level.
Common Mistakes & Pitfalls
Giving a definition without explaining a practical trade-off.
Check your understanding
Answer these without looking back at the article.
- When would you use Kubernetes Basics For Go in a real project?
- How would you compare Kubernetes Basics For Go with an alternative?
- What is a common mistake when using Kubernetes Basics For Go?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.