Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
Argo CD is implemented as a kubernetes controller which continuously monitors running applications and compares the current, live state against the desired target state (as specified in the Git repo). A deployed application whose live state deviates from the target state is considered OutOfSync
. Argo CD reports & visualizes the differences, while providing facilities to automatically or manually sync the live state back to the desired target state. Any modifications made to the desired target state in the Git repo can be automatically applied and reflected in the specified target environments.
For additional details, see architecture overview.
Let's assume you're familiar with core Git, Docker, Kubernetes, Continuous Delivery, and GitOps concepts. Below are some of the concepts that are specific to Argo CD.
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/core-install.yaml
This will create a new namespace, argocd
, where Argo CD services and application resources will live.
[root@k8s-master argocd]# kubectl apply -n argocd -f install.yaml
customresourcedefinition.apiextensions.k8s.io/applications.argoproj.io created
customresourcedefinition.apiextensions.k8s.io/applicationsets.argoproj.io created
customresourcedefinition.apiextensions.k8s.io/appprojects.argoproj.io created
serviceaccount/argocd-application-controller created
serviceaccount/argocd-applicationset-controller created
serviceaccount/argocd-dex-server created
serviceaccount/argocd-notifications-controller created
serviceaccount/argocd-redis created
serviceaccount/argocd-repo-server created
serviceaccount/argocd-server created
role.rbac.authorization.k8s.io/argocd-application-controller created
role.rbac.authorization.k8s.io/argocd-applicationset-controller created
role.rbac.authorization.k8s.io/argocd-dex-server created
role.rbac.authorization.k8s.io/argocd-notifications-controller created
role.rbac.authorization.k8s.io/argocd-server created
clusterrole.rbac.authorization.k8s.io/argocd-application-controller created
clusterrole.rbac.authorization.k8s.io/argocd-server created
rolebinding.rbac.authorization.k8s.io/argocd-application-controller created
rolebinding.rbac.authorization.k8s.io/argocd-applicationset-controller created
rolebinding.rbac.authorization.k8s.io/argocd-dex-server created
rolebinding.rbac.authorization.k8s.io/argocd-notifications-controller created
rolebinding.rbac.authorization.k8s.io/argocd-redis created
rolebinding.rbac.authorization.k8s.io/argocd-server created
clusterrolebinding.rbac.authorization.k8s.io/argocd-application-controller created
clusterrolebinding.rbac.authorization.k8s.io/argocd-server created
configmap/argocd-cm created
configmap/argocd-cmd-params-cm created
configmap/argocd-gpg-keys-cm created
configmap/argocd-notifications-cm created
configmap/argocd-rbac-cm created
configmap/argocd-ssh-known-hosts-cm created
configmap/argocd-tls-certs-cm created
secret/argocd-notifications-secret created
secret/argocd-secret created
service/argocd-applicationset-controller created
service/argocd-dex-server created
service/argocd-metrics created
service/argocd-notifications-controller-metrics created
service/argocd-redis created
service/argocd-repo-server created
service/argocd-server created
service/argocd-server-metrics created
deployment.apps/argocd-applicationset-controller created
deployment.apps/argocd-dex-server created
deployment.apps/argocd-notifications-controller created
deployment.apps/argocd-redis created
deployment.apps/argocd-repo-server created
deployment.apps/argocd-server created
statefulset.apps/argocd-application-controller created
networkpolicy.networking.k8s.io/argocd-application-controller-network-policy created
networkpolicy.networking.k8s.io/argocd-applicationset-controller-network-policy created
networkpolicy.networking.k8s.io/argocd-dex-server-network-policy created
networkpolicy.networking.k8s.io/argocd-notifications-controller-network-policy created
networkpolicy.networking.k8s.io/argocd-redis-network-policy created
networkpolicy.networking.k8s.io/argocd-repo-server-network-policy created
networkpolicy.networking.k8s.io/argocd-server-network-policy created
[root@k8s-master argocd]#
[root@k8s-master argocd]# kubectl get svc -n argocd
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
argocd-applicationset-controller ClusterIP 10.111.123.225 <none> 7000/TCP,8080/TCP 3m55s
argocd-dex-server ClusterIP 10.103.157.246 <none> 5556/TCP,5557/TCP,5558/TCP 3m54s
argocd-metrics ClusterIP 10.108.23.118 <none> 8082/TCP 3m54s
argocd-notifications-controller-metrics ClusterIP 10.96.248.236 <none> 9001/TCP 3m54s
argocd-redis ClusterIP 10.99.82.214 <none> 6379/TCP 3m54s
argocd-repo-server ClusterIP 10.100.87.16 <none> 8081/TCP,8084/TCP 3m54s
argocd-server ClusterIP 10.106.64.187 <none> 80/TCP,443/TCP 3m54s
argocd-server-metrics ClusterIP 10.109.40.112 <none> 8083/TCP 3m54s
[root@k8s-master argocd]#
[root@k8s-master argocd]# kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
service/argocd-server patched
[root@k8s-master argocd]# kubectl get svc -n argocd
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
argocd-applicationset-controller ClusterIP 10.111.123.225 <none> 7000/TCP,8080/TCP 5m30s
argocd-dex-server ClusterIP 10.103.157.246 <none> 5556/TCP,5557/TCP,5558/TCP 5m29s
argocd-metrics ClusterIP 10.108.23.118 <none> 8082/TCP 5m29s
argocd-notifications-controller-metrics ClusterIP 10.96.248.236 <none> 9001/TCP 5m29s
argocd-redis ClusterIP 10.99.82.214 <none> 6379/TCP 5m29s
argocd-repo-server ClusterIP 10.100.87.16 <none> 8081/TCP,8084/TCP 5m29s
argocd-server NodePort 10.106.64.187 <none> 80:32201/TCP,443:30702/TCP 5m29s
argocd-server-metrics ClusterIP 10.109.40.112 <none> 8083/TCP 5m29s
[root@k8s-master argocd]#
[root@k8s-master argocd]#
[root@k8s-master argocd]#
[root@k8s-master argocd]#
[root@k8s-master argocd]# kubectl get pod,svc -n argocd
NAME READY STATUS RESTARTS AGE
pod/argocd-application-controller-0 1/1 Running 0 56m
pod/argocd-applicationset-controller-67cf8dcc88-8wqk6 1/1 Running 0 56m
pod/argocd-dex-server-859899bdd-bpl6d 1/1 Running 0 56m
pod/argocd-notifications-controller-575bfb9f47-spdph 1/1 Running 0 56m
pod/argocd-redis-74d77964b-62f87 1/1 Running 0 56m
pod/argocd-repo-server-5bfb9fdd99-nj5wn 1/1 Running 0 56m
pod/argocd-server-6db87f5986-8jsmp 1/1 Running 0 56m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/argocd-applicationset-controller ClusterIP 10.111.123.225 <none> 7000/TCP,8080/TCP 56m
service/argocd-dex-server ClusterIP 10.103.157.246 <none> 5556/TCP,5557/TCP,5558/TCP 56m
service/argocd-metrics ClusterIP 10.108.23.118 <none> 8082/TCP 56m
service/argocd-notifications-controller-metrics ClusterIP 10.96.248.236 <none> 9001/TCP 56m
service/argocd-redis ClusterIP 10.99.82.214 <none> 6379/TCP 56m
service/argocd-repo-server ClusterIP 10.100.87.16 <none> 8081/TCP,8084/TCP 56m
service/argocd-server NodePort 10.106.64.187 <none> 80:32201/TCP,443:30702/TCP 56m
service/argocd-server-metrics ClusterIP 10.109.40.112 <none> 8083/TCP 56m
[root@k8s-master argocd]#
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
[root@k8s-master argocd]# kubectl get secret -n argocd argocd-initial-admin-secret -o yaml
apiVersion: v1
data:
password: Z1ZkcTRXbFVQV0taN1VLTw==
kind: Secret
metadata:
creationTimestamp: "2023-05-03T18:44:17Z"
name: argocd-initial-admin-secret
namespace: argocd
resourceVersion: "76395"
uid: f7018d3c-0a78-4a7b-bb7d-27a946d30fce
type: Opaque
[root@k8s-master argocd]#
[root@k8s-master argocd]#
[root@k8s-master argocd]# echo Z1ZkcTRXbFVQV0taN1VLTw== |base64 -d
gVdq4WlUPWKZ7UKO[root@k8s-master argocd]#
Using the username
admin
and the password from above, login to Argo CD's IP or hostname:need login argocd-server
[root@k8s-master argocd]# argocd version
argocd: v2.7.1+5e54351
BuildDate: 2023-05-02T16:54:25Z
GitCommit: 5e543518dbdb5384fa61c938ce3e045b4c5be325
GitTreeState: clean
GoVersion: go1.19.8
Compiler: gc
Platform: linux/amd64
FATA[0000] Argo CD server address unspecified
[root@k8s-master argocd]#
[root@k8s-master argocd]# argocd login argocd-server
FATA[0000] dial tcp: lookup argocd-server on 192.168.2.1:53: no such host
[root@k8s-master argocd]# argocd login 10.106.64.187
WARNING: server certificate had error: x509: cannot validate certificate for 10.106.64.187 because it doesn't contain any IP SANs. Proceed insecurely (y/n)? y
Username: admin
Password:
'admin:login' logged in successfully
Context '10.106.64.187' updated
[root@k8s-master argocd]#
First we need to set the current namespace to argocd running the following command:
kubectl config set-context --current --namespace=argocd
Download the latest Argo CD version from https://github.com/argoproj/argo-cd/releases/latest. More detailed installation instructions can be found via the CLI installation documentation.
argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-server https://kubernetes.default.svc --dest-namespace default
[root@k8s-master argocd]# argocd version
argocd: v2.7.1+5e54351
BuildDate: 2023-05-02T16:54:25Z
GitCommit: 5e543518dbdb5384fa61c938ce3e045b4c5be325
GitTreeState: clean
GoVersion: go1.19.8
Compiler: gc
Platform: linux/amd64
argocd-server: v2.7.1+5e54351.dirty
BuildDate: 2023-05-02T16:35:40Z
GitCommit: 5e543518dbdb5384fa61c938ce3e045b4c5be325
GitTreeState: dirty
GoVersion: go1.19.6
Compiler: gc
Platform: linux/amd64
Kustomize Version: v5.0.1 2023-03-14T01:32:48Z
Helm Version: v3.11.2+g912ebc1
Kubectl Version: v0.24.2
Jsonnet Version: v0.19.1
[root@k8s-master argocd]#
[root@k8s-master argocd]# argocd app get guestbook
Name: argocd/guestbook
Project: default
Server: https://kubernetes.default.svc
Namespace: default
URL: https://10.106.64.187/applications/guestbook
Repo: https://github.com/argoproj/argocd-example-apps.git
Target: HEAD
Path: guestbook
SyncWindow: Sync Allowed
Sync Policy: <none>
Sync Status: Synced to HEAD (53e28ff)
Health Status: Healthy
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
Service default guestbook-ui Synced Healthy service/guestbook-ui created
apps Deployment default guestbook-ui Synced Healthy deployment.apps/guestbook-ui created
[root@k8s-master argocd]#
[root@k8s-master argocd]# argocd app sync guestbook
TIMESTAMP GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
2023-05-04T03:27:20+08:00 Service default guestbook-ui Synced Healthy
2023-05-04T03:27:20+08:00 apps Deployment default guestbook-ui Synced Healthy
2023-05-04T03:27:21+08:00 Service default guestbook-ui Synced Healthy service/guestbook-ui unchanged
2023-05-04T03:27:21+08:00 apps Deployment default guestbook-ui Synced Healthy deployment.apps/guestbook-ui unchanged
Name: argocd/guestbook
Project: default
Server: https://kubernetes.default.svc
Namespace: default
URL: https://10.106.64.187/applications/guestbook
Repo: https://github.com/argoproj/argocd-example-apps.git
Target: HEAD
Path: guestbook
SyncWindow: Sync Allowed
Sync Policy: <none>
Sync Status: Synced to HEAD (53e28ff)
Health Status: Healthy
Operation: Sync
Sync Revision: 53e28ff20cc530b9ada2173fbbd64d48338583ba
Phase: Succeeded
Start: 2023-05-04 03:27:20 +0800 CST
Finished: 2023-05-04 03:27:21 +0800 CST
Duration: 1s
Message: successfully synced (all tasks run)
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
Service default guestbook-ui Synced Healthy service/guestbook-ui unchanged
apps Deployment default guestbook-ui Synced Healthy deployment.apps/guestbook-ui unchanged
[root@k8s-master argocd]#
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。