דלגו לתוכן

זהויות ו-tokens

טבלת החלטה: איזו זהות לכל actor

Section titled “טבלת החלטה: איזו זהות לכל actor”
actorסוג זהותscoperoleאיפה נשמר
CI promote writer (כותב versions/<ENV>.yaml ל-gitops, קורא את trident-ci)service account token (fallback: PAT)write_repositoryDeveloper על gitops, Reporter על trident-cigroup CI/CD variable TRIDENT_GIT_TOKEN (Mask ON, Protect OFF)
Argo reader, repo אחדdeploy token של אותו reporead_repositoryאין (deploy token לא member)Secret ב-ns argocd, אחד לכל repo
Argo reader, N repos עם credential אחדservice account read-only (Reporter על כל repo)read_repositoryReporter על כל repoאותו credential בשני Secrets (ה-url שונה בכל Secret)
kubelet pull של imagesdeploy token של trident-sourceread_registryאיןdocker-registry Secret בכל namespace של environment
CI registry pushאוטומטי: CI_REGISTRY_USER / CI_REGISTRY_PASSWORD(job token)role של מי שהריץ את ה-pipelineלא נשמר. נוצר לכל job
runnerrunner authentication token glrt-…(לא scope של API)-/etc/gitlab-runner/config.toml (root)
אתה, מה-VM / MacSSH key (ראה ssh)-role שלך ב-project~/.ssh/

מה זמין ב-Free ומה דורש Premium

Section titled “מה זמין ב-Free ומה דורש Premium”
סוגgitlab.com FreePremium / Ultimate
Personal access token (PAT)כןכן
Service account (+ token)כןכן
Deploy token (project / group)כןכן
Project access token / Group access tokenלאכן
Group runnerלפי התיעוד כן (בתרגול הכפתור לא הופיע)כן

Project/group access tokens ו-service accounts: אומת מול התיעוד של GitLab. Group runners: התיעוד הנוכחי מציג אותם בכל ה-tiers (Owner על ה-group), אבל בתרגול הכפתור New group runner לא הופיע, לכן project runner הוא המסלול הבטוח (runners). ה-GitLab של המבחן עשוי להיות שונה (self-managed או tier אחר), לכן הכר את שני המסלולים: ב-Premium אפשר project access token במקום service account. ב-gitlab.com, Owner של ה-group צריך לאמת זהות (identity verification) לפני שיוכל ליצור service account.

דרוש Owner על ה-group (top-level). הכי נקי: bot אחד לכל תפקיד, ולא החשבון האישי שלך.

GitLab UI
Group (top-level) → Settings → Service accounts → Add service account
Name: ci-promote-bot (username is generated, e.g. service_account_…)
→ Create
On the new service account row → Manage access tokens (or the "⋮" menu) → Add new token
Token name: promote
Expiration date: set one (exam period)
Scopes: write_repository
→ Create personal access token → COPY the value now (shown once)
Add it as a member of each repo it needs:
Project → Manage → Members → Invite members
Username: the service account's username Role: Developer (gitops) / Reporter (trident-ci)
→ Invite

מיקום התפריט משתנה בין גרסאות (Settings → Service accounts, או Manage → Service accounts). אם אינך רואה: חפש "Service accounts" בסרגל הצד של ה-group.

איך מוודאים: git ls-remote עם ה-token מצליח על שני ה-repos (ראה למטה). לא לשמור את הערך בהיסטוריה: read -rs לתוך קובץ (ראה bash/snippets).

PAT הוא הזהות שלך עצמך. הכוח שלו הוא ה-role שלך מצומצם ל-scope. פחות נקי כי הוא מייצג אדם.

GitLab UI
Avatar (top-left) → Edit profile → Access tokens → Add new token
Token name: <ENV>-writer Expiration date: set one
Scopes: write_repository (add read_registry only if the same token must pull images)
→ Create personal access token → COPY the value now

ליצור deploy token (קריאה בלבד ל-Argo או ל-kubelet)

Section titled “ליצור deploy token (קריאה בלבד ל-Argo או ל-kubelet)”
GitLab UI
Project → Settings → Repository → Deploy tokens → Expand → Add token
Name: argo-read (or registry-pull)
Expiration date: optional but recommended
Username: leave empty (GitLab generates gitlab+deploy-token-N) TRIDENT: gitlab+deploy-token-1
Scopes:
Argo reads git → read_repository
kubelet pulls images → read_registry
→ Create deploy token → COPY username AND token now (shown once)
  • deploy token שייך ל-project אחד. ל-Argo שקורא 2 repos יש 2 deploy tokens, או service account אחד.
  • אין scope write_repository ל-deploy token (יש write_registry). לכתיבה ל-git צריך service account / PAT.
  • יש גם group deploy token (Group → Settings → Repository → Deploy tokens) שתקף לכל projects ב-group.

project / group access token (Premium בלבד)

Section titled “project / group access token (Premium בלבד)”
GitLab UI
Project → Settings → Access tokens → Add new token
Token name: ci-publisher Role: Developer Scopes: write_repository → Create

אם הכפתור חסר, זה tier Free: עבור ל-service account.

לאמת token לפני שמשתמשים בו

Section titled “לאמת token לפני שמשתמשים בו”
runs on: VM
# git read/write access with a token stored in a file (username "oauth2" works for PAT / service account tokens)
git ls-remote "https://oauth2:$(cat <TOKEN_FILE>)@<GITLAB_HOST>/<GROUP>/<REPO>.git"
# deploy token: use its own username
git ls-remote "https://<USER>:$(cat <TOKEN_FILE>)@<GITLAB_HOST>/<GROUP>/<REPO>.git"

איך מוודאים: רשימת refs. HTTP Basic: Access denied / 403 / not found = ראה permissions (membership או scope). אימות registry: registry.