Skip to content

Conversation

@bkonicek
Copy link
Owner

No description provided.

@bkonicek
Copy link
Owner Author

Update AppSet like so

# AppSet for custom apps that don't necessarily follow the pattern of the others.
# Path structure is environments/<app-name> with namespace defined in config.yaml.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: argocd-applications
  namespace: argocd
spec:
  goTemplate: true
  # goTemplateOptions: ["missingkey=error"]
  generators:
    - git:
        repoURL: https://github.com/bkonicek/gitops
        revision: HEAD
        files:
          - path: environments/*/*/config.yaml
  template:
    metadata:
      name: '{{index .path.segments 1}}-{{.path.basenameNormalized}}'
      labels:
        app_name: '{{.path.basenameNormalized}}'
        environment: '{{index .path.segments 1}}'
    spec:
      project: default
      destination:
        namespace: '{{ .namespace }}'
        server: https://kubernetes.default.svc
      syncPolicy:
        automated:
          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: true # Allows deleting all application resources during automatic syncing ( false by default ).
        syncOptions:
          - CreateNamespace=true
          - ServerSideApply={{ .serverSideApply | default "false"}}
  templatePatch: |
      sources:
        - repoURL: '{{ .repoURL | default "https://github.com/bkonicek/gitops" }}'
          targetRevision: '{{ .targetRevision | default "HEAD" }}'
          {{- $isExternal := and (hasKey . "repoURL") (ne .repoURL ""https://github.com/bkonicek/gitops") }}
          {{- if $isExternal }}
          chart: '{{ .chartName | default .path.basenameNormalized }}'
          {{- else }}
          path: '{{ .path.path }}'
          {{- end }}
          helm:
            valueFiles:
            {{- if $isExternal }}
            - $values/base/{{ default (printf "%s.yaml" .path.basenameNormalized) .baseValuesFile }}
            {{- else }}
            - ../../../base/{{ default (printf "%s.yaml" .path.basenameNormalized) .baseValuesFile }}
            {{- end }}
            - values.yaml
            ignoreMissingValueFiles: true
        {{- if $isExternal }}
        - repoURL: https://github.com/bkonicek/gitops
          targetRevision: '{{ .valuesRevision | default "HEAD" }}'
          ref: values
        {{- end }}
  syncPolicy:
    preserveResourcesOnDeletion: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants