当前位置: 首页 > news >正文

【GitOps】Argo CD自动同步Push请求

Argo CD自动同步Push请求

文章目录

  • Argo CD自动同步Push请求
    • 资源列表
    • 一、创建Gitlba仓库
      • 1.1、创建仓库
      • 1.2、编写资源清单
    • 二、创建Application
    • 三、设置GitLab的Webhook
      • 3.1、设置Web Hook
      • 3.2、配置Argo CD Secret
      • 3.3、配置Web Hook
      • 3.4、测试webhook
      • 3.5、更改仓库yaml字段

资源列表

操作系统配置主机名IP所需软件
CentOS 7.92C4Gmaster192.168.93.145Docker Ce、kube-apiserver、kube-controller-manager、kube-scheduler、kubelet、Etcd、kube-proxy
CentOS 7.92C4Gnode1192.168.93.146Docker CE、kubectl、kube-proxy、Flnnel
CentOS 7.92C4Gnode2192.168.93.147Docker CE、kubectl、kube-proxy、Flnnel
CentOS 7.92C4Ggitlab192.168.93.102GtiLab

一、创建Gitlba仓库

  • 创建的仓库是用来存放Kubernetes的资源清单

1.1、创建仓库

在这里插入图片描述

1.2、编写资源清单

[root@gitlab ~]# git clone http://192.168.93.102/root/argocd-test.git
[root@gitlab ~]# cd argocd-test/
# 准备所需资源(测试)
[root@gitlab argocd-test]# cat deployment.yaml 
apiVersion: "apps/v1"
kind: Deployment
metadata:name: argocd-deploymentlabels:app: argocd
spec:replicas: 3selector:matchLabels:app: argocdtemplate:metadata:labels:app: argocdspec:containers:- name: nginximage: nginx:latestimagePullPolicy: IfNotPresentports:- containerPort: 80[root@gitlab argocd-test]# cat service.yaml 
apiVersion: "v1"
kind: Service
metadata:name: argocd-nginxlabels:app: argocd
spec:selector:app: argocdtype: NodePortports:- port: 80protocol: TCPtargetPort: 80nodePort: 30007
# 提交代码至仓库中
[root@gitlab argocd-test]# git add .
[root@gitlab argocd-test]# git commit -m "v1"
[root@gitlab argocd-test]# git push -u origin

在这里插入图片描述

二、创建Application

  • 仓库Argo CD资源
    在这里插入图片描述
    在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

三、设置GitLab的Webhook

  • 设置触发Push请求

3.1、设置Web Hook

在这里插入图片描述
在这里插入图片描述

3.2、配置Argo CD Secret

[root@master ~]# kubectl edit secret -n argocd argocd-secret
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
stringData:# gitlab webhook secretwebhook.gitlab.secret: wzh

3.3、配置Web Hook

# 调用的Argo CD是域名所以要在 gitlab 主机做hosts解析
[root@gitlab argocd-test]# cat /etc/hosts | tail -1
192.168.93.146 argocd.devops-engineer.com.cn
  • URL填写Argo CD API接口:https://argocd.devops-engineer.com.cn/api/webhook
  • Secret Token:填写上面加入的数字123
  • Trigger:提交到什么分支会发送push请求(main)
    在这里插入图片描述
    在这里插入图片描述

3.4、测试webhook

在这里插入图片描述
在这里插入图片描述

# 提前监控 Argo CD服务是否有接收push请求(添加上面hook确定之后)
[root@master ~]# kubectl logs -f -n argocd argocd-server-b6b977d99-4kp5r
time="2024-12-22T03:30:44Z" level=info msg="Received push event repo: http://192.168.93.102/root/argocd-test, revision: main, touchedHead: true"
time="2024-12-22T03:30:44Z" level=info msg="Requested app 'argocd-push' refresh"

