Skip to content

Commit

Permalink
Apps library (#31)
Browse files Browse the repository at this point in the history
* Experiment with helm library chart

* Add ec-service label

* Update _apps.tpl

Fix ec-service label

* Create argocd-apps schema

* Fix broken ec-service label

* Rename argo label

* Remove parameter override

---------

Co-authored-by: Giles Knap <[email protected]>
  • Loading branch information
marcelldls and gilesknap authored Aug 22, 2024
1 parent 2374c00 commit fed07ae
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Charts/argocd-apps/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions Charts/argocd-apps/templates/_apps.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}
79 changes: 79 additions & 0 deletions Schemas/argocd-apps.schema.json
Original file line number Diff line number Diff line change
@@ -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/<service>)"
}
},
"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"
}

0 comments on commit fed07ae

Please sign in to comment.