Complete the code to create a Kubernetes Deployment with 3 replicas.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: [1]
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app-container
image: my-app-image:latestThe replicas field sets how many copies of the app run. Here, 3 replicas means 3 pods will run.
Complete the code to define a Kubernetes Service that targets pods with label 'app: my-app'.
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
selector:
app: [1]
ports:
- protocol: TCP
port: 80
targetPort: 8080The Service selector must match the pod label to route traffic correctly. Here, pods labeled app: my-app are targeted.
Fix the error in the rollout strategy to enable rolling updates with max 25% unavailable pods.
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: [1]Setting maxUnavailable to 25% allows at most 25% of pods to be down during updates, enabling smooth progressive delivery.
Fill both blanks to define a canary deployment with 10% traffic and 90% stable traffic.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: my-app
spec:
hosts:
- my-app.example.com
http:
- route:
- destination:
host: my-app
weight: [1]
- destination:
host: my-app-canary
weight: [2]The weights control traffic split. 90% goes to stable, 10% to canary for gradual rollout.
Fill all three blanks to create a Kubernetes HorizontalPodAutoscaler targeting CPU usage at 50%.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: [1]
minReplicas: [2]
maxReplicas: [3]
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50The HPA targets the Deployment named my-app, scales between 1 and 5 replicas based on CPU usage at 50%.