In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to use Argo CD in K8S to do continuous deployment, the content is very detailed, interested friends can refer to, hope to be helpful to you.
What is ArgoCD?
Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
Argo CD is a declarative GitOps tool based on Kubernetes.
Before we talk about Argo CD, let's take a look at what GitOps is.
What is GitOps?
GitOps is based on Git and uses CI/CD to update applications running in a native cloud environment. It adheres to the core philosophy of DevOps-"build it and deliver it (you built it you ship it)".
The concept is a little empty. I drew a picture and you will understand it.
When the developer pushes the completed code to the git repository, it will trigger the CI to create the image and push the image to the image warehouse. After the CI processing is completed, the application configuration can be modified manually or automatically, and then pushed to the git repository. GitOps will compare the target status and the current state at the same time. If the two are inconsistent, it will trigger CD to deploy the new configuration to the cluster.
Where the target state is the state in Git, and the existing state is the application state in the cluster.
Is it okay without GitOps?
Of course, we can use kubectl, helm and other tools to publish the configuration directly, but there will be a serious security problem, that is, secret sharing.
In order to enable the CI system to deploy applications automatically, we need to share the access keys of the cluster to it, which will bring potential security problems.
ArgoCD
Argo CD follows the GitOps pattern and uses the Git repository to store the configuration of the required applications.
The Kubernetes list can be specified in the following ways:
Kustomize Application helm Chart ksonnet Application jsonnet File any custom configuration management tool configured based on the YAML/json configuration management plug-in
Argo CD is implemented as a kubernetes controller that continuously monitors running applications and compares the current active state with the desired target state (as specified in Git repo). If the activity state of the deployed application deviates from the target state, it is considered OutOfSync. Argo CD reports and visualizes these differences while providing a way to automatically or manually synchronize the active state back to the desired target state. Any changes made to the desired target state in Git repo can be automatically applied and reflected in the specified target environment.
Argo CD is in the following position:
Its advantages are summarized as follows:
Application definition, configuration and environment information are declarative and can be versioned; application deployment and lifecycle management are fully automated, auditable and easy to understand; Argo CD is an independent deployment tool that supports unified deployment and management practices for applications on multiple environments and multiple Kubernetes clusters
Premise: there is an available Kubernetes cluster.
Experimental environment:
Kubernetes:1.17.2argo cd:latest install Argo CD
Installation is simple, but data needs to be persisted in practical use.
I use the official documentation installation command directly here:
Kubectl create namespace argocd
Kubectl apply-n argocd-f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
After successful execution, the following resources will be created under the namespace of argocd.
# kubectl get all-n argocd
NAME READY STATUS RESTARTS AGE
Pod/argocd-application-controller-0 1/1 Running 0 16h
Pod/argocd-dex-server-74d9998fdb-mvpmh 1/1 Running 0 16h
Pod/argocd-redis-59dbdbb8f9-msxrp 1/1 Running 0 16h
Pod/argocd-repo-server-599bdc7cf5-ccv8l 1/1 Running 0 16h
Pod/argocd-server-576b4c7ff4-cnp9d 1/1 Running 0 16h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGE
Service/argocd-dex-server ClusterIP 10.105.217.139 5556/TCP,5557/TCP,5558/TCP 16h
Service/argocd-metrics ClusterIP 10.97.116.36 8082/TCP 16h
Service/argocd-redis ClusterIP 10.105.63.34 6379/TCP 16h
Service/argocd-repo-server ClusterIP 10.111.153.131 8081/TCP,8084/TCP 16h
Service/argocd-server ClusterIP 10.105.229.250 80/TCP,443/TCP 16h
Service/argocd-server-metrics ClusterIP 10.104.8.45 8083/TCP 16h
NAME READY UP-TO-DATE AVAILABLE AGE
Deployment.apps/argocd-dex-server 1/1 1 1 16h
Deployment.apps/argocd-redis 1/1 1 1 16h
Deployment.apps/argocd-repo-server 1/1 1 1 16h
Deployment.apps/argocd-server 1/1 1 1 16h
NAME DESIRED CURRENT READY AGE
Replicaset.apps/argocd-dex-server-74d9998fdb 1 1 1 16h
Replicaset.apps/argocd-redis-59dbdbb8f9 1 1 1 16h
Replicaset.apps/argocd-repo-server-599bdc7cf5 1 1 1 16h
Replicaset.apps/argocd-server-576b4c7ff4 1 1 1 16h
NAME READY AGE
Statefulset.apps/argocd-application-controller 1/1 16h
There are two ways to access Argo server:
Using argocd client tools through web ui
I use web ui to manage directly here.
Change the type type of service to NodePort via kubectl edit-n argocd svc argocd-server. After the modification, use the following command to view the port:
# kubectl get svc-n argocd
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGE
Argocd-dex-server ClusterIP 10.105.217.139 5556/TCP,5557/TCP,5558/TCP 17h
Argocd-metrics ClusterIP 10.97.116.36 8082/TCP 17h
Argocd-redis ClusterIP 10.105.63.34 6379/TCP 17h
Argocd-repo-server ClusterIP 10.111.153.131 8081/TCP,8084/TCP 17h
Argocd-server NodePort 10.105.229.250 80:32109/TCP,443:30149/TCP 17h
Argocd-server-metrics ClusterIP 10.104.8.45 8083/TCP 17h
Then visit the page via http://IP:32109, as follows:
The login account is admin, and the password is obtained by the following command.
Kubectl get pods-n argocd- l app.kubernetes.io/name=argocd-server-o name | cut-dwindling Grease'- f 2
Then go to the following interface.
Create an application
This is just for testing argo, so I don't do the ci part.
I prepared a warehouse on gitlab, and the files in the warehouse are very simple, as follows:
The deployment file under manifests is as follows:
ApiVersion: apps/v1
Kind: Deployment
Metadata:
Labels:
App: devops-argocd-test
Name: devops-argocd-test
Namespace: default
Spec:
MinReadySeconds: 60
ProgressDeadlineSeconds: 600
Replicas: 1
RevisionHistoryLimit: 10
Selector:
MatchLabels:
App: devops-argocd-test
Template:
Metadata:
Labels:
App: devops-argocd-test
Spec:
Containers:
-name: devops-argocd-test
Image: registry.cn-hangzhou.aliyuncs.com/rookieops/argocd-test-app:v1
ImagePullPolicy: Always
Ports:
-containerPort: 8080
Name: tcp-8080
Protocol: TCP
-
ApiVersion: v1
Kind: Service
Metadata:
Labels:
App: devops-argocd-test
Name: devops-argocd-test
Namespace: default
Spec:
Ports:
-name: tcp-8080
Port: 8080
Protocol: TCP
TargetPort: 8080
Selector:
App: devops-argocd-test
SessionAffinity: None
Type: NodePort
Now let's create the application in Argo by following the steps below:
(1) add the warehouse address, Settings → Repositories, and click Connect Repo using HTTPS button:
Fill in the following information.
After passing the verification, the display is as follows:
(2) create an application
After the creation is completed, it is as follows:
Since I am setting up manual SYNC, I need to click the SYNC below to synchronize.
Then you can see that the state becomes normal.
At this point, we can see that the v1 version of the application has been created in the cluster.
# kubectl get pod | grep devops-argocd-test
Devops-argocd-test-7f5fdd9fcf-xbzmp 1/1 Running 0 118s
# kubectl get svc | grep devops-argocd-test
Devops-argocd-test NodePort 10.97.159.140 8080:31980/TCP 2m6s
Access the application at this time, as follows:
Configuration change
Next, I manually change the configuration to change the image in the deploymeny.yaml file under manifests to v2, as follows:
And submit it to the warehouse.
This is when you go to ArgoCD, you can see that the state becomes OutOfSync.
At this time, sync again manually until the state is normal. And then visit the above application.
You can see that the application has been updated and deployed.
We can see the relationship status of the entire application, as follows:
You can also see the deployment history.
You can also roll back through this interface.
On how to use Argo CD in K8S to do continuous deployment is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.