[root@prod-public-runner-k8s-node01 ~]# argocd cluster add 266043569625004212-c7ded9566e35f4533b4dd76e1abdae02a --kubeconfig server-k8s.kube.config WARNING: This will create a service account `argocd-manager` on the cluster referenced by context `266043569625004212-c7ded9566e35f4533b4dd76e1abdae02a` with full cluster level privileges. Do you want to continue [y/N]? y INFO[0001] ServiceAccount "argocd-manager" already exists in namespace "kube-system" INFO[0001] ClusterRole "argocd-manager-role" updated INFO[0001] ClusterRoleBinding "argocd-manager-role-binding" updated Cluster 'https://182.92.***.***:6443' added
验证
[root@prod-public-runner-k8s-node01 ~]# argocd cluster list SERVER NAME VERSION STATUS MESSAGE PROJECT https://182.92.***.***:6443 266043569625004212-c7ded9566e35f4533b4dd76e1abdae02a Unknown Cluster has no applications and is not being monitored. https://kubernetes.default.svc in-cluster 1.20 Successful
[root@prod-public-runner-k8s-node01 ~]# argocd repo list TYPE NAME REPO INSECURE OCI LFS CREDS STATUS MESSAGE PROJECT git http://git.******.com/op/devops-argocd-test.git falsefalsefalsetrue Successful
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE Service my-app argocd-test-app Synced Healthy service/argocd-test-app created apps Deployment my-app argocd-test-app Synced Progressing deployment.apps/argocd-test-app created
Web UI 此时显示绿色状态
在目标集群查看应用状态
[root@prod-server-k8s0155010node ~]# kubelet -n my-app get all NAME READY STATUS RESTARTS AGE pod/argocd-test-app-86d78cd54c-jpmjx 1/1 Running 0 3m21s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/argocd-test-app NodePort 172.31.0.27 <none> 8080:30573/TCP 3m21s
NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/argocd-test-app 1/1 1 1 3m21s
NAME DESIRED CURRENT READY AGE replicaset.apps/argocd-test-app-86d78cd54c 1 1 1 3m21s
[root@prod-server-k8s0155010node ~]# kubectl -n my-app get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE argocd-test-app NodePort 172.31.0.27 <none> 8080:30573/TCP 8m35s
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE Service my-app argocd-test-app Synced Healthy service/argocd-test-app unchanged apps Deployment my-app argocd-test-app Synced Progressing deployment.apps/argocd-test-app configured
[root@prod-public-runner-k8s-node01 kube-config]# argocd app list NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET argocd/devops-argocd-test https://182.92.***.***:6443 my-app default Synced Healthy <none> <none> http://git.365jiating.com/op/devops-argocd-test.git manifests master
在目标集群查看应用状态
[root@prod-server-k8s0155010node ~]# kubectl -n my-app get all NAME READY STATUS RESTARTS AGE pod/argocd-test-app-68546f4f4b-tt6kq 1/1 Running 0 2m15s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/argocd-test-app NodePort 172.31.0.27 <none> 8080:30573/TCP 20m
NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/argocd-test-app 1/1 1 1 20m
NAME DESIRED CURRENT READY AGE replicaset.apps/argocd-test-app-68546f4f4b 1 1 1 2m15s replicaset.apps/argocd-test-app-86d78cd54c 0 0 0 20m [root@prod-server-k8s0155010node ~]# curl 172.31.0.27:8080 {"data":"这是第二版,Hello JackMa","version":"v2"}
此时应用版本为 “version”:”v2”
自动触发
为应用开启自动同步,开启后检测到状态不一致将会自动同步,无需手动sync
配置自动同步运行:
argocd app set devops-argocd-test --sync-policy automated
[root@prod-server-k8s0155010node ~]# kubectl -n my-app get all NAME READY STATUS RESTARTS AGE pod/argocd-test-app-86d78cd54c-84bf5 1/1 Running 0 13m pod/argocd-test-app-86d78cd54c-ffpr8 1/1 Running 0 13m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/argocd-test-app NodePort 172.31.0.27 <none> 8080:30573/TCP 44m
NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/argocd-test-app 2/2 2 2 44m
NAME DESIRED CURRENT READY AGE replicaset.apps/argocd-test-app-68546f4f4b 0 0 0 26m replicaset.apps/argocd-test-app-86d78cd54c 2 2 2 44m [root@prod-server-k8s0155010node ~]# [root@prod-server-k8s0155010node ~]# curl 172.31.0.27:8080 {"data":"这是第一版,Hello Joker","version":"v1"}