diff --git a/Charts/argocd-apps/Chart.yaml b/Charts/argocd-apps/Chart.yaml new file mode 100644 index 0000000..a466a4b --- /dev/null +++ b/Charts/argocd-apps/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: argocd-apps +description: | + A chart for creating Argocd managed apps for ec services. + +type: library + +version: 3.4.0 diff --git a/Charts/argocd-apps/templates/_apps.tpl b/Charts/argocd-apps/templates/_apps.tpl new file mode 100644 index 0000000..c19afe8 --- /dev/null +++ b/Charts/argocd-apps/templates/_apps.tpl @@ -0,0 +1,41 @@ +{{- define "ec-helm-charts.argocd-apps" -}} +{{- $currentScope := . -}} +{{- range $service, $settings := .Values.services }} +{{- /* Make sure settings is an empty dict if it is currently nil */ -}} +{{ $settings := default dict $settings -}} +{{ if ne $settings.removed true }} +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: {{ $service }} + namespace: {{ $currentScope.Release.Namespace }} + labels: + ec_service: {{ eq $settings.ec_service true | ternary true false | quote }} + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: {{ default $currentScope.Release.Namespace $currentScope.Values.project }} + destination: + namespace: {{ $currentScope.Values.destination.namespace }} + name: {{ $currentScope.Values.destination.name }} + source: + repoURL: {{ default $currentScope.Values.source.repoURL $settings.repoURL }} + path: services/{{ $service }} + targetRevision: {{ default $currentScope.Values.source.targetRevision $settings.targetRevision }} + helm: + version: v3 + valueFiles: + - ../values.yaml + - values.yaml + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + # don't restart pods unless there has been a change + - ApplyOutOfSyncOnly=true + - RespectIgnoreDifferences=true +--- +{{ end }} +{{- end -}} +{{- end -}} diff --git a/Schemas/argocd-apps.schema.json b/Schemas/argocd-apps.schema.json new file mode 100644 index 0000000..71d9d53 --- /dev/null +++ b/Schemas/argocd-apps.schema.json @@ -0,0 +1,79 @@ +{ + "properties": { + "destination": { + "description": "The desired Kubernetes cluster for deployment", + "properties": { + "name": { + "type": "string", + "description": "The name of the Kubernetes cluster" + }, + "namespace": { + "type": "string", + "description": "The target namespace" + } + }, + "type": "object" + }, + "source": { + "description": "The desired specification of the services to be deployed", + "properties": { + "targetRevision": { + "type": "string", + "description": "Optional override for targetRevision" + }, + "repoURL": { + "type": "string", + "description": "The git repo hosting the services repository (helm chart path must be services/)" + } + }, + "type": "object" + }, + "services": { + "type": "object", + "patternProperties": { + "^.*$": { + "type": ["object", "null"], + "properties": { + "targetRevision": { + "type": "string", + "description": "Override for targetRevision" + }, + "repoURL": { + "type": "string", + "description": "Override for repoURL" + }, + "ec_service": { + "type": "boolean", + "description": "Manage a service as an Epics container", + "default": "False" + }, + "enabled": { + "type": "boolean", + "description": "Start a service", + "default": "True" + }, + "removed": { + "type": "boolean", + "description": "Remove the service from the cluster", + "default": "False" + } + }, + "additionalProperties": false, + "description": "A service instance" + } + } + }, + "project": { + "description": "A target Argocd Project", + "type": "string" + } + }, + "required": [ + "project", + "destination", + "source" + ], + "title": "Values", + "type": "object" +} + \ No newline at end of file