EN: Read in English
Dunia K7: Pandu Sendiri
Misi capstone 6: Lepas tangan
Anda akan belajar: biar Argo CD jalankan Kedai Kancil dari repo Git, supaya satu perubahan Git sampai ke kluster tanpa kubectl.
Teks BM belum disemak oleh penutur asli.
Disemak dengan Kubernetes 1.37 pada 31 Okt 2026
Masalahnya
Tukar satu baris dalam Git dan commit. Lihat kluster mengikutnya.
Git (papan pesanan)
apps/deployment.yaml
Tunjuk seluruh fail
apiVersion: apps/v1
kind: Deployment
metadata:
name: kedai-kancil
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: kedai-kancil
template:
metadata:
labels:
app: kedai-kancil
spec:
containers:
- name: web
image: nginx:1.30-alpine
Commit
c7c258eAdd kedai-kancildalam kluster
Kluster · namespace default
Sync: SyncedHealth: Healthy
Deployment kedai-kancil: 2/2 sedia · image 1.30-alpine
syncPolicy:
automated:
selfHeal: trueTunjuk Application Argo CD
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kedai-kancil
namespace: argocd
spec:
project: default
source:
repoURL: "https://github.com/you/kedai-kancil.git"
path: apps
targetRevision: main
destination:
server: "https://kubernetes.default.svc"
namespace: default
syncPolicy:
automated:
selfHeal: true
Misi 6: Lepas tangan. Matlamat anda: satu baris yang diubah dalam Git sampai ke kluster anda. Tiada kubectl untuk perubahan itu. Cuba di sini dulu.
Cuba
Langkah 1: kluster pakai buang dengan Argo CD. Guna manifest rasmi sahaja. Baca papan “anda di sini” sebelum setiap arahan.
Misi sebenar
kind create cluster --name kedaikubectl config current-contextkubectl create namespace argocdkubectl apply -n argocd --server-side --force-conflicts -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlkubectl wait --for=condition=Available deployment --all -n argocd --timeout=300s
0 daripada 5 langkah siap · Tanda anda disimpan.
Tengok
Langkah 2: papan pesanan. Dalam repo kedai-kancil anda, buat apps/kedai-kancil.yaml dengan YAML di bawah. Baris mana yang anda akan tukar dalam langkah 4?
Pilih satu jawapan.
apiVersion: apps/v1
kind: Deployment
metadata:
name: kedai-kancil
spec:
replicas: 2
selector:
matchLabels:
app: kedai-kancil
template:
metadata:
labels:
app: kedai-kancil
spec:
containers:
- name: web
image: nginx:1.30-alpineCuba
Langkah 3: halakan Argo CD ke Git. Simpan YAML di bawah sebagai argocd/application.yaml. Letak nama pengguna anda dalam repoURL.
Misi sebenar
git add apps argocd && git commit -m "Add GitOps app" && git pushkubectl apply -f argocd/application.yamlkubectl get deployment kedai-kancil
0 daripada 3 langkah siap · Tanda anda disimpan.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kedai-kancil
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/YOUR-USERNAME/kedai-kancil.git
path: apps
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
selfHeal: trueTeka
Anda push replicas: 3. Siapa yang ubah kluster?
Pilih satu jawapan.
Cuba
Langkah 4: perubahan satu baris. Tiada kubectl dibenarkan untuknya.
Misi sebenar
git commit -am "Scale kedai-kancil to 3" && git pushkubectl get deployment kedai-kancil
0 daripada 4 langkah siap · Tanda anda disimpan.
Semak
Biar API awam GitHub sahkan papan pesanan anda. Taip nama pengguna anda, kemudian semak.
Semak di GitHub
- Repo Kedai Kancil anda awamBelum disemak
- Ia ada apps/kedai-kancil.yamlBelum disemak
- Ia ada argocd/application.yamlBelum disemak
Semak
API itu tak boleh lihat ke dalam kluster anda. Semak sendiri perkara ini.
Misi sebenar
kubectl get applications -n argocdkubectl scale deployment kedai-kancil --replicas=1kind delete cluster --name kedai
0 daripada 5 langkah siap · Tanda anda disimpan.
Anda berjaya!
Kini anda boleh jalankan Kedai Kancil dengan GitOps, lepas tangan.
Nak tahu lebih (pilihan)
Di mana seluruh cerita medan selera tak tepat. Gerai sebenar tak berpindah, tetapi pod berpindah dan dapat nama baharu. Pengurus sebenar boleh ubah rancangan; controller hanya ikut papan. Papan pesanan pula ialah kod: disemak, berversi dan boleh diundur. Keselamatan: kluster pakai buang sahaja. Guna image Misi 2 hanya jika pakejnya awam.
English
Mission 6: Hands off. Your goal: one line changed in Git reaches your cluster. No kubectl for the change. Try it here first.
Step 1: a throwaway cluster with Argo CD. Use the official manifests only. Read the “you are here” sign before every command.
Step 2: the order board. In your kedai-kancil repo, make apps/kedai-kancil.yaml with the YAML below. Which line will you change in step 4?
apiVersion: apps/v1
kind: Deployment
metadata:
name: kedai-kancil
spec:
replicas: 2
selector:
matchLabels:
app: kedai-kancil
template:
metadata:
labels:
app: kedai-kancil
spec:
containers:
- name: web
image: nginx:1.30-alpine
Step 3: point Argo CD at Git. Save the YAML below as argocd/application.yaml. Put your username in repoURL.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kedai-kancil
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/YOUR-USERNAME/kedai-kancil.git
path: apps
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
selfHeal: true
You push replicas: 3. Who changes the cluster?
Step 4: the one-line change. No kubectl allowed for it.
Let GitHub’s public API confirm your order board. Type your username, then check.
The API can’t see inside your cluster. Check these yourself.
You can now run Kedai Kancil with GitOps, hands off.
Anda dah siapkan ini. Latihan lagi pun bagus!
Dokumentasi rasmi: Argo CD: getting started · Argo CD: declarative setup · Argo CD: automated sync · kind: quick start
Anda dah belajar 25 minit. Rehat sekejap bantu otak anda.
Pecutan selesai! Fokus yang hebat. Regangkan badan seminit?