首页 > 其他分享 >ArgoCD ApplicationSet CRD

ArgoCD ApplicationSet CRD

时间:2023-12-13 17:45:43浏览次数:49  
标签:generator ApplicationSet ArgoCD CD Application controller CRD Argo

ApplicationSet 概述

ApplicationSet controller是一个 Kubernetes controller,添加了对 ApplicationSet CustomResourceDefinition (CRD) 的支持。该controller/CRD 实现了跨大量集群和 monorepos 内管理 Argo CD Application 的自动化和更大的灵活性,此外,它还使多租户 Kubernetes 集群上的自助服务使用成为可能。

ApplicationSet 功能

1. 能够使用单个 Kubernetes 清单通过 Argo CD 部署到多个 Kubernetes 集群
2. 能够使用单个 Kubernetes 清单通过 Argo CD 从一个或多个 Git 存储库部署多个应用程序
3. 改进了对 monorepos 的支持:在 Argo CD 的context中,monorepo 是在单个 Git 存储库中定义的多个 Argo CD Application资源
4. 在多租户集群内,提高单个集群租户使用 Argo CD 部署应用程序的能力(无需特权集群管理员参与启用目标clusters/namespaces)

ApplicationSet controller 工作模式

ApplicationSet controller的唯一职责是创建、更新和删除 Argo CD 命名空间内的Application资源。controller的唯一工作是确保Application资源与定义的声明性 ApplicationSet 资源保持一致。因此,ApplicationSet controller:
1. 不创建/修改/删除 Kubernetes 资源(Application CR 除外)
2. 不会连接到部署了Argo CD 的集群以外的集群
3. 除了argocd名称空间外,不与其他命称空间交互
Argo CD 本身负责生成子Application资源的实际部署,例如 Deployments、Services 和 ConfigMaps。
ApplicationSet控制器可被视作Application CRD资源的工厂,它将ApplicationSet资源作为输入,而输出的是一个或多个Application资源配置

 

在此图中ApplicationSet定义了一个资源,ApplicationSet controller负责创建相应的Application资源。然后生成的Application资源由 Argo CD 管理:也就是说,Argo CD 负责实际部署资源。
Argo CD 根据Application spec字段中定义的 Git 存储库的内容生成Application的 Kubernetes 资源, e.g. Deployments, Service和其他资源。
Applications的创建、更新或删除将对 Argo CD 命名空间中存在的Application产生直接影响。同样,cluster events(使用Cluster generator时添加/删除 Argo CD cluster secrets)或 Git 中的更改(使用 Git generator时)将在构建Application资源时用作 ApplicationSet controller的输入。
Argo CD 和 ApplicationSet controller协同工作,确保存在一组一致的Application资源,并跨目标集群部署。

ApplicationSet generators 

1. List generator
2. Cluster generator
3. Git generator
4. Matrix generator
5. Merge generator
6. SCM Provider generator
7. Pull Request generator
8. Cluster Decision Resource generator
9. Plugin generator

ApplicationSet CRD

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: guestbook
  namespace: argocd
spec:
  # See docs for available generators and their specs.
  generators:                 # 定义负责生成参数的生成器,这些参数会被用于渲染template字段中定义的模板
  - list:
      elements:
      - cluster: engineering-dev
        url: https://1.2.3.4
      - cluster: engineering-prod
        url: https://2.4.6.8
      - cluster: finance-preprod
        url: https://9.8.7.6
  # Determines whether go templating will be used in the `template` field below.
  goTemplate: false
  # Optional list of go templating options, see https://pkg.go.dev/text/template#Template.Option
  # This is only relevant if `goTemplate` is true
  goTemplateOptions: ["missingkey="]
  # These fields are identical to the Application spec.
  template:                   # Application资源模板,配置格式与Application规范相同,但它含有一些参数化的配置,通过将这些参数替换为generators生成的“值”完成模板的实例化
    metadata:
      name: '{{cluster}}-guestbook'
    spec:
      project: my-project
      source:
        repoURL: https://github.com/infra-team/cluster-deployments.git
        targetRevision: HEAD
        path: guestbook/{{cluster}}
      destination:
        server: '{{url}}'
        namespace: guestbook
  # This sync policy pertains to the ApplicationSet, not to the Applications it creates.
  syncPolicy:                 # 资源同步策略,仅支持内嵌一个布尔型字段preserveResourcesOnDeletion
    # Determines whether the controller will delete Applications when an ApplicationSet is deleted.
    preserveResourcesOnDeletion: false
  # Alpha feature to determine the order in which ApplicationSet applies changes.
  strategy:
  # This field lets you define fields which should be ignored when applying Application resources. This is helpful if you
  # want to use ApplicationSets to create apps, but also want to allow users to modify those apps without having their
  # changes overwritten by the ApplicationSet.
  ignoreApplicationDifferences:
  - jsonPointers:
    - /spec/source/targetRevision
  - name: some-app
    jqPathExpressions:
    - .spec.source.helm.values

