Complete the code to create a basic Pod in Kubernetes.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: [1]The image field specifies the container image to run. nginx is a valid image name.
Complete the code to expose a Deployment with a Service of type LoadBalancer.
apiVersion: v1 kind: Service metadata: name: my-service spec: type: [1] selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 8080
The LoadBalancer type exposes the service externally using a cloud provider's load balancer.
Fix the error in the Deployment spec to correctly set the number of replicas.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
replicas: [1]
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: nginxThe replicas field expects an integer, not a string or word.
Fill both blanks to create a ConfigMap and mount it as a volume in a Pod.
apiVersion: v1
kind: Pod
metadata:
name: configmap-pod
spec:
containers:
- name: app
image: busybox
volumeMounts:
- name: config-volume
mountPath: [1]
volumes:
- name: config-volume
configMap:
name: [2]The mountPath is where the ConfigMap files appear inside the container. The name under configMap must match the ConfigMap resource name.
Fill all three blanks to create a Horizontal Pod Autoscaler targeting a Deployment.
apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: [1] spec: scaleTargetRef: apiVersion: apps/v1 kind: [2] name: [3] minReplicas: 1 maxReplicas: 5 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 50
The HPA needs a name, the kind of resource it scales (Deployment), and the name of that resource.