Argo CD App Of Apps
Argo CD App of Apps
什么是 App of Apps
您可以创建一个应用程序来创建其他应用程序,而其他应用程序又可以创建其他应用程序。这允许您以声明方式管理一组可以协同部署和配置的应用程序。这就是 App of Apps
官方文档:https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#app-of-apps
创建 App of Apps
项目仓库:https://gitee.com/evescn/argocd-example-apps/tree/main/app-of-apps
新建 rootapp.yaml
配置文件
## rootapp.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: root-application
namespace: argocd
spec:
project: default
source:
repoURL: https://gitee.com/evescn/argocd-example-apps.git
targetRevision: main
path: ./app-of-apps/apps
# directory
directory:
recurse: false
destination:
server: https://kubernetes.default.svc
namespace: default
# syncPolicy:
# automated: # automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using `retry` field.
# prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ).
# selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ).
# allowEmpty: false # Allows deleting all application resources during automatic syncing ( false by default ).
在代码仓库 https://gitee.com/evescn/argocd-example-apps.git ./app-of-apps/apps
目录下,准备好我们需要创建的 APP
服务,详细如下:
APP1
## app1.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app1
namespace: argocd
spec:
destination:
namespace: directory-guestbook-1
server: https://kubernetes.default.svc
project: default
source:
path: guestbook
repoURL: https://gitee.com/evescn/argocd-example-apps.git
targetRevision: main
directory:
recurse: true
syncPolicy:
syncOptions:
- CreateNamespace=true
APP2
## app2.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app2
namespace: argocd
spec:
destination:
namespace: directory-guestbook-2
server: https://kubernetes.default.svc
project: default
source:
path: guestbook
repoURL: https://gitee.com/evescn/argocd-example-apps.git
targetRevision: main
directory:
recurse: true
syncPolicy:
syncOptions:
- CreateNamespace=true
APP3
## app3.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app3
namespace: argocd
spec:
destination:
namespace: directory-guestbook-3
server: https://kubernetes.default.svc
project: default
source:
path: guestbook
repoURL: https://gitee.com/evescn/argocd-example-apps.git
targetRevision: main
directory:
recurse: true
syncPolicy:
syncOptions:
- CreateNamespace=true
在 Argo CD
中创建 APP
[root@node argocd]# kubectl apply -f rootapp.yaml
application.argoproj.io/root-application created
web UI
界面查看:
点击 Sync
按钮同步,自动新建了 3
个 APP
服务
3
个 APP
服务分别点击 Sync
按钮进行同步
使用 kubectl
查看集群详细信息
## 查看 NameSpace
[root@node argocd]# kubectl get ns
NAME STATUS AGE
argo-rollouts Active 5d23h
argocd Active 12d
default Active 15d
dev Active 6d5h
devops Active 15d
directory-guestbook-1 Active 49s
directory-guestbook-2 Active 46s
directory-guestbook-3 Active 43s
kube-node-lease Active 15d
kube-public Active 15d
kube-system Active 15d
## 查看 directory-guestbook-1 服务信息
[root@node argocd]# kubectl get all -n directory-guestbook-1
NAME READY STATUS RESTARTS AGE
pod/guestbook-ui-56f57db4f-lpckf 1/1 Running 0 63s
pod/guestbook-ui-56f57db4f-r6cbz 1/1 Running 0 63s
pod/guestbook-ui-56f57db4f-wszq7 1/1 Running 0 63s
pod/guestbook-ui-new-54557b8c69-4v569 1/1 Running 0 63s
pod/guestbook-ui-new-54557b8c69-nr7xd 1/1 Running 0 63s
pod/guestbook-ui-new-54557b8c69-vt5h8 1/1 Running 0 63s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/guestbook-ui ClusterIP 10.68.83.65 <none> 80/TCP 63s
service/guestbook-ui-new ClusterIP 10.68.249.216 <none> 80/TCP 63s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/guestbook-ui 3/3 3 3 63s
deployment.apps/guestbook-ui-new 3/3 3 3 63s
NAME DESIRED CURRENT READY AGE
replicaset.apps/guestbook-ui-56f57db4f 3 3 3 63s
replicaset.apps/guestbook-ui-new-54557b8c69 3 3 3 63s
## 查看 directory-guestbook-2 服务信息
[root@node argocd]# kubectl get all -n directory-guestbook-2
NAME READY STATUS RESTARTS AGE
pod/guestbook-ui-56f57db4f-96n2r 1/1 Running 0 64s
pod/guestbook-ui-56f57db4f-f25xk 1/1 Running 0 64s
pod/guestbook-ui-56f57db4f-lmmwn 1/1 Running 0 64s
pod/guestbook-ui-new-54557b8c69-d6q7j 1/1 Running 0 64s
pod/guestbook-ui-new-54557b8c69-gt4wk 1/1 Running 0 64s
pod/guestbook-ui-new-54557b8c69-v2jxf 1/1 Running 0 64s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/guestbook-ui ClusterIP 10.68.242.246 <none> 80/TCP 64s
service/guestbook-ui-new ClusterIP 10.68.135.130 <none> 80/TCP 64s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/guestbook-ui 3/3 3 3 64s
deployment.apps/guestbook-ui-new 3/3 3 3 64s
NAME DESIRED CURRENT READY AGE
replicaset.apps/guestbook-ui-56f57db4f 3 3 3 64s
replicaset.apps/guestbook-ui-new-54557b8c69 3 3 3 64s