An engineering team is attempting to deploy a stateless microservice to a Google Kubernetes Engine (GKE) Autopilot cluster. The Kubernetes Deployment manifest includes a Pod specification that configures a `hostPath` volume to write cache files directly to the host node directory `/var/cache/app`. When the team executes `kubectl apply -f deployment.yaml`, the Kubernetes API server rejects the request. The team must deploy the application on GKE Autopilot using container best practices while adhering to Google Cloud security boundaries. Which change should the team make to resolve this deployment issue?
- Replace the `hostPath` volume with an `emptyDir` volume in the Pod specification to provide temporary storage without accessing the host filesystem.Answer
- BConvert the existing cluster operational mode to GKE Standard by running `gcloud config set container/cluster_mode standard` before reapplying the manifest.
- CUpdate the local kubeconfig context by running `gcloud config set container/use_client_certificate true` to bypass cluster admission control policies.
- DAdd a `nodeSelector` specifying Spot VM node pools in the Deployment manifest, as Spot nodes permit unrestricted host filesystem mounts.
Answer
Replace the hostPath volume with an emptyDir volume in the Pod specification to provide temporary storage without accessing the host filesystem.
In GKE Autopilot, Google manages the underlying nodes, security hardening, and host OS. To guarantee node integrity, Autopilot restricts privileged operations, including custom `hostPath` volume mounts. Replacing `hostPath` with an `emptyDir` volume provides the workload with scratch/cache storage isolated to the pod without breaking Autopilot security guardrails.
Step-by-Step Solution
Key Concept
GKE Autopilot Workload Security Constraints and Storage Mechanisms
Estimated Time:2m 0s