首页 > 其他分享 >ArgoCD和Argo Rollouts自动化部署应用

ArgoCD和Argo Rollouts自动化部署应用

时间:2023-12-22 09:56:50浏览次数:24  
标签:git Rollouts ArgoCD 192.168 nginx 174.108 ssh Argo 35022

环境说明

使用Argo Rollouts部署nginx应用:
1. 使用Rollout部署nginx
2. 采用canary部署策略
3. 结合Analysis进行渐进式交付
4. 结合Istio VirtualService进行自动化流量分割和流量迁移
5. 部署清单放在git repo中
使用ArgoCD进行自动化部署:
1. 使用Application监视Git Repository
2. 自动在Repository和Destination之间进行同步

Git Repo 说明

git repo地址:
HTTP: http://192.168.174.108:8080/admin/projects/root/nginx-deployment.git
SSH:  ssh://[email protected]:35022/root/nginx-deployment.git

添加私有Git Repo

Argo CD CLI 添加 known_hosts

# ssh-keyscan -p35022 192.168.174.108 | argocd cert add-ssh --batch
# 192.168.174.108:35022 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.4
Enter SSH known hosts entries, one per line. Press CTRL-D when finished.
# 192.168.174.108:35022 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.4
# 192.168.174.108:35022 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.4
# 192.168.174.108:35022 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.4
# 192.168.174.108:35022 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.4
Successfully created 3 SSH known host entries

Argo CD CLI 添加私有仓库

# argocd repo add ssh://[email protected]:35022/root/nginx-deployment.git --ssh-private-key-path /root/.ssh/id_rsa
Repository 'ssh://[email protected]:35022/root/nginx-deployment.git' added

查看 repo

# argocd repo list
TYPE  NAME  REPO                                                       INSECURE  OCI    LFS    CREDS  STATUS      MESSAGE  PROJECT
git         ssh://[email protected]:35022/root/nginx-deployment.git  false     false  false  false  Successful       

ArgoCD 自动部署应用

application-nginx.yaml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: nginx
  namespace: argocd
  finalizers:                       
    - resources-finalizer.argocd.argoproj.io
  annotations:
    notifications.argoproj.io/subscribe.on-deployed.email: [email protected];[email protected]
spec:
  project: default
  source:
    repoURL: ssh://[email protected]:35022/root/nginx-deployment.git
    targetRevision: HEAD
    path: nginx/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: argo-demo
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
      allowEmpty: false
    syncOptions:
    - Validate=false
    - CreateNamespace=true
    - PrunePropagationPolicy=foreground
    - PruneLast=true
    - ApplyOutOfSyncOnly=true
    retry:
      limit: 5
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 3m
  ignoreDifferences:
  - group: networking.istio.io
    kind: VirtualService
    jsonPointers:
    - /spec/http/0

创建应用

# kubectl apply -f application-nginx.yaml
application.argoproj.io/nginx created

查看应用

访问应用

/ $ while true;do curl nginx.argo-demo.svc.wgs.local -I ; sleep 1;done
HTTP/1.1 200 OK
server: envoy
date: Tue, 19 Dec 2023 07:48:55 GMT
content-type: text/html
content-length: 615
last-modified: Tue, 11 Apr 2023 17:21:57 GMT
etag: "64359735-267"
accept-ranges: bytes
x-envoy-upstream-service-time: 10

更新应用版本

# sed -i 's@nginx:1.24-alpine@nginx:1.25-alpine@g' nginx/prod/Rollout.yaml
# git add .
# git commit -m "update nginx:1.24-alpine to nginx:1.25-alpine"
# git push

查看更新过程

标签:git,Rollouts,ArgoCD,192.168,nginx,174.108,ssh,Argo,35022
From: https://www.cnblogs.com/wangguishe/p/17913857.html

相关文章

  • ArgoCD 添加私有仓库
    HTTPS方式访问私有仓库ArgoCDCLI添加私有仓库#argocdrepoaddhttps://github.com/argoproj/argocd-example-apps--username<username>--password<password>dashboard添加私有仓库SSHPrivateKeyCredentialArgoCDCLI添加known_hosts#ssh-keyscan-p3......
  • Argo CD 基础
    Argoproj概述用于Kubernetes运行工作流程、管理集群和正确执行GitOps的开源工具。Argoproj组成ArgoWorkflows基于Kubernetes平台的原生工作流引擎,支持DAG和step-based工作流。ArgoEventsKubernetes上的基于事件的依赖管理器,用于触发Kubernetes中的Argo工作流和其他操作。A......
  • Argo Rollouts CRD
    ArgoRolloutsCRDapiVersion:argoproj.io/v1alpha1kind:Rolloutmetadata:name:example-rollout-canaryspec:#运行的Pod实例数量,默认为1.#Defaultsto1.replicas:5analysis:#保留成功的数量#Defaultsto5.successfulRunHistoryLimit:1......
  • Argo Rollouts Canary 基础
    ArgoRolloutsCanary概述金丝雀部署是一种部署策略,将一小部分生产流量发布到新版本的应用程序。ArgoRolloutsCanary完整配置apiVersion:argoproj.io/v1alpha1kind:Rolloutmetadata:name:example-rollout-canaryspec:#运行的Pod实例数量,默认为1.#Defaultsto......
  • Argo Rollouts 基础
    ArgoRollouts概述ArgoRollouts是一个Kubernetes控制器和一组CRD,为Kubernetes提供高级部署功能,例如蓝绿、金丝雀、金丝雀分析、experimentation和渐进式交付功能。ArgoRollouts(可选)与IngressController和服务网格集成,利用其流量治理功能在更新期间逐渐将流量转移到新版本......
  • Argo Rollouts TrafficRouting结合Istio进行Canary流量管理基础
    ArgoRolloutsTrafficRouting概述流量治理技术实现如下:1.按百分比进行流量管理(即5%的流量应流向新版本,其余流量流向稳定版本)2.基于标头的路由(即将带有特定标头的请求发送到新版本)3.镜像流量,其中所有流量都被复制并并行发送到新版本(但响应被忽略)TrafficRouting配置api......
  • cargo-make rust 任务执行以及构建工具
    再学习nakago框架的时候发现其使用了cargo-make这个工具,但是很方便,类似make的构建模式包含的特性依赖管理,别名支持,支持workspace简单使用安装cargoinstall--forcecargo-make参考使用创建一个cargo项目 cargonewappdemo......
  • Argo Rollouts Canary结合Istio进行流量迁移实例
    环境说明用argorollouts金丝雀发布策略更新nginx服务。发布过程结合Isito和analysis。创建nsargo-demo#kubectlcreatensargo-demonamespace/argo-democreated启用Istio自动注入功能#kubectllabelnamespaceargo-demoistio-injection=enablednamespace/argo-d......
  • Argo Rollouts AnalysisTemplate CRD
    AnalysisTemplateCRDapiVersion:argoproj.io/v1alpha1kind:AnalysisTemplatemetadata:name:success-ratespec:args:#模板参数,模板内部引用的格式为“{{args.NAME}}”;可在调用该模板时对其赋值;-name:<string>value:<string>valu......
  • Argo Rollouts Canary 基础
    ArgoRolloutsCanary概述金丝雀部署是一种部署策略,将一小部分生产流量发布到新版本的应用程序。ArgoRolloutsCanary完整配置apiVersion:argoproj.io/v1alpha1kind:Rolloutmetadata:name:example-rollout-canaryspec:#运行的Pod实例数量,默认为1.#Defaults......