8000 ax install changes Agent Substrate and starts ax-server before it fails on ClusterRole permissions · Issue #806 · google/ax · GitHub
[go: up one dir, main page]

Skip to content

ax install changes Agent Substrate and starts ax-server before it fails on ClusterRole permissions #806

In review

Description

@mayawang

Summary

Running ax install on GKE as an identity that can create namespaced objects but not ClusterRoles (such as a service account with the project Editor role) registers ax-server in the ate-api-server bootstrap owners and rolls the Agent Substrate API server, edits the credential provider policy, and deploys ax-postgres and ax-server. Only after that does it fail on clusterroles.rbac.authorization.k8s.io is forbidden. It exits 1 and leaves ax-server running without its ClusterRole, while ax ctx reports the tunnel as Healthy. The prerequisites in docs/installation.md list port forwarding, ClusterTrustBundles, and PodCertificateRequests, but not cluster-scoped RBAC.

Environment

  • Originally reproduced on AX main at 8e2a187, Agent Substrate v1.0.0, GKE 1.37.2.
  • Rechecked on main at 275d0b69: internal/install/axdeploy/deploy.go still has no permission preflight before GrantSubstrateAccess, and docs/installation.md prerequisites are unchanged.

Steps to reproduce

  1. As an identity without permission to create ClusterRoles, run ax install --context <gke-context> with the image flags.
  2. Run kubectl -n ax-system get deploy,pods and ax ctx.

Expected behavior

A preflight error that names the missing permission, with nothing changed on the cluster.

Actual behavior

==> Registered system:serviceaccount:ax-system:ax-server in ate-api-server --authz-bootstrap-owners; waiting for rollout...
==> Updated k8s-credential-provider-namespace-policy for namespace "ax-system"; restarting k8s-credential-provider...
==> Deploying ax-postgres in namespace "ax-system"...
==> Deploying ax-server (...)...
Error: applying ax-server: ... clusterroles.rbac.authorization.k8s.io is forbidden: User "<service account>" cannot create resource "clusterroles" ...

After that, kubectl showed deployment.apps/ax-server 1/1, and ax ctx showed the tunnel to ax-system/ax-server as Healthy. Run again as a cluster admin, ax install took 11.5 s and exited 0.

Suggested fix

Check the needed permissions before the first change using a preflight with SelfSubjectAccessReview (the API behind kubectl auth can-i), and add creating ClusterRoles and ClusterRoleBindings (on GKE, roles/container.admin) to the prerequisites in docs/installation.md.

Impact

  • Severity: P2. Teams where developers do not hold cluster admin, which is common on shared GKE clusters.
  • Workaround: run ax install as a cluster admin.

Activity

  1. added
    devx
    bug-bash
    on Nov 30, 2026
  2. chilin0525 commented on Dec 1, 2026

    @chilin0525

    @mayawang I reproduced this on Kind at 938dc1e with a ServiceAccount that can't create ClusterRoles. ax install changed Agent Substrate and deployed ax-postgres and ax-server before failing with clusterroles.rbac.authorization.k8s.io is forbidden:

    Error: applying ax-server: /usr/bin/kubectl --context limited apply -f -: exit status 1 (Error from server (Forbidden): error when creating "STDIN": clusterroles.rbac.authorization.k8s.io is forbidden: User "system:serviceaccount:rbac-test:limited" cannot create resource "clusterroles" in API group "rbac.authorization.k8s.io" at the cluster scope
    Error from server (Forbidden): error when creating "STDIN": clusterrolebindings.rbac.authorization.k8s.io is forbidden: User "system:serviceaccount:rbac-test:limited" cannot create resource "clusterrolebindings" in API group "rbac.authorization.k8s.io" at the cluster scope)

    I'd like to work on this. Here is my proposal; I'd like to confirm the scope before implementation.

    Proposal

    1. Add a preflight in a new file, internal/install/axdeploy/preflight.go. It runs before GrantSubstrateAccess, the first change to the cluster, and sends SelfSubjectAccessReview (SSAR) requests through the existing kubectl wrapper.
    2. Check the permissions install needs to make its changes and wait for the rollouts (listed in Question 1).
    3. Report all the missing permissions in one error, and change nothing. Each line gives the verb, the resource and API group, the object name, and the namespace if it has one. Example error message:
      Error: missing Kubernetes permissions for ax install; nothing was changed on the cluster:
        - create clusterroles.rbac.authorization.k8s.io "ax-server"
        - create clusterrolebindings.rbac.authorization.k8s.io "ax-server"
      Run ax install as an identity with these permissions (see the prerequisites in docs/installation.md).
      
    4. Update the prerequisites with creating ClusterRoles and ClusterRoleBindings (on GKE, roles/container.admin).

    Open Questions

    1. Should the preflight check all of these permissions, or only the ClusterRole and ClusterRoleBinding?

      Scope Resources Verbs
      Cluster ClusterRole, ClusterRoleBinding get, plus create if missing or patch if it exists
      Cluster Namespace get and patch, plus create if missing
      AX namespace ServiceAccount, ConfigMap, Service, NetworkPolicy, Deployment, StatefulSet get, plus create if missing or patch if it exists
      AX namespace ax-postgres Secret get, plus create if missing
      AX namespace ax-server Deployment and ax-postgres StatefulSet (rollout) list, watch
      ate-system ate-api-server and atenet-router Deployments get, plus patch, list, and watch if ax-server isn't registered yet
      ate-system k8s-credential-provider-namespace-policy ConfigMap get, plus patch if it exists and needs updating
      ate-system k8s-credential-provider Deployment get, patch, list, and watch, if the ConfigMap needs updating and the Deployment exists

      I suggest checking all of them, because a missing permission on any of them can also leave a partial install.

    2. Should this fix also cover RBAC escalation prevention? SSAR can tell whether the caller may create a ClusterRole, but not whether they may grant the permissions in it. A caller who can create ClusterRoles, but can't grant cluster-wide access to Secrets, would pass the preflight and could still end up with a partial install.

  3. Jefftree commented on Dec 3, 2026

    @Jefftree
    Collaborator

    Check the needed permissions before the first change using a preflight with SelfSubjectAccessReview (the API behind kubectl auth can-i),

    feels a bit overkill and bloats the installation script imo.

    add creating ClusterRoles and ClusterRoleBindings (on GKE, roles/container.admin) to the prerequisites in docs/installation.md.

    this feels like the better angle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bug-bashdevx

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0