参考文档

https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/

标签:generator,ApplicationSet,ArgoCD,CD,Application,controller,CRD,Argo
From: https://www.cnblogs.com/wangguishe/p/17897550.html

相关文章

  • ArgoCD AppProject CRD
    Project概述Projects负责为Application提供逻辑分组,它主要实现如下功能:1.限制可以部署的内容(指定受信任的GitSource仓库)2.限制Application可以部署到的目标位置(指定目标Cluster和Namespace)3.限制能够及不能够部署的对象类型,例如RBAC、CRD、DeamonSets、NetworkPolicy等4......
  • ArgoCD Application CRD
    Application示例apiVersion:argoproj.io/v1alpha1kind:Applicationmetadata:name:guestbook#You'llusuallywanttoaddyourresourcestotheargocdnamespace.namespace:argocd#AddthisfinalizerONLYifyouwantthesetocascadedelete.......
  • ArgoCD 同步配置
    自动同步策略当ArgoCD检测到Git中所需的清单与集群中的实时状态之间的差异时,它能够自动同步应用程序。自动同步的好处是CI/CD管道不再需要直接访问ArgoCDAPI服务器来执行部署。相反,管道会提交并推送到Git存储库,并对跟踪Git存储库中的清单进行更改。PruneResour......
  • Tekton Trigger CRD
    Trigger概述Trigger指定事件监听器检测到事件时发生的情况。主要由TriggerTemplate、TriggerBinding和Interceptor组成。TriggerTemplate定义在spec.template字段上,支持引用和内联两种定义方式。TriggerBinding定义在spec.bindings字段上,支持引用和内联两种定义方式。Cluster......
  • Argocd使用说明
    一,背景概述1.0,背景知识docker虚拟化技术Kubernetes容器编排技术1.1,历史操作​ 以自身的使用经历来说明,之前在一个服务器上部署java程序的流程如下本地java-maven打包成为成果物将java程序的成果物上传到服务器上使用命令kill具体服务的进程使用命令启动java服务​ ......
  • K8S HPA在CRD Operator中的应用
    K8SHPA在TrinoOperator中的应用HPA(HorizontalPodAutoscaler)水平扩缩意味着对增加的负载的响应是部署更多的Pod。这与“垂直(Vertical)”扩缩不同,对于Kubernetes,垂直扩缩意味着将更多资源(例如:内存或CPU)分配给已经为工作负载运行的Pod。https://kubernetes.io/zh-cn/do......
  • Argo CD ApplicationSet
    ArgoCDApplicationSetApplicationSet介绍ApplicationSet控制器是一个Kubernetes控制器,添加了对ApplicationSetCustomResourceDefinition(CRD)的支持。该控制器实现了跨大量集群和monorepos内管理ArgoCD应用程序的自动化和更大的灵活性,此外,它还使多租户Kubernete......
  • argocd + kustomize 报错“rpc error: code = Unknown desc = Manifest generation er
    argocd+kustomize报错“rpcerror:code=Unknowndesc=Manifestgenerationerror(cached)” 报错内容报错内容为:rpcerror:code=Unknowndesc=Manifestgenerationerror(cached):`kustomizebuild.xiaowangTech/4.0/frontend/dingding-pc/manifests/overla......
  • 认识 ArgoCD
    ArgoCD官网:https://argo-cd.readthedocs.io/en/stable/应用程序的定义、配置和环境应该是声明式的,并受版本控制。应用程序部署和生命周期管理应该是自动化的、可审计的,并且易于理解。ArgoCD遵循GitOps模式,使用Git存储库作为定义所需应用程序状态的真实源。Kubernetes清单可......
  • k8s强制删除CRD
    在Kubernetes中,当你删除一个自定义资源对象时,默认情况下其实并不会真正删除。相反,Kubernetes会将该对象的状态更新为“Terminating”,并在其metadata.finalizers字段中添加一些值,以确保相关的清理工作被完成后再真正删除该对象。如果你想要强制删除一个自定义资源对象,你需要......