3.5、更改仓库yaml字段

  • 更改image镜像,然后快速回到Argo CD即可看到效果
    在这里插入图片描述
    在这里插入图片描述

  • 点击其中一个即可
    在这里插入图片描述


文章转载自:

http://wValGhvD.kcfnp.cn
http://92E6Envm.kcfnp.cn
http://zGCXyUWb.kcfnp.cn
http://09Tc31rJ.kcfnp.cn
http://1pP8Cdro.kcfnp.cn
http://SwCqteq8.kcfnp.cn
http://FasMcIJW.kcfnp.cn
http://ExZvzszW.kcfnp.cn
http://tdfNdhlJ.kcfnp.cn
http://Xa6rQH8X.kcfnp.cn
http://eHhGlR4g.kcfnp.cn
http://3QvPvcjm.kcfnp.cn
http://9zka2RrG.kcfnp.cn
http://goRTObyB.kcfnp.cn
http://qgJdKYqm.kcfnp.cn
http://EwloIPYi.kcfnp.cn
http://MtUcpjpH.kcfnp.cn
http://Q4Y2Kina.kcfnp.cn
http://N9JONMBe.kcfnp.cn
http://e3rv0jio.kcfnp.cn
http://tcWrSzvE.kcfnp.cn
http://v3GmBKdo.kcfnp.cn
http://3cuCcIRp.kcfnp.cn
http://8ATN78Ni.kcfnp.cn
http://htxZY30m.kcfnp.cn
http://tLU1nJE5.kcfnp.cn
http://b6ZDEXhE.kcfnp.cn
http://0rDeIUSX.kcfnp.cn
http://bz6VIyeV.kcfnp.cn
http://4l4KbehH.kcfnp.cn
http://www.dtcms.com/a/367040.html

相关文章:

  • 救命!Shell用了100次还不懂底层?爆肝300行代码从0造“壳”,fork/exec/重定向全扒光,Linux系统编程直接开挂!
  • 皮尔逊相关(Pearson)和斯皮尔曼相关(Spearman)显著性检验
  • 学完这节课,别再问我LLM是不是溜溜梅
  • npm/pnpm软链接的优点和使用场景
  • 追觅吸尘器发布双旗舰新品,首创颠覆性技术终结家庭清洁妥协时刻
  • java中实现自定义拦截器
  • 实战复盘:pnpm Monorepo 中的 Nuxt 依赖地狱——Unhead 升级引发的连锁血案
  • 传统装修行业数字化转型:如何通过GEO工具实现300%业绩增长?
  • cursor使用配置
  • Linux内核进程管理子系统有什么第四十二回 —— 进程主结构详解(38)
  • OpenLayers常用控件 -- 章节三:鼠标位置坐标显示控件教程
  • QT6(拖放事件与拖放操作)
  • Java全栈工程师的实战面试:从Vue到Spring Boot的技术旅程
  • 3ds Max流体模拟终极指南:打造逼真液体效果,从瀑布到杯中溢出的饮料!
  • 处理PostgreSQL中的磁盘I/O瓶颈
  • Redission 对比isHeldByCurrentThread()和unlock()
  • 逻辑回归基础
  • 目标检测如何将同时有方形框和旋转框的json/xml标注转为txt格式
  • 拦截器和过滤器(理论+实操)
  • HTML 基本结构
  • 《Html泛型魔法学院:用霍格沃茨风格网页教授集合框架》
  • 【LVGL】从HTML到LVGL:嵌入式UI的设计迁移与落地实践
  • 白平衡分块统计数据为什么需要向下采样?
  • 基于单片机智能扫地机器人/智能小车设计
  • 2025 前端 3D 选型指南:Three.js、Babylon.js、WebGPU 深度对比
  • AI视频画质提升效果实用指南:提升清晰度的完整路径
  • Boost搜索引擎 数据清洗与去标签(1)
  • Deeplizard深度学习课程(七)—— 神经网络实验
  • 深度学习——数据增强
  • 在线测评系统---第n天