Circleci GKE

Published
Length
3 min read

Luis Felipe Dias

All posts

A circleci gke pipeline sends app updates from your build job to your Google cluster. You set this up by linking a cloud identity to a Kubernetes role. Most teams start by giving the build runner a shared key with broad cluster rights. That fast path gets apps running, but a broad role lets any job change the whole cluster. If a build script has a bug, it can break live apps in other namespaces. How a circleci gke workflow operates To run a safe circleci gke workflow, you split identity check

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

A circleci gke pipeline sends app updates from your build job to your Google cluster. You set this up by linking a cloud identity to a Kubernetes role. Most teams start by giving the build runner a shared key with broad cluster rights. That fast path gets apps running, but a broad role lets any job change the whole cluster. If a build script has a bug, it can break live apps in other namespaces.

How a circleci gke workflow operates

To run a safe circleci gke workflow, you split identity checks from cluster rules. First, the build runner proves who it is to the cloud provider. Then, the Kubernetes API server checks what that identity can do inside the cluster. Kubernetes RBAC uses the rbac.authorization.k8s.io API group to manage these rules on the API server.

In Kubernetes RBAC, a Role or ClusterRole holds a set of permissions. These permissions are additive only, which means there are no deny rules at all. A Role always sets rules inside one single namespace. A ClusterRole is not tied to one namespace and can cover nodes or all namespaces.

Once you define a Role, you attach it to your build identity with a binding. A RoleBinding grants those permissions inside one specific namespace. A RoleBinding can point to a Role in that namespace or a shared ClusterRole. In contrast, a ClusterRoleBinding grants access across the entire cluster at once.

For a build runner, a namespace RoleBinding is much safer than a cluster-wide binding. You give the runner permission to update deployments only in the target app namespace. RBAC also refers to resources by the exact name in the API URL. Some APIs use a subresource, such as a pod log or an exec call. In RBAC, you write the subresource with a slash, like pods and log.

Where native cluster roles fall short

Native roles and bindings do a good job of limiting which namespaces a runner reaches. They stop a staging build job from touching a live payment namespace. Still, static RBAC rules only decide who can call an API endpoint. They do not inspect what individual commands or changes do while they run in flight.

Many build pipelines need to run database migrations or one-off fix scripts inside a pod. To do that, teams give the runner permission on the pod exec subresource. Once a role grants exec rights, Kubernetes cannot filter which shell commands run inside the container. A bad script or a leaked build token can run any command inside that pod.

GKE Workload Identity + CircleCI Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Engineers also use the same cluster roles when a build fails and needs a manual fix. If they read app data or pod logs, sensitive fields come back in plain text. Native RBAC cannot rewrite emails, phone numbers, card numbers, or national IDs in output results. It also cannot ask a teammate to approve a risky command before it runs.

Scoping build and debug rules for daily runs

To keep your cluster safe, start by removing all ClusterRoleBindings from your build runners. Create one Role per namespace and list only the resource types your deploy step needs. Never add pod exec rules to a standard build role unless a step truly needs it.

When a job or an engineer needs to run commands inside a container, separate that workflow. Keep standard app rollouts on narrow, automated roles that only update deployment manifests. Handle live container commands and database checks through a path that inspects every single action.

Govern kubectl and API calls in flight

Identity providers and Kubernetes RBAC decide who logs into a cluster. They cannot redact keys inside returned JSON objects or hold a risky delete call for review. By design, hoop.dev sits inline as an open-source proxy, a sidecar for your Kubernetes API, without replacing RBAC. On every production call from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for human approval.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run or hold risky deletes for review. Next, hoop.dev data masking rewrites sensitive keys in returned Secret, ConfigMap, and log responses in memory, and writes each decision to the audit trail. Explore the repo on GitHub.

Frequently asked questions

Should a circleci gke runner use a RoleBinding or a ClusterRoleBinding?

Use a RoleBinding whenever you can so permissions stay inside one single namespace. A ClusterRoleBinding gives the build runner access across the entire cluster, which increases risk.

Can Kubernetes RBAC block a single dangerous command inside a pod exec session?

No, Kubernetes RBAC is additive only and has no deny rules for specific shell commands. Once a role grants access to the exec subresource, any command can run in that pod.

Can a RoleBinding use a ClusterRole for a single namespace?

Yes, a RoleBinding can reference a ClusterRole and apply those rules to one specific namespace. This lets teams reuse one standard deploy template across many app namespaces safely.

The query runs. The emails stay hidden.