首页 > 其他分享 >ArgoCD Application CRD

ArgoCD Application CRD

时间:2023-12-13 15:48:18浏览次数:37  
标签:name io namespace ArgoCD value Application CRD Helm true

Application 示例

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: guestbook
  # You'll usually want to add your resources to the argocd namespace.
  namespace: argocd
  # Add this finalizer ONLY if you want these to cascade delete.
  finalizers:
    # The default behaviour is foreground cascading deletion
    - resources-finalizer.argocd.argoproj.io
    # Alternatively, you can use background cascading deletion
    # - resources-finalizer.argocd.argoproj.io/background
  # Add labels to your application object.
  labels:
    name: guestbook
spec:
  # The project the application belongs to.
  project: default               # default project由ArgoCD自动部署,它允许用户按需修改,但不能被删除

  # Source of the application manifests
  source:
    repoURL: https://github.com/argoproj/argocd-example-apps.git  # Can point to either a Helm chart repo or a git repo.
    targetRevision: HEAD  # For Helm, this refers to the chart version.
    path: guestbook  # This has no meaning for Helm charts pulled directly from a Helm repo instead of git.

    # helm specific config
    chart: chart-name  # Set this when pulling directly from a Helm repo. DO NOT set for git-hosted Helm charts.
    helm:
      passCredentials: false # If true then adds --pass-credentials to Helm commands to pass credentials to all domains
      # Extra parameters to set (same as setting through values.yaml, but these take precedence)
      parameters:
      - name: "nginx-ingress.controller.service.annotations.external-dns\\.alpha\\.kubernetes\\.io/hostname"
        value: mydomain.example.com
      - name: "ingress.annotations.kubernetes\\.io/tls-acme"
        value: "true"
        forceString: true # ensures that value is treated as a string

      # Use the contents of files as parameters (uses Helm's --set-file)
      fileParameters:
      - name: config
        path: files/config.json

      # Release name override (defaults to application name)
      releaseName: guestbook

      # Helm values files for overriding values in the helm chart
      # The path is relative to the spec.source.path directory defined above
      valueFiles:
      - values-prod.yaml

      # Ignore locally missing valueFiles when installing Helm chart. Defaults to false
      ignoreMissingValueFiles: false

      # Values file as block file. Prefer to use valuesObject if possible (see below)
      values: |
        ingress:
          enabled: true
          path: /
          hosts:
            - mydomain.example.com
          annotations:
            kubernetes.io/ingress.class: nginx
            kubernetes.io/tls-acme: "true"
          labels: {}
          tls:
            - secretName: mydomain-tls
              hosts:
                - mydomain.example.com

      # Values file as block file. This takes precedence over values
      valuesObject:
        ingress:
          enabled: true
          path: /
          hosts:
            - mydomain.example.com
          annotations:
            kubernetes.io/ingress.class: nginx
            kubernetes.io/tls-acme: "true"
          labels: {}
          tls:
            - secretName: mydomain-tls
              hosts:
                - mydomain.example.com

      # Skip custom resource definition installation if chart contains custom resource definitions. Defaults to false
      skipCrds: false

      # Optional Helm version to template with. If omitted it will fall back to look at the 'apiVersion' in Chart.yaml
      # and decide which Helm binary to use automatically. This field can be either 'v2' or 'v3'.
      version: v2

    # kustomize specific config
    kustomize:
      # Optional kustomize version. Note: version must be configured in argocd-cm ConfigMap
      version: v3.5.4
      # Supported kustomize transformers. https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/
      namePrefix: prod-
      nameSuffix: -some-suffix
      commonLabels:
        foo: bar
      commonAnnotations:
        beep: boop-${ARGOCD_APP_REVISION}
      # Toggle which enables/disables env variables substitution in commonAnnotations
      commonAnnotationsEnvsubst: true
      images:
      - gcr.io/heptio-images/ks-guestbook-demo:0.2
      - my-app=gcr.io/my-repo/my-app:0.1
      namespace: custom-namespace
      replicas:
      - name: kustomize-guestbook-ui
        count: 4

    # directory
    directory:                       # 目录类型应用程序从 .yml、.yaml 和 .json 文件加载纯清单文件。目录类型应用程序可以通过 UI、CLI 或声明方式创建。
      recurse: true                  # 目录递归资源检测
      jsonnet:
        # A list of Jsonnet External Variables
        extVars:
        - name: foo
          value: bar
          # You can use "code to determine if the value is either string (false, the default) or Jsonnet code (if code is true).
        - code: true
          name: baz
          value: "true"
        # A list of Jsonnet Top-level Arguments
        tlas:
        - code: false
          name: foo
          value: bar
      # Exclude contains a glob pattern to match paths against that should be explicitly excluded from being used during
      # manifest generation. This takes precedence over the `include` field.
      # To match multiple patterns, wrap the patterns in {} and separate them with commas. For example: '{config.yaml,env-use2/*}'
      exclude: 'config.yaml'      # 排除config.yaml文件
      # Include contains a glob pattern to match paths against that should be explicitly included during manifest
      # generation. If this field is set, only matching manifests will be included.
      # To match multiple patterns, wrap the patterns in {} and separate them with commas. For example: '{*.yml,*.yaml}'
      include: '*.yaml'           # 仅包含yaml文件

    # plugin specific config
    plugin:    # Argo CD 的“原生”配置管理工具是 Helm、Jsonnet 和 Kustomize。要想使用其它管理工具需要使用配置管理插件 (CMP)自定义功能。
      # If the plugin is defined as a sidecar and name is not passed, the plugin will be automatically matched with the
      # Application according to the plugin's discovery rules.
      name: mypluginname
      # environment variables passed to the plugin
      env:
        - name: FOO
          value: bar
      # Plugin parameters are new in v2.5.
      parameters:
        - name: string-param
          string: example-string
        - name: array-param
          array: [item1, item2]
        - name: map-param
          map:
            param-name: param-value
  
  # Sources field specifies the list of sources for the application
  sources:        # Argo CD 能够为单个应用程序指定多个源。可以使用sources字段提供多个来源。当指定源字段时,Argo CD 将忽略源(单数)字段。
    - repoURL: https://github.com/argoproj/argocd-example-apps.git  # Can point to either a Helm chart repo or a git repo.
      targetRevision: HEAD  # For Helm, this refers to the chart version.
      path: guestbook  # This has no meaning for Helm charts pulled directly from a Helm repo instead of git.
      ref: my-repo  # For Helm, acts as a reference to this source for fetching values files from this source. Has no meaning when under `source` field
    - chart: elasticsearch
      repoURL: https://helm.elastic.co
      targetRevision: 8.5.1
    # prometheus chart将使用 git.example.gom/org/value-files.git 中的值。 $values 解析为value-files存储库的根。 $values 变量只能在值文件路径的开头指定。
    - repoURL: 'https://prometheus-community.github.io/helm-charts'
      chart: prometheus
      targetRevision: 15.7.1
      helm:
        valueFiles:
        - $values/charts/prometheus/values.yaml
    - repoURL: 'https://git.example.com/org/value-files.git'
      targetRevision: dev
      ref: values
  # Destination cluster and namespace to deploy the application
  destination:                              # 应用程序要部署到的目标位置
    # cluster API URL
    server: https://kubernetes.default.svc  # 目标Kubernetes集群的API Server访问入口
    # or cluster name
    # name: in-cluster
    # The namespace will only be set for namespace-scoped resources that have not set a value for .metadata.namespace
    namespace: guestbook
    
  # Extra information to show in the Argo CD Application details tab
  info:
    - name: 'Example:'
      value: 'https://example.com'
      
  # Sync policy
  syncPolicy:
    automated: # automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using `retry` field.
      prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ).
      selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ).
      allowEmpty: false # Allows deleting all application resources during automatic syncing ( false by default ).
    syncOptions:     # Sync options which modifies sync behavior
    - Validate=false # disables resource validation (equivalent to 'kubectl apply --validate=false') ( true by default ).
    - CreateNamespace=true # Namespace Auto-Creation ensures that namespace specified as the application destination exists in the destination cluster.
    - PrunePropagationPolicy=foreground # Supported policies are background, foreground and orphan.
    - PruneLast=true # Allow the ability for resource pruning to happen as a final, implicit wave of a sync operation
    - RespectIgnoreDifferences=true # When syncing changes, respect fields ignored by the ignoreDifferences configuration
    managedNamespaceMetadata: # Sets the metadata for the application namespace. Only valid if CreateNamespace=true (see above), otherwise it's a no-op.
      labels: # The labels to set on the application namespace
        any: label
        you: like
      annotations: # The annotations to set on the application namespace
        the: same
        applies: for
        annotations: on-the-namespace

    # The retry feature is available since v1.7
    retry:
      limit: 5 # number of failed sync attempt retries; unlimited number of attempts if less than 0
      backoff:
        duration: 5s # the amount to back off. Default unit is seconds, but could also be a duration (e.g. "2m", "1h")
        factor: 2 # a factor to multiply the base duration after each failed retry
        maxDuration: 3m # the maximum amount of time allowed for the backoff strategy

  # Will ignore differences between live and desired states during the diff. Note that these configurations are not
  # used during the sync process unless the `RespectIgnoreDifferences=true` sync option is enabled.
  ignoreDifferences:
  # for the specified json pointers
  - group: apps
    kind: Deployment
    jsonPointers:
    - /spec/replicas
  - kind: ConfigMap
    jqPathExpressions:
    - '.data["config.yaml"].auth'
  # for the specified managedFields managers
  - group: "*"
    kind: "*"
    managedFieldsManagers:
    - kube-controller-manager
    # Name and namespace are optional. If specified, they must match exactly, these are not glob patterns.
    name: my-deployment
    namespace: my-namespace

  # RevisionHistoryLimit limits the number of items kept in the application's revision history, which is used for
  # informational purposes as well as for rollbacks to previous versions. This should only be changed in exceptional
  # circumstances. Setting to zero will store no history. This will reduce storage used. Increasing will increase the
  # space used to store the history, so we do not recommend increasing it.
  revisionHistoryLimit: 10

