Bantu tingkatkan halaman ini
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Untuk berkontribusi pada panduan pengguna ini, pilih Edit halaman ini pada GitHub tautan yang terletak di panel kanan setiap halaman.
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan ApplicationSets
ApplicationSets menghasilkan beberapa Aplikasi dari template, memungkinkan Anda untuk menyebarkan aplikasi yang sama di beberapa cluster, lingkungan, atau ruang nama dengan definisi sumber daya tunggal.
Prasyarat
-
Cluster EKS dengan kemampuan Argo CD dibuat
-
Beberapa kluster target terdaftar (lihatDaftarkan kluster target)
-
Akses repositori dikonfigurasi (lihat) Konfigurasikan akses repositori
-
kubectldikonfigurasi untuk berkomunikasi dengan cluster Anda
Bagaimana cara ApplicationSets kerja
ApplicationSets gunakan generator untuk menghasilkan parameter, lalu terapkan parameter tersebut ke template Aplikasi. Setiap set parameter yang dihasilkan menciptakan satu Aplikasi.
Generator umum untuk penerapan EKS:
-
Generator daftar - Secara eksplisit mendefinisikan cluster dan parameter untuk setiap lingkungan
-
Generator cluster - Secara otomatis menyebarkan ke semua cluster terdaftar
-
Generator Git - Hasilkan Aplikasi dari struktur repositori
-
Generator matriks - Gabungkan generator untuk penerapan multi-dimensi
Untuk referensi generator lengkap, lihat ApplicationSet Dokumentasi
Daftar Generator
Terapkan ke beberapa cluster dengan konfigurasi eksplisit:
apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: guestbook-all-clusters namespace: argocd spec: generators: - list: elements: - cluster: arn:aws:eks:us-west-2:111122223333:cluster/dev-cluster environment: dev replicas: "2" - cluster: arn:aws:eks:us-west-2:111122223333:cluster/staging-cluster environment: staging replicas: "3" - cluster: arn:aws:eks:us-west-2:111122223333:cluster/prod-cluster environment: prod replicas: "5" template: metadata: name: 'guestbook-{{environment}}' spec: project: default source: repoURL: https://github.com/example/guestbook targetRevision: HEAD path: 'overlays/{{environment}}' destination: server: '{{cluster}}' namespace: guestbook syncPolicy: automated: prune: true selfHeal: true
catatan
Gunakan kluster EKS ARNs di server bidang saat menargetkan kluster EKS terdaftar. Anda juga dapat menggunakan nama cluster dengan destination.name alih-alihdestination.server.
Ini menciptakan tiga Aplikasi:guestbook-dev,guestbook-staging, danguestbook-prod.
Generator cluster
Terapkan ke semua cluster terdaftar secara otomatis:
apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: cluster-addons namespace: argocd spec: generators: - clusters: {} template: metadata: name: '{{name}}-addons' spec: project: default source: repoURL: https://github.com/example/cluster-addons targetRevision: HEAD path: addons destination: server: '{{server}}' namespace: kube-system syncPolicy: automated: prune: true selfHeal: true
Ini secara otomatis membuat Aplikasi untuk setiap cluster terdaftar.
Cluster filter:
spec: generators: - clusters: selector: matchLabels: environment: production
Generator Git
Generator Git membuat Aplikasi berdasarkan struktur repositori:
-
Generator direktori - Menyebarkan setiap direktori sebagai Aplikasi terpisah (berguna untuk layanan mikro)
-
Generator file - Hasilkan Aplikasi dari file parameter (berguna untuk penyebaran multi-penyewa)
Contoh: Penyebaran Microservices
apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: microservices namespace: argocd spec: generators: - git: repoURL: https://github.com/example/microservices revision: HEAD directories: - path: services/* template: metadata: name: '{{path.basename}}' spec: project: default source: repoURL: https://github.com/example/microservices targetRevision: HEAD path: '{{path}}' destination: server: arn:aws:eks:us-west-2:111122223333:cluster/my-cluster namespace: '{{path.basename}}' syncPolicy: automated: prune: true selfHeal: true syncOptions: - CreateNamespace=true
Untuk detail tentang generator Git dan konfigurasi berbasis file, lihat Git Generator dalam dokumentasi
Generator matriks
Gabungkan beberapa generator untuk digunakan di berbagai dimensi (lingkungan × cluster):
apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: multi-env-multi-cluster namespace: argocd spec: generators: - matrix: generators: - list: elements: - environment: dev - environment: staging - environment: prod - clusters: selector: matchLabels: region: us-west-2 template: metadata: name: 'app-{{environment}}-{{name}}' spec: project: default source: repoURL: https://github.com/example/app targetRevision: HEAD path: 'overlays/{{environment}}' destination: server: '{{server}}' namespace: 'app-{{environment}}'
Untuk detail tentang menggabungkan generator, lihat Matrix Generator
Peluncuran progresif
Terapkan ke lingkungan secara berurutan dengan kebijakan sinkronisasi yang berbeda:
apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: progressive-rollout namespace: argocd spec: generators: - list: elements: - environment: dev autoSync: "true" - environment: staging autoSync: "true" - environment: prod autoSync: "false" template: metadata: name: 'app-{{environment}}' spec: project: default source: repoURL: https://github.com/example/app targetRevision: HEAD path: 'overlays/{{environment}}' destination: server: arn:aws:eks:us-west-2:111122223333:cluster/{{environment}}-cluster namespace: app syncPolicy: automated: prune: true selfHeal: '{{autoSync}}'
Dev dan staging sinkronisasi secara otomatis, sementara produksi memerlukan persetujuan manual.
Penyebaran multi-wilayah
Terapkan ke cluster di beberapa wilayah:
apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: global-app namespace: argocd spec: generators: - list: elements: - cluster: arn:aws:eks:us-west-2:111122223333:cluster/prod-us-west region: us-west-2 - cluster: arn:aws:eks:us-east-1:111122223333:cluster/prod-us-east region: us-east-1 - cluster: arn:aws:eks:eu-west-1:111122223333:cluster/prod-eu-west region: eu-west-1 template: metadata: name: 'app-{{region}}' spec: project: default source: repoURL: https://github.com/example/app targetRevision: HEAD path: kubernetes helm: parameters: - name: region value: '{{region}}' destination: server: '{{cluster}}' namespace: app syncPolicy: automated: prune: true selfHeal: true
Mengelola ApplicationSets
Lihat ApplicationSets dan dihasilkan Aplikasi:
kubectl get applicationsets -n argocd kubectl get applications -n argocd -l argocd.argoproj.io/application-set-name=<applicationset-name>
Perbarui ApplicationSet:
Ubah ApplicationSet spesifikasi dan aplikasikan kembali. Argo CD secara otomatis memperbarui semua Aplikasi yang dihasilkan:
kubectl apply -f applicationset.yaml
Hapus sebuah ApplicationSet:
kubectl delete applicationset <name> -n argocd
Awas
Menghapus ApplicationSet menghapus semua Aplikasi yang dihasilkan. Jika Aplikasi tersebut memilikiprune: true, sumber daya mereka juga akan dihapus dari cluster target.
Sumber daya tambahan
-
Bekerja dengan Proyek CD Argo- Mengatur ApplicationSets dengan Proyek
-
Buat Aplikasi- Memahami konfigurasi Aplikasi
-
ApplicationSet Dokumentasi
- Referensi dan pola generator lengkap -
Referensi Generator
- Spesifikasi generator terperinci