Write a Deployment that uses the downward API to expose the pod name and node name to the app.
IntermediateHands-onWrite-a-Kubernetes-manifest tasks
Answer
env:
- name: POD_NAME
valueFrom: { fieldRef: { fieldPath: metadata.name } }
- name: NODE_NAME
valueFrom: { fieldRef: { fieldPath: spec.nodeName } }
- name: MEM_LIMIT
valueFrom:
resourceFieldRef: { containerName: app, resource: limits.memory }
Key trick → The downward API lets the app log which pod and node it runs on, or size its caches from its own memory limit, without calling the Kubernetes API.
More on Write-a-Kubernetes-manifest tasks
Write a Deployment and Service for an Nginx app with 3 replicas, resources and probes.BeginnerAdd an HPA that scales the Deployment between 3 and 15 pods at 70% CPU.BeginnerFix this broken Deployment YAML.BeginnerWrite a ConfigMap and Secret and inject them as environment variables and as a mounted file.IntermediateWrite an Ingress that routes `/api` to the api service and `/` to the web service with TLS.IntermediateWrite a pod spec with a hardened securityContext.Intermediate