Argo CD YAML资源清单

Argo CD YAML 资源清单

Argo CD 创建 APP 的方式

  • webUI
  • argoCLI
  • YAML

YAML 资源清单创建 APP 服务

官方配置文件:https://argo-cd.readthedocs.io/en/stable/operator-manual/application.yaml

实验代码库:https://github.com/argoproj/argocd-example-apps

Directory 文件 YAML 资源清单

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: directory-guestbook
  namespace: argocd
spec:
  destination:
    namespace: directory-guestbook
    server: https://kubernetes.default.svc
  project: default
  source:
    path: guestbook
    repoURL: https://github.com/argoproj/argocd-example-apps.git
    targetRevision: master
    directory:
      recurse: true
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
  • 其他参数
    # directory
    directory:
      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'
      # 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'

Helm 文件 YAML 资源清单

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: helm-app
  namespace: argocd
spec:
  project: default
  source:
    #chart: sealed-secrets
    #repoURL: https://bitnami-labs.github.io/sealed-secrets
    #targetRevision: 1.16.1
    path: helm-guestbook
    repoURL: https://github.com/argoproj/argocd-example-apps.git
    targetRevision: master
    helm:
      releaseName: my-release
  destination:
    server: "https://kubernetes.default.svc"
    namespace: helm-app
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
  • 其他参数
    # 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
      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

      # 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 文件 YAML 资源清单

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: guestbook-kustomize
  namespace: argocd
spec:
  source:
    repoURL: "https://github.com/argoproj/argocd-example-apps.git"
    targetRevision: master
    path: kustomize-guestbook
    kustomize:
      namePrefix: "staging-"
      #replicas:
      #- name: guestbook-ui
      #count: 5
  destination:
    namespace: kustomize-guestbook
    server: "https://kubernetes.default.svc"
  project: default
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
  • 其他参数
    # 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
posted @ 2023-08-10 17:25  evescn  阅读(166)  评论(0编辑  收藏  举报