参考文档

https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#applications

标签:name,io,namespace,ArgoCD,value,Application,CRD,Helm,true
From: https://www.cnblogs.com/wangguishe/p/17897549.html

相关文章

  • spring ApplicationContext通常的实现是什么?
    FileSystemXmlApplicationContext:此容器从一个XML文件中加载beans的定义,XMLBean配置文件的全路径名必须提供给它的构造函数。ClassPathXmlApplicationContext:此容器也从一个XML文件中加载beans的定义,这里,你需要正确设置classpath因为这个容器将在classpath里找bean配置。WebXmlA......
  • ArgoCD 同步配置
    自动同步策略当ArgoCD检测到Git中所需的清单与集群中的实时状态之间的差异时,它能够自动同步应用程序。自动同步的好处是CI/CD管道不再需要直接访问ArgoCDAPI服务器来执行部署。相反,管道会提交并推送到Git存储库,并对跟踪Git存储库中的清单进行更改。PruneResour......
  • ApplicationContextInitializer在Spring容器执行refresh之前执行
    ApplicationContextInitializer用于在刷新Spring容器之前的回调接口。ApplicationContextInitializer是Spring框架原有的概念,这个类的主要目的就是在ConfigurableApplicationContext类型(或者子类型)的ApplicationContext进行刷新refresh之前,允许我们对ConfigurableApplicatio......
  • ApplicationContext is unlikely to start due to a @ComponentScan of the default p
    springboot警告:ApplicationContextisunlikelytostartduetoa@ComponentScanofthedefaultpackage解决办法:1、一般发出这个警告的原因是你把启动类直接放在的src目录下面。2、你需要在src目录下面再建一个包,然后把启动类放到下面。3、或者你错将启动类放到java文件中了......
  • Spring Boot学习随笔- @SpringBootApplication详解、加载绝对路径配置文件、工厂创建
    学习视频:【编程不良人】2021年SpringBoot最新最全教程3.5@SpringBootApplication详解这是一个组合注解,就是由多个注解组成。下列注解红框内称为元注解(jdk提供)@Target:指定注解作用范围@Retention:指定注解什么时候生效重要注解@SpringBootConfiguration:自动配置Spring......
  • Docker - Build an application to an image
    Dockerfile:#BuildstageFROMgolang:1.21.5-alpine3.18ASbuilderWORKDIR/appCOPY..RUNgoenv-wGOPROXY=https://goproxy.io,directRUNgobuild-omainmain.go#RunstageFROMalpine:3.18WORKDIR/appCOPY--from=builder/app/main.COPYapp.env......
  • 解决:Command line is too long. Shorten command line for xxx or also for Applicati
    解决:Commandlineistoolong.ShortencommandlineforxxxoralsoforApplicationdefaultconfigurat解决:Errorrunning'xxx':Commandlineistoolong.ShortencommandlineforxxxoralsoforApplicationdefaultconfiguration?一·问题描述:1.运行一......
  • 一、Spring学习 : 容器---->BeanFactory+ApplicationContext 的多种容器实现
    BeanFactory实现的特点我们来着重讲一下DefaultListableBeanFactory这个实现类:点击查看完整代码packagecom.itvayne.springbootcloudstudy.beanfactory01;importcom.sun.org.slf4j.internal.Logger;importcom.sun.org.slf4j.internal.LoggerFactory;importorg.springf......
  • Tekton Trigger CRD
    Trigger概述Trigger指定事件监听器检测到事件时发生的情况。主要由TriggerTemplate、TriggerBinding和Interceptor组成。TriggerTemplate定义在spec.template字段上,支持引用和内联两种定义方式。TriggerBinding定义在spec.bindings字段上,支持引用和内联两种定义方式。Cluster......
  • Spring Boot2 开启系统日志(2)- 在application中配置日志
    在application.yml中通过logging.level来配置root是所有日志级别的打印;sql、web是分别设置sql或web相关的日志级别2.另外还可以分别对不同的包设置不同的日志打印级别#Logconfigurationlogging:level:com.*:debugorg.springframework:warn如上所示,分别......