זהויות ו-tokens
טבלת החלטה: איזו זהות לכל actor
Section titled “טבלת החלטה: איזו זהות לכל actor”| actor | סוג זהות | scope | role | איפה נשמר |
|---|---|---|---|---|
CI promote writer (כותב versions/<ENV>.yaml ל-gitops, קורא את trident-ci) | service account token (fallback: PAT) | write_repository | Developer על gitops, Reporter על trident-ci | group CI/CD variable TRIDENT_GIT_TOKEN (Mask ON, Protect OFF) |
| Argo reader, repo אחד | deploy token של אותו repo | read_repository | אין (deploy token לא member) | Secret ב-ns argocd, אחד לכל repo |
| Argo reader, N repos עם credential אחד | service account read-only (Reporter על כל repo) | read_repository | Reporter על כל repo | אותו credential בשני Secrets (ה-url שונה בכל Secret) |
| kubelet pull של images | deploy token של trident-source | read_registry | אין | docker-registry Secret בכל namespace של environment |
| CI registry push | אוטומטי: CI_REGISTRY_USER / CI_REGISTRY_PASSWORD | (job token) | role של מי שהריץ את ה-pipeline | לא נשמר. נוצר לכל job |
| runner | runner authentication token glrt-… | (לא scope של API) | - | /etc/gitlab-runner/config.toml (root) |
| אתה, מה-VM / Mac | SSH key (ראה ssh) | - | role שלך ב-project | ~/.ssh/ |
מה זמין ב-Free ומה דורש Premium
Section titled “מה זמין ב-Free ומה דורש Premium”| סוג | gitlab.com Free | Premium / 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.
ליצור service account + token
Section titled “ליצור service account + token”דרוש Owner על ה-group (top-level). הכי נקי: bot אחד לכל תפקיד, ולא החשבון האישי שלך.
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 (fallback)
Section titled “ליצור PAT (fallback)”PAT הוא הזהות שלך עצמך. הכוח שלו הוא ה-role שלך מצומצם ל-scope. פחות נקי כי הוא מייצג אדם.
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)”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 בלבד)”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 לפני שמשתמשים בו”# 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 usernamegit 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.