首页 > 其他分享 >ArgoCD + ArgoCD Image Updater 部署实现

ArgoCD + ArgoCD Image Updater 部署实现

时间:2024-10-11 10:50:00浏览次数:1  
标签:argocd Image ArgoCD yaml Updater doc image smart

部署思路踩坑整理

1、ArgoCD和ArgoCD Image Updater是2个不同的程序。"ArgoCD Image Updater小工具"没有集成在ArgoCD中需要单独部署。

2、单独的ArgoCD能够实现基于git仓库变更作为应用部署的事实来源 [参考子页:argocd根据镜像tag变化实现自动发布的2种方式];

ArgoCD +"ArgoCD Image Updater小工具"能够实现以镜像仓库中镜像tag变更作为应用部署的事实来源。

3、"ArgoCD Image Updater小工具"部署略显繁琐,并不只是apply官方提供的yaml让pod运行就可以了,需要打通和argocd的认证操作。

4、ArgoCD 或"ArgoCD Image Updater小工具"按照官方提供的install.yaml 部署后,如果修改其中的cm或者参数,不要采取在原yaml修改后再提交的方式,应该 用命令修改。因为yaml太长太复杂了!

5、其它

5.1、argocd 配置gitlab,http用户名密码方式可以实现认证并回写。

5.2、harbor公开仓库配置的时候不需要用户名和密码,可以使用http请求。

6、配置了回写时,ArgoCD Image Updater 并不会直接修改git仓库yaml 文件的tag,而是会创建一个.开头的yaml 文件(此例为".argocd-source-dev-smart-doc.yaml

"),每次更新都会覆盖此文件的images内容。

   

   

   

ArgoCD + ArgoCD Image Updater 部署步骤:

1、安装ArgoCD

略,在线安装离线安装均可,yaml文件很长。可参考本节其它。

   

登录argocd UI 会强制修改密码。

   

安装 Argo CD CLI

要与 Argo CD API Server 进行交互,我们需要安装 CLI 命令:

# wget https://github.com/argoproj/argo-cd/releases/download/v1.7.10/argocd-linux-amd64

或者用win访问 https://github.com/argoproj/argo-cd/releases 选择合适的版本下载 argocd-linux-amd64 文件

# cp argocd-linux-amd64 /usr/local/bin/argocd

# chmod +x /usr/local/bin/argocd

# argocd version:

   

2、部署"ArgoCD Image Updater小工具"部署略显繁琐

==================== 2.1、在argocd中创建本地用户并为用户创建访问令牌 ======================

# kubectl -n argocd edit cm argocd-cm

data:

accounts.image-updater: apiKey

   

##打开后没有data字段,在最后顶格补入以上字段。注意:apiKey中的K为大写!!!

##修改保存后,再查看格式大概如下,验证多了data字段

=================== 2.1.1 为用户创建访问令牌,保存备用(下面配置API访问令牌秘钥会用到此处生成的令牌)===============

用argocd命令登录认证argocd(地址为argocd-server SVC暴露的端口),需要交互输入y,忽略tls证书。

# argocd login 10.244.10.55:15471 --username admin --password argocd123

WARNING: server certificate had error: tls: failed to verify certificate: x509: cannot validate certificate for 10.244.10.55 because it doesn't contain any IP SANs. Proceed insecurely (y/n)? y

'admin:login' logged in successfully

Context '10.244.10.55:15471' updated

   

执行下面命令的前提是上面已经用argocd命令登录了argocd

# argocd account generate-token --account image-updater --id image-updater

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJpbWFnZS11cGRhdGVyOmFwaUtleSIsIm5iZiI6MTcyODUyNDUyMCwiaWF0IjoxNzI4NTI0NTIwLCJqdGkiOiJpbWFnZS11cGRhdGVyIn0.QecneA-yvcbU7Eoyi8egWwiAxN4zrf9FCWJXPeu0ick

   

=================== 2.2、在Argo CD中授予RBAC权限 =====================

# kubectl -n argocd edit cm argocd-rbac-cm

data:

policy.default: role:readonly

policy.csv: |

p, role:image-updater, applications, get, */*, allow

p, role:image-updater, applications, update, */*, allow

g, image-updater, role:image-updater

   

##打开后没有data字段,在最后顶格补入以上字段。

##修改保存后,再查看验证多了data字段。

================= 2.3、安装Argo CD Image Update =====================

建议在运行 Argo CD 的同一个 Kubernetes 命名空间集群中运行 Argo CD Image Updater,但这不是必需的。事实上,甚至不需要在 Kubernetes 集群中运行 Argo CD Image Updater 或根本不需要访问任何 Kubernetes 集群。但如果不访问 Kubernetes,某些功能可能无法使用,所以强烈建议使用第一种安装方法。

运行镜像更新程序的最直接方法是将其作为 Kubernetes 工作负载安装到运行 Argo CD 的命名空间中。这样就不需要任何配置,也不会对你的工作负载产生任何影响。

# kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj-labs/argocd-image-updater/stable/manifests/install.yaml

或者地址:https://github.com/argoproj-labs/argocd-image-updater/tree/master/manifests

   

================= 2.4、配置镜像仓库(此例为harbor,之前ecr有过实践) ===============

即使您不打算使用私有镜像仓库,您也需要至少配置一个empty registries.conf:

   

# kubectl -n argocd edit cm argocd-image-updater-config

data:

registries.conf: ""

   

##没有此条目argocd-image-updater pod将无法启动。

   

如果使用私有镜像仓库可参考以下配置,以harbor镜像仓库为例:

   

data:

argocd.insecure: "true"

log.level: debug

registries.conf: |

registries:

- name: harbor

api_url: http://reg1.ka.zkj.com

prefix: reg1.ka.zkj.com

ping: yes

insecure: yes

   

##打开后没有data字段,在最后顶格补入以上字段。

##修改保存后,再查看验证多了data字段。

   

================= 2.5、配置API访问令牌秘钥 ============

根据上面生成的令牌设置变量

#YOUR_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJpbWFnZS11cGRhdGVyOmFwaUtleSIsIm5iZiI6MTcyODUyNDUyMCwiaWF0IjoxNzI4NTI0NTIwLCJqdGkiOiJpbWFnZS11cGRhdGVyIn0.QecneA-yvcbU7Eoyi8egWwiAxN4zrf9FCWJXPeu0ick

   

创建并应用于现有资源,特别注意:命令中的命名空间要修改为服务实际部署的NS

# kubectl create secret generic argocd-image-updater-secret \

> --from-literal argocd.token=$YOUR_TOKEN --dry-run -o yaml |

> kubectl -n argocd apply -f -

W1010 09:48:58.532655 3478 helpers.go:703] --dry-run is deprecated and can be replaced with --dry-run=client.

