当前位置:网站首页>Argo CD usage
Argo CD usage
2022-06-21 06:42:00 【youzhouliu】
One 、 What is? argo cd
Argo CD Is used for Kubernetes The declarativeness of GitOps Continuous delivery tools .
Two 、 Why use argo cd
Argo CD The required application state can be automatically deployed in the specified target environment , Application deployment can be done in Git Tracking changes to branches on commit , Label update , Or fixed to a specific version of the list .
3、 ... and 、argo cd Architecture diagram
Argo CD The main responsibilities of CD(Continuous Delivery, Continuous delivery ), Deploy the application to Kubernetes Wait for the environment , and CI(Continuous Integration, Continuous integration ) Mainly to Jenkins,Gitlab CI Wait for tools to complete .
Argo CD The architecture of is as follows :

Four 、Argo CD Use
Argo CD Generally installed in Kubernetes In the cluster .
1、 install Argo CD
Use the following command in argocd Namespace deployment Argo CD:
# Create a namespace
kubectl create namespace argocd
# Deploy argo cd
wget https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl apply -n argocd -f install.yaml
2、 install Argo CD CLI
Argo CD CLI It's for management Argo CD Command line tools for , For specific installation methods of different operating systems, please refer to Argo CD CLI Installation
Mac The system can be used directly brew install Installation , as follows :
brew install argocd3、 Release Argo CD service
By default , Argo CD The service is not exposed to the public , Can pass LoadBalancer perhaps NodePort Type of Service、Ingress、Kubectl Port forwarding and other methods will Argo CD The service is published to Kubernetes Outside the cluster .
Here, use the following command to pass NodePort The way the service is exposed Argo CD To the outside of the cluster :
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
Now the name has been argocd-server Of Service Change to NodePort Type , It can be used outside the cluster through < node IP>:< Randomly generated NodePort port > To visit Argo CD.
Browser input https://< node IP>:port visit Argo CD.
4、 obtain Argo CD password
By default admin The initial password of the account is automatically generated , Will be stored in... In clear text Argo CD The installed namespace is named argocd-initial-admin-secret Of Secret Under the object password Under the field , You can use the following command to get :
kubectl -n argocd get secret \
argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -d
# Return results
kj8bDMiDTnsEfnjg
Enter the password in the browser to log in Argo CD, The login interface is shown in the figure below :

The login interface is shown below :

5、 Get ready Git Warehouse
stay Gitlab Create project on , named argocd-lab, In order to facilitate the experiment, the warehouse is set to public Public Warehouse . Create... In the warehouse quickstart Catalog , Create two... In the directory yaml Resource file , Namely myapp-deployment.yaml and myapp-service.yaml.
gitlab The contents are as follows :

yaml The content of the resource file is as follows :
# myapp-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- image: registry.cn-shanghai.aliyuncs.com/public-namespace/myapp:v1
name: myapp
ports:
- containerPort: 80
# myapp-service.yaml
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
ports:
- port: 80
targetPort: 80
nodePort: 32060
type: NodePort
selector:
app: myapp
6、 establish Argo CD App
First create a namespace devops be used for Argo CD Deploy the application .
kubectl create ns devops
There are three ways to create app, They are as follows :
Mode one : Use UI establish App
- Application Name: Custom application name .
- Project: Use the default created default project .
- SYNC POLICY: Synchronization mode , You can choose automatic or manual , Here we choose manual synchronization .

- Repository URL: Project Git Address .
- Revision: Branch name .
- Path: yaml The relative path where the resource file is located .

Cluster URL: Kubernetes API Server Access address of , because Argo CD And distribute the application Kubernetes The cluster is the same , So you can use http://kubernetes.default.svc To visit . About Kubernetes in DNS Parsing rules can be viewed Pod And Service Of DNS.
Namespace: The namespace of the deployment application .
After creation, as shown in the figure below , At this time OutOfSync The state of :

Since manual synchronization is set , So you need to click the following SYNC To synchronize :

Click in the pop-up box SYNCHRONIZE, Confirm synchronization :

Wait for synchronization to complete .

stay Argo CD Click on the app to view the details , Here's the picture :

