Around Go: Kubernetes · 3 MIN READ
Kubernetes reconciles a workload; a Service routes to it
Read Deployment, Pod labels, resource budgets and a Service without confusing them with an application build.
Kubernetes operates containerized workloads. It does not write your Go code or remove distributed-system failures. A Deployment describes the desired replicated workload; a Service gives selected Pods a stable network abstraction while individual Pods are replaced.
Follow selectors and labels
This abbreviated manifest connects a Service to Pods carrying app: go-api. The image reference is a placeholder for an image you have built, tested and published to an accessible registry. Read it as configuration, not something the iOS app can apply.
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-api
spec:
replicas: 2
selector:
matchLabels: {app: go-api}
template:
metadata:
labels: {app: go-api}
spec:
containers:
- name: api
image: your-registry/go-api:tested
ports: [{containerPort: 8080}]
resources:
requests: {cpu: "100m", memory: "128Mi"}
limits: {cpu: "1", memory: "512Mi"}
---
apiVersion: v1
kind: Service
metadata:
name: go-api
spec:
selector: {app: go-api}
ports: [{port: 80, targetPort: 8080}]The numbers illustrate syntax, not capacity recommendations. This Service is internal by default; public ingress, TLS and authentication need their own design. The Deployment example still needs suitable probe and shutdown policies.
Observe replicas, requests and limits
Requests influence scheduling; CPU and memory limits have different runtime effects. Use the Pod specification and Deployment state to inspect the declared budget, then compare with metrics if the cluster exposes them. The sample numbers are illustrative rather than recommendations.
kubectl --context dev-cluster -n go-lab get deployment go-api
kubectl --context dev-cluster -n go-lab get pods -l app=go-api -o wide
kubectl --context dev-cluster -n go-lab get deployment go-api \
-o jsonpath='{.spec.template.spec.containers[0].resources}{"\n"}'Run after the context/setup and apply lessons. Two replicas each allowing fifty downstream calls can present a hundred simultaneous calls. Resource declarations do not measure actual usage; memory exhaustion can terminate a container while CPU limits can throttle it.
Use orchestration only when it pays for itself
Rolling replacement and service discovery help teams operating many workloads, but cluster maintenance and debugging cost time. A VM, a managed service or a single container host can be simpler for a small application. Learn the reconciliation model before copying a large production manifest, and inspect a plan in a non-production environment before applying it.
TAKE THIS WITH YOU
Match labels to selectors, give each replica a resource and downstream budget, and treat public routing as a separate concern.
Check your understanding
Which statement is correct about a kubernetes service selector?
Go to the source
Progress stays in this browser. No account needed.