Complete the code to set a resource limit for CPU in a pod specification.
resources:
limits:
cpu: [1]The CPU limit in Kubernetes is specified in millicores, so 500m means half a CPU core.
Complete the command to view the current resource usage of pods in a namespace.
kubectl top pods -n [1]The default namespace is the common namespace where pods run if none is specified.
Fix the error in the YAML snippet to request 1 CPU core for a container.
resources:
requests:
cpu: [1]CPU requests use millicores, so 1000m means 1 full CPU core.
Fill both blanks to create a Horizontal Pod Autoscaler that scales between 2 and 5 replicas based on CPU usage.
apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: example-hpa spec: minReplicas: [1] maxReplicas: [2] metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 50
The minimum replicas is 2 and maximum replicas is 5 to control scaling limits.
Fill all three blanks to create a resource quota limiting pods and CPU usage in a namespace.
apiVersion: v1
kind: ResourceQuota
metadata:
name: cpu-pod-quota
spec:
hard:
pods: [1]
requests.cpu: [2]
limits.cpu: [3]This quota limits pods to 10, CPU requests to 1000m (1 CPU), and CPU limits to 8 cores.