Based on Argo CD V2.0.4

Personal blog original address

Use ArgoCD to implement the CD process

In the previous article, I used Tekton to build an image from the source code and push the image to the Huawei Cloud SWR image warehouse. This article uses ArgoCD to build the CD process. We create a directory in the Github repository, demo-go, where the yamL of the application is stored, and the image in the YAML of Deployment is the address of the image we uploaded to the SWR in the last article.

Argo installation CD

Install the Argo CD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Install the Argo CD CLI
Can go to dead simple download and install https://github.com/argoproj/argo-cd/releases/latest #

Expose the Argo CD Dashboard
# Local browser access 'loaclhost:8080' to access the Argo CD dashboard
kubectl port-forward svc/argocd-server -n argocd 8080:443
Copy the code

Login Argo CD

The admin account and password are automatically generated on the Argo CD by default. The password is stored in sercet argocd-initial-admin-secret of the namespace on the Argo CD. You can run the following command to obtain the password:

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
Copy the code

Use the Argo CD Dashboard

Access localhost:8080. Enter the preceding user name and password to log in

Use the Argo CD CLI

argocd login localhost:8080
# Enter the above user name and password to log in
Copy the code

Register the cluster to deploy the application

This command lists all clusters in the current Kubeconfig
[root@LAPTOP-65TL6H1S cicd]# kubectl config get-contexts -o name
docker-desktop
gke_secure-totality-316408_us-central1-c_my-first-cluster-1

# Select the name of a cluster to supply to the Argo CD, such as Docker-destop
argocd cluster add docker-desktop
Copy the code

The preceding command will install an argocd-manager (SA) into the Kube-system namespace and bind the SA to the Admin-level ClusterRole. The Argo CD uses the SA to deploy and monitor applications.

Create an

Use the Argo CD Dashboard

Go to localhost:8080, click NEW APP, and follow the process

Use the Argo CD CLI

ArgoCD can automatically detect github.com/Myrat92/sam… Check whether the files in the demo-go directory in the repository are different from the applications in the cluster. Set sync-policy to auto to automatically update the applications in the cluster if the files are different.

# --sync-policy Specifies the synchronization policy
# -- address of repo code repository
# --path specifies the directory where yamL is stored
# --dest-server specifies the destination cluster address
argocd app create demo-go  --sync-policy auto --repo https://github.com/Myrat92/sample-go --path demo-go --dest-server https://kubernetes.default.svc --dest-namespace default
Copy the code

We can manually update the image of yamL application in the Github repository to see if the cluster application updates synchronously.

Check the status

argocd app get guestbook
Copy the code

Refer to the link

  • Argoproj. Making. IO/Argo – CD/get…