Cloud & GCP interview question

MLOps & ProductionCloud & GCPAccess Controleasy

A security review of a retail client's Google Cloud project finds that the Vertex AI training pipeline, a GKE scoring service and a nightly export job all run as the Compute Engine default service account with the Editor role, and a downloaded JSON key for it sits in a Kubernetes Secret. Which redesign follows Google Cloud best practice?

  1. AGive each workload its own service account with only the roles it needs, use Workload Identity on GKE instead of a JSON key, and keep other secrets in Secret Manager.
  2. BKeep one shared service account so permissions are managed in one place, but rotate its JSON key every 90 days and store it base64-encoded in a Kubernetes Secret.
  3. CCreate one service account per workload, each with the Editor role so no pipeline fails on a missing permission, and use Workload Identity on GKE instead of a JSON key.
  4. DRun each workload with the user credentials of the data scientist who owns it, using that person's existing roles, so every action in the audit logs points to a named human.
Show the answer and explanation

Correct answer: A, Give each workload its own service account with only the roles it needs, use Workload Identity on GKE instead of a JSON key, and keep other secrets in Secret Manager.

Explanation Cloud & GCP

Least privilege on Google Cloud comes down to three habits:

  1. One service account per workload, with narrow predefined roles at the smallest scope, e.g. read one bucket (roles/storage.objectViewer) or write one BigQuery dataset. A compromise then exposes one workload's permissions, not the whole project.
  2. No long-lived keys. Downloaded JSON keys do not expire by default, get copied into repos, images and laptops, and are a classic source of credential leaks. On GKE, Workload Identity (Workload Identity Federation for GKE) maps a Kubernetes service account to an IAM identity so Pods receive short-lived tokens automatically; Vertex AI jobs and Cloud Run services simply run as their attached service account.
  3. Secrets in Secret Manager (versioned, IAM-controlled, audited) rather than in env files, images or ConfigMaps.

Why the others are wrong:

  • Rotating a shared key shortens the exposure window but keeps one broad identity for everything, and base64 is an encoding, not encryption.
  • Per-workload accounts that all hold Editor keep the blast radius of the old design even without keys: Editor is a basic role that can change almost every resource in the project, and Google advises against basic roles in production.
  • A person's user credentials give a workload that person's usually broad roles, need a long-lived refresh token stored with the job, and break when the person leaves; accountability comes from per-workload service accounts plus Cloud Audit Logs.

Interview tip: call out running workloads as the default compute service account with Editor as a known anti-pattern, and mention that an organization policy can block service-account key creation altogether.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More MLOps & Production questions

  1. On a GKE cluster you deploy a model server as a Deployment with 3 replicas and expose it with a Service. Which statement correctly describes these Kubernetes…
  2. Which statement best defines MLOps?
  3. An 8B support model (≈ 16 GB of BF16 weights) is served with a vLLM-style engine as shown below. At peak, the time per output token (TPOT) spikes and the…
  4. Re-running the training job below from the same git commit one month later gives a validation AUC of 0.861 instead of the logged 0.874. The library versions,…
  5. Estimate the monthly LLM bill for this RAG chatbot workload. Every user turn is a separate API call that re-sends the full prompt.