هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
Step by step
- Pre-check (line 2) — Kubernetes version and access are fine.
- Bootstrap (line 3) — Flux creates (or uses) the repo
fleet, commits its own manifests toclusters/prod/flux-system, installs itself and from now on syncs that path. The token needs repo admin rights only for bootstrap; Flux then uses a deploy key. - Add an app — the app's manifests (or a Kustomize overlay) in
apps/shop/prod/, and a FluxKustomizationthat points to it:
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: shop
namespace: flux-system
spec:
interval: 5m
path: ./apps/shop/prod
prune: true
wait: true
timeout: 3m
sourceRef:
kind: GitRepository
name: flux-system
targetNamespace: shopprune: true deletes objects you remove from Git; wait: true marks it ready only when the workloads are healthy.
- Commit and push — Flux applies it within the interval. Faster:
flux reconcile kustomization shop --with-source. - Watch —
flux get kustomizationsshowsREADY Trueand the applied revision;flux events --for Kustomization/shopandflux logsshow why something fails. - A failed change — Flux keeps the last good state running and shows the error. Fix it with a new commit or
git revert— never withkubectl edit(Flux would undo it at the next reconcile). - Helm charts —
HelmRepository+HelmReleaseobjects; values in Git. - Secrets — never plain in Git: SOPS decryption in the Kustomization, or the External Secrets Operator.
Check that it worked
flux check reports all controllers healthy; flux get kustomizations shows flux-system and shop with READY True and the latest commit; kubectl -n shop get deploy shows the app; a commit that changes the replica count is applied within minutes without anyone running kubectl.
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Bootstrap fails with 403 | Token missing rights or org restrictions. | Token with repo admin for bootstrap; org allows it. |
kustomization path not found | Wrong path in the Kustomization. | Path relative to the repo root, starting with ./. |
| Manual change undone | Flux reconciles Git state. | Change Git, not the cluster. |
READY False with health check timeout | Pods do not become ready. | kubectl describe the pods; fix image/probes; raise timeout. |
| Deleted file but object still there | prune: false. | Enable prune (carefully). |
| Secret decryption failed | SOPS key secret missing. | Create the sops-age secret; decryption block. |
Go further
- Command pages: flux, kubectl, kustomize.
- Next how-tos: Deploy an app with Argo CD from Git, Use Kustomize overlays per environment, Encrypt Kubernetes secrets in Git with SOPS, Promote a release from staging to production.
- Learn it: GitOps — Flux bootstrap, GitOps — Flux Kustomization, GitOps — Push vs pull. Full guide: Flux.
1Why should you not fix a Flux-managed object with kubectl edit?
Flux reapplies the state from Git at the next reconcile, so the manual change is undone; change Git instead.
2What does prune: true do in a Flux Kustomization?
Objects removed from Git are also deleted from the cluster.