Tag 9: Projects und RBAC
Ziel: notes läuft in einem eigenen Projekt mit festen Grenzen. Eine Entwicklerin und eine Pipeline bekommen genau die Rechte, die sie brauchen. · Dauer: ca. 50 min · Voraussetzung: Tag 8
Briefing
- Bisher läuft alles im Projekt
default. Es erlaubt jede Quelle, jeden Cluster und jeden Namespace. Wer eine Application anlegen darf, darf damit alles. - Ein AppProject zieht Grenzen: Aus welchen Repos
darf eine Application lesen (
sourceRepos), wohin darf sie schreiben (destinations), und welche Objekte ohne Namespace darf sie anlegen (clusterResourceWhitelist)? - Lokale Benutzer stehen in
argocd-cm. Ein neuer Benutzer darf zunächst nichts. - RBAC regelt, wer was darf. Die Regeln stehen als
CSV in
argocd-rbac-cm. Eine Zeilepvergibt ein Recht an eine Rolle, eine Zeileghängt einen Benutzer an eine Rolle. - Projektrollen gehören zu einem Projekt und können Tokens ausstellen, etwa für eine Pipeline.
p, role:notes-entwickler, applications, sync, notes/*, allow
└─ wer ────────────┘ └─ was ─────┘ └─ tun ┘ └─ wo ┘
Projekt/Application
g, alice, role:notes-entwickler
Drill 1: Ein eigenes Projekt
Das Projekt kommt ins Fleet-Repo nach applications,
damit root es verwaltet:
cd ~/argo-lab/argocd-fleet
cat > applications/project-notes.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: notes
namespace: argocd
spec:
description: Team notes
sourceRepos:
- [email protected]:<du>/argocd-fleet.git
destinations:
- server: https://kubernetes.default.svc
namespace: "notes*"
clusterResourceWhitelist:
- group: ""
kind: Namespace
EOF
git add -A
git commit -m "AppProject notes"
git push
argocd app get root --refresh
sleep 15
argocd proj get notesErwartet:
Name: notes
Description: Team notes
Destinations: https://kubernetes.default.svc,notes*
Repositories: [email protected]:<du>/argocd-fleet.git
Source Namespaces: <none>
Scoped Repositories: <none>
Allowed Cluster Resources: /Namespace
Scoped Clusters: <none>
Denied Namespaced Resources: <none>
Signature keys: <none>
Orphaned Resources: disabled
notes*erlaubt alle Namespaces, die mitnotesbeginnen, also auch künftige Umgebungen aus dem ApplicationSet.- Objekte ohne Namespace sind standardmäßig verboten. Nur
Namespaceist erlaubt, weilCreateNamespace=trueihn anlegt. Eine ClusterRole oder eine CRD kann das Team damit nicht anlegen.
Fortschritt speichern? Kostenlos registrieren
Drill 2: Die Grenzen testen
Eine Application im Projekt notes, die nach
kube-system will. Sie ist nur ein Test und kommt deshalb
nicht ins Repo:
mkdir -p ~/argo-lab/tag09
cd ~/argo-lab/tag09
cat > ausreisser.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ausreisser
namespace: argocd
spec:
project: notes
source:
repoURL: [email protected]:<du>/argocd-fleet.git
targetRevision: main
path: apps/notes/overlays/dev
destination:
server: https://kubernetes.default.svc
namespace: kube-system
EOF
kubectl apply -f ausreisser.yaml
sleep 5
argocd app get ausreisser | grep -E "Sync Status|InvalidSpecError"Erwartet:
application.argoproj.io/ausreisser created
Sync Status: Unknown
InvalidSpecError application destination server 'https://kubernetes.default.svc' and namespace 'kube-system' do not match any of the allowed destinations in project 'notes' 2026-11-14 20:18:34 +0000 UTC
Kubernetes nimmt die Application an, denn für die API ist sie gültig.
Argo CD weigert sich aber, sie zu bearbeiten. Ein
argocd app sync hängt hier nur, ohne etwas zu tun.
Ausprobiert:
argocd app sync ausreisserkam nach zwei Minuten nicht zurück. Bei einer Application mitInvalidSpecErrorhilft nur, die Ursache zu beheben.
Jetzt eine fremde Quelle, das Chart aus Tag 5:
kubectl delete -f ausreisser.yaml
cat > fremdes-chart.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: fremdes-chart
namespace: argocd
spec:
project: notes
source:
repoURL: https://stefanprodan.github.io/podinfo
chart: podinfo
targetRevision: 6.17.0
destination:
server: https://kubernetes.default.svc
namespace: notes-podinfo
EOF
kubectl apply -f fremdes-chart.yaml
sleep 5
argocd app get fremdes-chart | grep InvalidSpecError
kubectl delete -f fremdes-chart.yamlErwartet:
application.argoproj.io "ausreisser" deleted from argocd namespace
application.argoproj.io/fremdes-chart created
InvalidSpecError application repo https://stefanprodan.github.io/podinfo is not permitted in project 'notes' 2026-11-14 20:21:05 +0000 UTC
application.argoproj.io "fremdes-chart" deleted from argocd namespace
Das Ziel notes-podinfo wäre erlaubt, die Quelle
nicht.
Fortschritt speichern? Kostenlos registrieren
Drill 3: notes ins Projekt
Die Applications von notes kommen aus dem ApplicationSet. Also änderst du die Vorlage:
cd ~/argo-lab/argocd-fleet
sed -i "s/project: default/project: notes/" applications/notes-appset.yaml
grep -n "project:" applications/notes-appset.yaml
git commit -am "notes-Applications ins Projekt notes"
git push
argocd app get root --refresh
sleep 20
kubectl -n argocd get app -o custom-columns=NAME:.metadata.name,PROJECT:.spec.projectErwartet (gekürzt):
21: project: notes
NAME PROJECT
argocd-extras default
notes notes
notes-dev notes
root default
argocd app get notes | grep -E "Project|Sync Status|Health Status"Erwartet:
Project: notes
Sync Status: Synced to main (53e3193)
Health Status: Healthy
Der Umzug ändert nur die Application, nichts im Namespace
notes. root und argocd-extras
bleiben bewusst in default. Sie verwalten Argo CD selbst
und sind Sache des Plattform-Teams.
Fortschritt speichern? Kostenlos registrieren
Drill 4: Ein lokaler Benutzer
Benutzer stehen in argocd-cm. Diese ConfigMap hat die
Installation angelegt, und sie ist voller Voreinstellungen. Du ergänzt
deshalb nur einen Schlüssel:
kubectl -n argocd patch cm argocd-cm --type merge \
-p '{"data":{"accounts.alice":"login"}}'
argocd account listErwartet:
configmap/argocd-cm patched
NAME ENABLED CAPABILITIES
admin true login
alice true login
login heißt: alice darf sich anmelden. Ein Passwort
setzt der Admin. Als --current-password fragt Argo CD sein
eigenes Passwort ab, nicht das von alice:
argocd account update-password --account alice \
--current-password lab-argo-pw-123 --new-password lab-alice-pw-123Erwartet:
Password updated
alice meldet sich in einem eigenen Kontext an. So bleibt deine Admin-Anmeldung erhalten:
argocd login 172.16.0.182:30443 --username alice --password lab-alice-pw-123 \
--insecure --name alice
argocd contextErwartet:
'alice:login' logged in successfully
Context 'alice' updated
CURRENT NAME SERVER
172.16.0.182:30443 172.16.0.182:30443
* alice 172.16.0.182:30443
Was sieht alice?
argocd app list
argocd app get notesErwartet:
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET
{"level":"fatal","msg":"rpc error: code = PermissionDenied desc = permission denied","time":"…"}
Nichts. argocd-rbac-cm ist leer, und ohne Regel gilt:
verboten. Zurück zum Admin:
argocd context 172.16.0.182:30443Erwartet:
Switched to context '172.16.0.182:30443'
Fortschritt speichern? Kostenlos registrieren
Drill 5: Eine Rolle für alice
Rechte gehören ins Git. argocd-rbac-cm ist bei der
Installation leer geblieben. Du legst sie deshalb als ganze Datei nach
platform/argocd, das argocd-extras aus Tag 7
verwaltet:
cd ~/argo-lab/argocd-fleet
cat > platform/argocd/argocd-rbac-cm.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-rbac-cm
namespace: argocd
labels:
app.kubernetes.io/name: argocd-rbac-cm
app.kubernetes.io/part-of: argocd
data:
policy.csv: |
p, role:notes-entwickler, applications, get, notes/*, allow
p, role:notes-entwickler, applications, sync, notes/*, allow
g, alice, role:notes-entwickler
EOF
git add -A
git commit -m "RBAC: Rolle notes-entwickler"
git push
argocd app get argocd-extras --refresh
sleep 10
argocd app get argocd-extras | sed -n "/GROUP/,\$p"Erwartet:
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
ConfigMap argocd argocd-rbac-cm Synced configmap/argocd-rbac-cm configured
Service argocd argocd-server-nodeport Synced Healthy service/argocd-server-nodeport unchanged
notes/*heißt: alle Applications im Projektnotes.- Der Server liest die Regeln sofort neu. alice muss sich nicht neu anmelden.
argocd context alice
argocd app list -o name
argocd account can-i sync applications "notes/*"
argocd account can-i delete applications "notes/*"
argocd account can-i get applications "default/*"Erwartet:
Switched to context 'alice'
argocd/notes
argocd/notes-dev
yes
no
no
alice sieht nur die beiden Applications aus ihrem Projekt.
root und argocd-extras existieren für sie
nicht. Ein Sync klappt, ein Löschen nicht:
argocd app sync notes-dev | grep -E "^Phase|^Message"
argocd app delete notes-dev -yErwartet:
Phase: Succeeded
Message: successfully synced (no more tasks)
{"level":"fatal","msg":"rpc error: code = PermissionDenied desc = permission denied: applications, delete, notes/notes-dev, sub: alice, iat: …","time":"…"}
argocd context 172.16.0.182:30443Fortschritt speichern? Kostenlos registrieren
Drill 6: Ein Token für die Pipeline
Eine Pipeline soll nach dem Bauen synchronisieren dürfen, ohne
Benutzer und Passwort. Dafür bekommt das Projekt eine Rolle
ci. Du hängst sie an die Projektdatei an:
cat >> applications/project-notes.yaml <<'EOF'
roles:
- name: ci
description: Pipeline darf synchronisieren
policies:
- p, proj:notes:ci, applications, get, notes/*, allow
- p, proj:notes:ci, applications, sync, notes/*, allow
EOF
git commit -am "Projektrolle ci"
git push
argocd app get root --refresh
sleep 15
argocd proj role list notesErwartet (gekürzt):
ROLE-NAME DESCRIPTION
ci Pipeline darf synchronisieren
Der Name einer Projektrolle ist immer
proj:<projekt>:<rolle>. Ihre Regeln dürfen nur
Applications des eigenen Projekts betreffen. Jetzt stellst du ein Token
aus, das eine Stunde gilt. Es landet in einer Variablen und nicht auf
dem Bildschirm:
CI_TOKEN=$(argocd proj role create-token notes ci --expires-in 1h --token-only)
argocd proj role get notes ciErwartet (gekürzt):
Role Name: ci
Description: Pipeline darf synchronisieren
Policies:
p, proj:notes:ci, projects, get, notes, allow
p, proj:notes:ci, applications, get, notes/*, allow
p, proj:notes:ci, applications, sync, notes/*, allow
…
JWT Tokens:
ID ISSUED-AT EXPIRES-AT
1794687819 2026-11-14T20:23:39Z (1 second ago) 2026-11-14T21:23:39Z (59 minutes from now)
Die erste Regel ergänzt Argo CD selbst: Wer zu einem Projekt gehört,
darf es sehen. Die Pipeline übergibt das Token mit
--auth-token:
argocd app list -o name --auth-token "$CI_TOKEN"
argocd app sync notes-dev --auth-token "$CI_TOKEN" | grep "^Phase"
argocd app delete notes-dev -y --auth-token "$CI_TOKEN"Erwartet:
argocd/notes
argocd/notes-dev
Phase: Succeeded
{"level":"fatal","msg":"rpc error: code = PermissionDenied desc = permission denied: applications, delete, notes/notes-dev, sub: proj:notes:ci, iat: …","time":"…"}
Wird das Token einmal bekannt, löschst du es mit
argocd proj role delete-token notes ci <ID>. Es ist
dann sofort ungültig.
Ausprobiert: Das Token steht als
jwtTokensin der Rolle im Cluster, aber nicht in Git.rootbleibt trotzdemSynced, denn wie in Tag 3 zählen nur Felder, die in Git stehen.
Fortschritt speichern? Kostenlos registrieren
Kontrollpunkt
argocd proj get notes | grep -E "^Destinations|^Repositories"Erwartet: https://kubernetes.default.svc,notes* und dein
Fleet-Repo.
kubectl -n argocd get app notes notes-dev -o custom-columns=NAME:.metadata.name,\
PROJECT:.spec.projectErwartet: beide im Projekt notes.
argocd account listErwartet: admin und alice, beide
true und login.
argocd contextErwartet: Der Stern steht vor 172.16.0.182:30443, nicht
vor alice.
Challenge
alice soll notes-dev weiter synchronisieren dürfen, die
Produktion notes aber nur noch ansehen.
Hinweis: Der letzte Teil einer p-Zeile
kann statt notes/* auch eine einzelne Application
nennen.
Lösung
cd ~/argo-lab/argocd-fleet
sed -i "s#sync, notes/\*#sync, notes/notes-dev#" platform/argocd/argocd-rbac-cm.yaml
tail -4 platform/argocd/argocd-rbac-cm.yaml
git commit -am "alice: Sync nur für notes-dev"
git push
argocd app get argocd-extras --refresh
sleep 15
argocd context alice
argocd account can-i sync applications notes/notes-dev
argocd account can-i sync applications notes/notes
argocd app sync notes
argocd context 172.16.0.182:30443Erwartet (gekürzt):
policy.csv: |
p, role:notes-entwickler, applications, get, notes/*, allow
p, role:notes-entwickler, applications, sync, notes/notes-dev, allow
g, alice, role:notes-entwickler
…
Switched to context 'alice'
yes
no
{"level":"fatal","msg":"rpc error: code = PermissionDenied desc = permission denied: applications, sync, notes/notes, sub: alice, iat: …","time":"…"}
Switched to context '172.16.0.182:30443'
Fortschritt speichern? Kostenlos registrieren
Enterprise-Notiz
- Lokale Benutzer sind für den Anfang. Im Betrieb kommen Menschen über SSO, und Rollen hängen an Gruppen statt an Namen. Wie Dex oder ein OIDC-Anbieter angebunden wird, steht in der Doku unter „User Management“.
policy.default: role:readonlyinargocd-rbac-cmlässt jeden angemeldeten Benutzer alles sehen. Viele Firmen setzen das bewusst, andere nicht.adminsollte nach der Einrichtung abgeschaltet werden:admin.enabled: "false"inargocd-cm. Vorher muss ein anderer Weg mit vollen Rechten funktionieren.- Ein Token einer Projektrolle bekommt immer ein Ablaufdatum. Ein
Token ohne
--expires-ingilt für immer.