Write a Kustomize overlay that changes replicas and image tag for production.
IntermediateHands-onWrite-a-Kubernetes-manifest tasks
Answer
base/kustomization.yaml -> resources: [deployment.yaml, service.yaml]
overlays/prod/kustomization.yaml
# overlays/prod/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: prod
resources:
- ../../base
images:
- name: myrepo/api
newTag: "1.5.0"
replicas:
- name: api
count: 6
patches:
- path: resources-patch.yaml
Render: kubectl kustomize overlays/prod or apply with kubectl apply -k overlays/prod.
Key trick → The images and replicas transformers change values without a patch file. CI bumps tags with kustomize edit set image myrepo/api:1.5.1.
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