Mode two : Use CLI establish APP
argocd app create myapp2 \
--repo http://11.8.36.29/root/argocd-lab.git \
--path quickstart --dest-server \
https://kubernetes.default.svc \
--dest-namespace devops
Use argocd Command to view the created application :
# List applications
* argocd app list
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET
myapp https://kubernetes.default.svc devops default Synced Healthy <none> <none> http://11.8.36.29/root/argocd-lab.git quickstart main
# see myapp application
* argocd app get myapp
Name: myapp
Project: default
Server: https://kubernetes.default.svc
Namespace: devops
URL: https://11.8.36.159:32313/applications/myapp
Repo: http://11.8.36.29/root/argocd-lab.git
Target: main
Path: quickstart
SyncWindow: Sync Allowed
Sync Policy: <none>
Sync Status: Synced to main (82baed1)
Health Status: Healthy
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
Service devops myapp Synced Healthy service/myapp created
apps Deployment devops myapp Synced Healthy deployment.apps/myapp created
Mode three : Use YAML File creation
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: argocd
spec:
destination:
namespace: devops # The namespace of the deployment application
server: https://kubernetes.default.svc # API Server Address
project: default # Project name
source:
path: quickstart # Resource file path
repoURL: http://11.8.36.29/root/argocd-lab.git # Git Warehouse address
targetRevision: main # Branch name
7、 Version update
take myapp The application changes from manual synchronization to automatic synchronization . Click on APP DETAILS -> SYNC POLICY, Click on ENABLE AUTO-SYNC:

edit myapp Resource file , Change the version from v1 Change it to v2, Click on Commit changes, Submit changes :

Wait a moment Argo CD The application will be automatically updated , If you can't wait, you can click Refresh,Argo CD Will go to get the latest resource files immediately . You can see at this time myapp Deployment Will be newly created v2 Version of Replicaset,v2 Version of Replicaset Will create and manage v2 Version of Pod.

8、 Version rollback
Upgrade to v2 After the version , v1 Version of Replicaset Not deleted , But keep it , This is for the convenience of rolling back the application . stay myapp Click... In the application HISTORY AND ROLLBACK View history , You can see that there is 2 A history :

Let's assume that just launched v2 There is a problem with the version , Need to roll back v1 edition , Then you can select v1 edition , And then click Rollback Roll back :

It needs to be disabled during rollback AUTO-SYNC Automatic synchronization , Click on OK Can be confirmed :

After a while, you can see that the rollback has been successful , here Pod yes v1 Version of , And because the online version is not Git The latest version in the warehouse , Therefore, the synchronization state is OutOfSync:

边栏推荐
- Sqlmap工具
- (各种规律数的编程练习)输出范围内的素数,一个整数的分解质因数,两个数的最大公约数和最小公倍数以及水仙花数和完数等等
- C语言实现模拟银行存取款管理系统课程设计(纯C语言版)
- [JDBC from introduction to actual combat] JDBC basic customs clearance tutorial (comprehensive summary part I)
- Regular expression Basics
- 【MySQL】数据库函数通关教程上篇(聚合、数学、字符串、日期、控制流函数)
- 155-Solana存储数组
- delphi10 ftp文件名乱码问题
- 【JDBC从入门到实战】JDBC基础通关教程(全面总结上篇)
- FPGA - 7 Series FPGA selectio -02- introduction to source language
猜你喜欢

Regular expression Basics
![[reproduce ms08-067 via MSF tool intranet]](/img/93/631c9bfcf5184900f65f53d09a5f1c.png)
[reproduce ms08-067 via MSF tool intranet]

Mysql database foundation: sub query

第8期:云原生—— 大学生职场小白该如何学

C语言程序设计——三子棋(学期小作业)

TweenMax不规则几何图形背景带动画js特效
![Markdown mathematical grammar [detailed summary]](/img/c2/7aff61f7e82595a9d22c2d593148f0.png)
Markdown mathematical grammar [detailed summary]

How powerful are spectral graph neural networks

How to access MySQL database through JDBC? Hand to hand login interface (illustration + complete code)

递归建立链式二叉树,完成前中后序遍历以及其他功能(附源码)
随机推荐
The framework and script of cognitive linguistics
MySQL数据库基础:子查询
Docker installing MySQL
Issue 7: roll inside and lie flat. How do you choose
155-Solana存储数组
Direct attack on the Internet layoffs in 2022: flowers on the ground, chicken feathers on the ground
Data visualization practice: data processing
PyG教程(2):图数据
回答问题:你认为AGI应该采用什么思路?
数据可视化实战:数据处理
5254. dynamic planning of selling wood blocks
C语言程序设计——三子棋(学期小作业)
154-Solana分发token
MSF intranet penetration
Niuke-top101-bm25
Aurora8b10b IP usage-01-introduction and port description
[graduation season] a brief talk on the learning experience before sophomore year
Are you sure about this filter?
TweenMax示波器3d动画
【input】输入框事件总结