Skip to content
Tutorials Center
My learning

Topics

Lesson 27 of 37 ยท Security and RBAC

RBAC Policies, Projects and Roles

Control who can do what in Argo CD: policy.csv syntax, built-in roles, group mapping, AppProject roles and limits, plus a runnable policy evaluator model.

Argo CD has its own authorization layer on top of Kubernetes RBAC. It decides what a signed-in person or token may do inside Argo CD: view an app, sync it, delete it, read logs, manage clusters. Two mechanisms work together: RBAC policies (global) and AppProjects (scope of what apps may deploy).

Where policies live

Policies are in the argocd-rbac-cm ConfigMap:

YAML
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-rbac-cm
  namespace: argocd
data:
  policy.default: role:readonly
  scopes: "[groups, email]"
  policy.csv: |
    p, role:developer, applications, get, */*, allow
    p, role:developer, applications, sync, shop/*, allow
    p, role:developer, logs, get, shop/*, allow
    p, role:ops, applications, *, */*, allow
    p, role:ops, clusters, get, *, allow
    g, my-org:shop-devs, role:developer
    g, my-org:platform, role:ops
    g, [email protected], role:admin

Policy syntax

Two line types:

TEXT
p, <subject>, <resource>, <action>, <object>, <effect>
g, <user-or-group>, <role>
  • p defines a permission for a subject (a role, user or group).
  • g assigns a user or SSO group to a role.
  • effect is allow or deny. A matching deny wins over any allow.
Resource Objects look like Typical actions
applications project/app get, create, update, delete, sync, override, action/<group>/<kind>/<action>
applicationsets project/name get, create, update, delete
projects project get, create, update, delete
clusters server or name get, create, update, delete
repositories repo-url get, create, update, delete
logs project/app get
exec project/app create (disabled by default)
accounts account name get, update

* is a wildcard in the action and object fields. Objects use glob matching by default; set policy.matchMode: regex to use regular expressions instead.

The extra action/... form permits custom resource actions, for example restarting a Deployment from the UI: action/apps/Deployment/restart.

Built-in roles and defaults

  • role:admin: everything.
  • role:readonly: read access to everything.
  • policy.default: the role given to every authenticated user who matches no other policy. Setting it to the empty string means nobody gets access by default (the safest choice); setting it to role:readonly lets all signed-in users view everything.

Groups from SSO

g, my-org:shop-devs, role:developer maps a group claim to a role. The claim comes from the identity provider (see SSO and Authentication). scopes tells Argo CD which token claims to read; use [groups] or [groups, email], and whichever claim your provider sends. Group names must match exactly, including organization prefix and case.

AppProject roles

Projects can define their own roles, kept in the project and scoped to it:

YAML
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: shop
  namespace: argocd
spec:
  description: Shop team
  sourceRepos:
    - https://git.example.com/shop/*
  destinations:
    - name: prod-eu-1
      namespace: shop-*
  clusterResourceWhitelist: []
  namespaceResourceBlacklist:
    - group: ""
      kind: ResourceQuota
  roles:
    - name: ci
      description: CI pipeline may sync shop apps
      policies:
        - p, proj:shop:ci, applications, sync, shop/*, allow
      groups:
        - my-org:shop-ci

Project roles can also have JWT tokens (argocd proj role create-token shop ci), which are the usual way to give a CI job a narrow credential. Prefer short expiry with --expires-in.

RBAC versus project limits

Question Answered by
May Alice click Sync on shop/web? RBAC policy
May shop/web deploy to the kube-system namespace? AppProject destinations
May the shop team deploy ClusterRoles? AppProject clusterResourceWhitelist
May an Application pull from an arbitrary repo? AppProject sourceRepos

RBAC protects the Argo CD API. Projects protect the cluster. You need both: an engineer who can create Applications but has no project limits could deploy anything anywhere.

Local accounts

Besides SSO, argocd-cm can define local users:

YAML
data:
  accounts.ci-bot: apiKey
  accounts.alice: login
  admin.enabled: "false"

apiKey accounts have tokens, login accounts have passwords (set with argocd account update-password). Disable the built-in admin account once SSO works, and restrict who holds break-glass access.

Testing policies

You can test without deploying by using the CLI against a policy file:

Terminal
argocd admin settings rbac can alice sync applications shop/web --policy-file policy.csv
argocd admin settings rbac validate --policy-file policy.csv

The first prints Yes or No; the second checks syntax. Put the validation in CI for your GitOps repository.

Stand-in: a policy evaluator

This model implements glob matching, allow and deny, and default policy. It is a teaching aid, not Argo CD's Casbin engine.

Python Stand-in: evaluate an RBAC policy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common mistakes

  • Leaving policy.default: role:admin from a quick test.
  • Group names that differ from the provider's claim by prefix or case.
  • Expecting RBAC to limit which clusters an app deploys to (that is the project).
  • Granting exec broadly; it opens a shell in pods.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In which ConfigMap are Argo CD RBAC policies defined?

    argocd-rbac-cm holds policy.csv, policy.default and scopes.
  2. 2. What does the line g, my-org:devs, role:developer do?

    Lines starting with g assign a user or group to a role.
  3. 3. Two matching rules: one allow, one deny. What is the result?

    An explicit deny overrides allows.
  4. 4. Which mechanism limits the namespaces an Application may deploy into?

    RBAC controls API actions; the project controls repos, destinations and resource kinds.

Summary

  • Policies in argocd-rbac-cm use p (permission) and g (group or user to role) lines; deny beats allow.
  • Set policy.default to something minimal and map SSO groups to roles.
  • AppProjects limit repos, clusters, namespaces and resource kinds, and can hold roles and tokens for CI.
  • Validate policies with argocd admin settings rbac.

Next: SSO and Authentication