secret/argocd-image-updater-secret configured

   

更改后必须重启服务

# kubectl -n argocd rollout restart deployment argocd-image-updater

deployment.apps/argocd-image-updater restarted

   

   

3、在gitlab仓库中建立编排文件

   

说明:gitlab仓里有4个文件。

回写文件

.argocd-source-dev-smart-doc.yaml 是argocd 回写后的文件,这个是argocd image updater 应用建立后才会生成的!

编排文件:

dp-smart-doc.yaml

svc-smart-doc.yaml

Kustomize工具文件:

kustomization.yaml

   

---------文件内容如下 -------------------

kustomization.yaml

 

namePrefix: kustomize-

apiVersion: kustomize.config.k8s.io/v1beta1

kind: Kustomization

resources:

- dp-smart-doc.yaml

- svc-smart-doc.yaml

------------------------------------

dp-smart-doc.yaml

   

apiVersion: apps/v1

kind: Deployment

metadata:

name: smart-doc

namespace: wa

labels:

group: service

spec:

replicas: 1

selector:

matchLabels:

app: smart-doc

tier: backend

template:

metadata:

annotations: {}

labels:

app: smart-doc

tier: backend

spec:

nodeSelector:

smart: "true"

dnsPolicy: ClusterFirst

containers:

- image: reg1.ka.zkj.com/dev/smart-doc:v1.241008-68-002

imagePullPolicy: IfNotPresent

name: smart-wealth

ports:

- containerPort: 9800

#command: ["sleep","10000"]

env:

- name: TZ

value: Asia/Shanghai

resources:

limits:

cpu: 1000m

memory: 4Gi

requests:

cpu: 1000m

memory: 4Gi

volumeMounts:

- mountPath: /logs/smart-doc

name: smart-doc

terminationGracePeriodSeconds: 60

volumes:

- hostPath:

path: "/home/zkj/wealth/logs/smart-doc"

type: DirectoryOrCreate

name: "smart-doc"

-----------------------------

svc-smart-doc.yaml

 

apiVersion: v1

kind: Service

metadata:

name: smart-doc

namespace: wa

