الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

flux

The CLI of Flux CD, a GitOps tool made of Kubernetes controllers that pull from Git and apply the changes.

المستوى
خدمة DevSecOps
المجموعة
Git و CI/CD
يحتاج root
لا
الحزمة
flux

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

Flux installs controllers into the cluster: the source-controller pulls Git repos, Helm repos and OCI artifacts; the kustomize-controller applies folders; the helm-controller installs charts; the image automation controllers can write new image tags back to Git. Everything is a Kubernetes object (GitRepository, Kustomization, HelmRelease). Flux has no own UI — you use flux and kubectl.

flux bootstrap installs Flux and commits its own config to your Git repo, so Flux manages itself.

طريقة الكتابة

flux bootstrap github --owner USER --repository REPO --path clusters/NAME
flux get|reconcile|suspend|resume KIND NAME

الأجزاء الرئيسية

Commands

check [--pre]
Check the cluster and Flux.
bootstrap github|gitlab|git
Install Flux and connect it to a repo.
create source git NAME
Create a GitRepository source.
create kustomization NAME
Create a Kustomization (apply a folder).
create helmrelease NAME
Create a HelmRelease.
get all|sources|kustomizations|helmreleases
Show status.
reconcile kustomization|source NAME
Sync now.
suspend / resume KIND NAME
Pause / continue syncing.
logs [--level error]
Controller logs.
diff kustomization NAME --path DIR
Show changes before push.
events
Flux events.
export KIND NAME
Print YAML.
uninstall
Remove Flux.

الخيارات 6

الأكثر استخدامًا

Common flags

--export
Print YAML instead of creating (write it into Git).
-n NS / -A
Namespace / all namespaces.
--interval 1m
How often to check.
--path ./DIR
Folder in the repo.
--prune
Delete removed objects.
--with-source
Reconcile the source first.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Check and bootstrap with GitHub

    flux check --pre
    export GITHUB_TOKEN=github_pat_xxxx
    flux bootstrap github --owner s0sta --repository fleet --branch main --path clusters/home --personal
  2. 2Add an app from another repo (as YAML in Git)

    flux create source git shop --url https://github.com/s0sta/platform --branch main --interval 1m --export > clusters/home/shop-source.yaml
    flux create kustomization shop --source GitRepository/shop --path ./apps/shop/overlays/prod --prune --interval 5m --target-namespace shop --export > clusters/home/shop-kustomization.yaml
    git add clusters/home && git commit -m "Add shop" && git push
  3. 3Watch and force a sync

    flux get kustomizations
    flux reconcile kustomization shop --with-source
    flux get all -A
  4. 4Install a Helm chart with a HelmRelease

    cat clusters/home/podinfo.yaml
    apiVersion: helm.toolkit.fluxcd.io/v2
    kind: HelmRelease
    metadata: { name: podinfo, namespace: podinfo }
    spec:
      interval: 10m
      chart:
        spec:
          chart: podinfo
          version: "6.7.x"
          sourceRef: { kind: HelmRepository, name: podinfo, namespace: flux-system }
      values:
        replicaCount: 2
  5. 5Decrypt SOPS secrets during apply

    cat clusters/home/shop-kustomization.yaml
    spec:
      decryption:
        provider: sops
        secretRef: { name: sops-age }
  6. 6Pause during an incident

    flux suspend kustomization shop
    flux resume kustomization shop
  7. 7Read errors

    flux logs --level error --since 1h
    flux events -n flux-system
  8. 8Preview a change before you push

    flux diff kustomization shop --path ./apps/shop/overlays/prod
  9. 9See which version runs where

    flux get sources git -A
    flux version
  10. 10Export everything for a backup

    flux export source git --all > sources.yaml
    flux export kustomization --all > kustomizations.yaml

انتبه

  • The bootstrap token needs repo rights only once; Flux then uses a deploy key.
  • --prune deletes objects you remove from Git — that is the point, but check the path.

الملفات

clusters/NAME/flux-system/
Flux's own config in your repo.

نصائح للحفظ

  • Flux vs Argo CD: Flux is CLI/controllers only; Argo CD has a strong UI and multi-cluster view. Learn one well.

رموز الخروج

0Success.
1Error.