דלגו לתוכן

התמונה הגדולה

Git הוא הדרך היחידה לשנות את ה-cluster. CI כותב images ו-commits. Argo הוא היחיד שמחיל (applies) משהו על ה-cluster.

מכאן נגזר: אף אחד לא מריץ kubectl apply/helm install על אובייקט מנוהל, CI לא נוגע ב-cluster, ו-kubectl edit מתבטל (selfHeal).

איך מחלקים repos: מי קורא, מי כותב, באיזה קצב משתנה

Section titled “איך מחלקים repos: מי קורא, מי כותב, באיזה קצב משתנה”

השאלה לכל repo: מי קורא אותו, מי כותב אותו, ומה האירוע שגורם לו להשתנות. התשובה נותנת לו token, pipeline ומקום בזרימה.

חלק במערכתמשתנה כל כמה זמןנקרא על ידינכתב על ידילכן repo נפרד
קוד האפליקציה + Dockerfiles + testsכל הזמןCIהמפתחה-registry של ה-images יושב עליו
לוגיקת ה-pipeline + סקריפט promoteלעיתים רחוקותGitLab (include), jobs (clone)הפלטפורמהנבדק בנפרד, משותף למספר repos
charts מאושריםפעם אחת, אחר כך <TAG>Argoנוצר פעם אחתtag לא זז: בלוק בנייה בלתי-משתנה
המצב הרצוי (values, Applications, versions)בכל promotionArgoאתה + CI (רק קבצי versions)זה מה ש-Argo צופה בו

ב-TRIDENT:

Repoתוכןקוראכותב
trident-sourceקוד, Dockerfiles, tests, .gitlab-ci.yml דקGitLab CIהמפתח
trident-cipipelines/source.yml + scripts/promote.shGitLab (include) + jobsהפלטפורמה
trident-templatescharts מיובאים, tag v1.0.0Argoפעם אחת
trident-gitopsvalues לכל env, versions/<ENV>.yaml, Applications, bootstrapArgoאתה + promote.sh
flow: code to Pod
git push (branch dev or main) to trident-source
| .gitlab-ci.yml: include project trident-ci / pipelines/source.yml
v
candidate -> CANDIDATE=<branch>-<date>-<sha> (dotenv artifact, every later job gets $CANDIDATE)
test -> unit tests
build -> docker build, one image per service (context = shared parent dir)
publish -> docker login (job token) -> docker push <IMAGE>:<CANDIDATE>
promote -> clone trident-ci -> promote.sh <ENV> <CANDIDATE>
-> clone trident-gitops -> write versions/<ENV>.yaml -> commit -> push main
v
Argo notices the new commit in trident-gitops
root app -> child Applications (dev / staging / prod / observability)
child = charts @ trident-templates tag + values @ trident-gitops main
render (helm template) -> diff vs cluster -> apply -> selfHeal / prune
v
kubelet pulls the image with Secret (deploy token, read_registry) -> Pod runs

שים לב: ה-image נכנס ל-registry של trident-source; ל-gitops נכנסת רק מחרוזת ה-tag.

dev, staging, prod הם namespaces (<NS>) עם values משלהם. dev ו-main הם branches של repo ה-source. הקישור ביניהם הוא רק כלל ב-pipeline.

אירועמה קורהלאן
push ל-branch devpromote:dev אוטומטיDEV
push ל-mainpromote:staging אוטומטיSTAGING
לחיצה על promote:prod (כפתור ב-pipeline של main)אותו pipeline, אותו $CANDIDATE, בלי build מחדש; נכתב versions/prod.yamlPROD
  • ה-candidate הוא מחרוזת <BRANCH>-YYYYMMDD-<SHA>, מחושבת פעם אחת ב-job candidate ועוברת ב-dotenv ל-jobs הבאים (needs).
  • ה-job הידני מקדם את ה-candidate של ה-pipeline שלו, לא "מה שנמצא עכשיו ב-STAGING".
  • שני שערים: CI שולט במה שנכנס ל-Git (הכפתור הידני); Argo תמיד אוטומטי. אין syncPolicy שונה ל-prod.
  • מצב יציב תקין: DEV = dev-C, STAGING = main-B, PROD = main-A.

איפה זה רץ? (הטבלה הקנונית)

Section titled “איפה זה רץ? (הטבלה הקנונית)”

החולשה הכי חוזרת: לא לדעת איפה פקודה רצה ומי מגדיר לה משתנים.

הקשרמה רץ שםמאיפה מגיעים משתנים ו-credentials
Mac / laptopgit (SSH), עריכת קבצים; אין kubeconfigמפתח SSH ב-~/.ssh, ~/.ssh/config
shell ב-VMkubectl, helm, docker, סקריפטי bootstrap, gitkubeconfig על ה-VM; משתנים רק מ-export באותו shell (ובכל טרמינל חדש); קבצי credentials תחת ~/.local/share/trident/
CI job על ה-runnerdocker build/push, promote.sh, clone של trident-ciמשתני GitLab CI/CD (group/project) + משתנים מוגדרים-מראש (CI_REGISTRY_USER...). לא export שלך
GitLab UIיצירת projects, tokens, variables, runners, הכפתור הידניאתה, מחובר כמשתמש
Argo בתוך ה-clusterhelm template, diff, apply; קורא manifests ו-values בלבד, לא את bootstrap/repo Secrets ב-namespace argocd; ה-$values קיים רק כאן

git push לא מתקן כשל שנובע ממצב ה-cluster (Secret חסר, או Failed אחרי 5 ניסיונות sync): סקריפטי bootstrap/ רצים ידנית ב-VM ו-Argo לא קורא אותם. אחרי התיקון: sync ידני, argocd/operate.