spec:

type: NodePort

ports:

- port: 9800

targetPort: 9800

nodePort: 48528

selector:

app: smart-doc

tier: backend

   

4、登录argocd UI,建立argocd应用。

   

   

   

   

   

   

   

=======================================================

综合参考:

https://cloudpods.csdn.net/657807ccb8e5f01e1e447b15.html KubeSphere对接ArgoCD

https://kubesphere.io/zh/blogs/kubesphere-argocd/ KubeSphere + Argo CD,实现真正的 GitOps!

标签:argocd,Image,ArgoCD,yaml,Updater,doc,image,smart
From: https://www.cnblogs.com/golaris/p/18457953

相关文章

  • WPF Image display webp via BitMapImgae BeginInit UriSource EndInit in MVVM
    privatevoidGenenerateBitMapImageViaUrl(stringurl){BitmapImagebmi=newBitmapImage();bmi.BeginInit();bmi.UriSource=newUri(url,UriKind.RelativeOrAbsolute);bmi.EndInit();if(bmi.CanFreeze){bmi.Freeze();}......
  • FreeImage裁剪输出
    #include<iostream>#include"FreeImage.h"bool   SaveToFile(intm_originW,intm_originH,char*FileName,BYTE*pBuf,intnWidth,intnHeight){         FIBITMAP*bitmap=NULL;   FREE_IMAGE_FORMATfif=FIF_JPEG;   int       flag......
  • GeoKR系列--Geographical Knowledge-Driven Representation Learning for Remote Sens
    一、abstract1.绝大多数遥感图像仍未标注,想要充分利用这些未标注的图像,本文提出了一种基于地理知识驱动的表示学习方法,使得提升遥感图像的网络性能+减少对标注数据的需求。2.本文将全球地表覆盖产品和与每张遥感图像相关的地理位置视为地理知识,为了消除遥感图像与地理知识之......
  • 图床搭建与工作流优化全方位集成教程:EasyImages2.0与七牛云的搭建与配置+通过 PicGo
    1.准备搭建–简单图床——EasyImage2.01.1前言无意中网上冲浪的时候,发现了一个叫做简单图床——EasyImage的图床,很好用,搭建也很简单。特别鸣谢简单图床——EasyImage作者大大。1.2特点支持WebP格式转换支持仅登录后上传支持设置图片质量支持文字/图片水印支持设置......
  • 图像分割(Image segementation)
    图像分割(ImageSegmentation)是指在计算机视觉和图像处理领域中,将一幅图像分割成多个具有不同语义或特征的区域,这些区域通常是连续的像素集合,并且每个区域内包含的像素在某些属性上是相似的。这一过程旨在识别图像中的各个对象或者背景,为后续的图像分析、物体识别与跟踪、三维重建......
  • 图像增强(Image enhancement)
    图像增强(ImageEnhancement)是一种图像处理技术,其主要目的是通过特定算法和方法改善图像的视觉效果或提升图像中目标特征的识别能力。它主要包括以下几个方面:提高图像质量:针对原始图像可能存在的噪声、模糊、低对比度等问题进行处理,以提升整体图像的质量。突出重要信息:通过强调......
  • PHP报错getimagesize(): SSL operation failed with code 1问题解决方案
    这个PHP错误通常发生在尝试通过HTTPS协议获取图像时,由于缺少或过期的CA证书导致SSL连接验证失败。以下是详细的解决方案:解决方案一:更新CA证书下载最新的CA证书访问 curl官方提供的CA证书 页面下载 cacert.pem 文件。上传证书文件将下载的 cacert.......
  • Light Image Resizer v7.0.7 解锁版下载及安装方法(图片大小调整工具)
    LightImageResizer是一款简单又实用的图片大小调整工具,软件通过缩小分辨率或在硬盘驱动器中移动它们来组织您的照片。LightImageResizer是那些将数码照片和图像存储在PC上以及想要调整大小,压缩,转换,创建副本,创建缩略图、导入或组织照片的人的完美工具。具体步骤如下:下载地......
  • WPF ListBox ListBoxItemTemplate display image automatically via System.Timers.Ti
    //xaml<Windowx:Class="WpfApp6.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.micr......
  • WPF image via web url or uri
    Thebasicroadmapistodownloadwebimageatfirst,second convertitintomemeorystream,thirdassignthememorystreamtobitmapimageasStreamSource. //xaml<Windowx:Class="WpfApp2.MainWindow"xmlns="http://schemas.micro......