Skip to content

Commit 03a4a47

Browse files
authored
Merge pull request #21 from markoskandylis/main
Adding new Helm charts with Examples
2 parents 1758b08 + 1b0bb65 commit 03a4a47

31 files changed

+1719
-0
lines changed

charts/application-sets/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/application-sets/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: application-sets
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.0.0"
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: ApplicationSet
3+
metadata:
4+
name: cluster-addons
5+
namespace: argocd
6+
spec:
7+
syncPolicy:
8+
preserveResourcesOnDeletion: false
9+
goTemplate: true
10+
goTemplateOptions:
11+
- missingkey=error
12+
generators:
13+
- matrix:
14+
generators:
15+
- matrix:
16+
generators:
17+
- clusters:
18+
selector:
19+
matchLabels:
20+
fleet_member: hub-cluster
21+
values:
22+
chartName: application-sets
23+
chartRepo: "12345678910.dkr.ecr.eu-west-2.amazonaws.com"
24+
chartPath: "charts/application-sets"
25+
applicationSetGroup: "addons"
26+
groupRelease: '{{default "" (index .metadata.labels "addonsRelease")}}'
27+
useSelectors: "false"
28+
useVersionSelectors: "true"
29+
- git:
30+
repoURL: '{{ .metadata.annotations.fleet_repo_url }}'
31+
revision: '{{ .metadata.annotations.fleet_repo_revision }}'
32+
files:
33+
- path: "{{ .metadata.annotations.fleet_repo_basepath }}/bootstrap/versions/applicationSets.yaml"
34+
- list:
35+
elementsYaml: |
36+
{{- $releaseTypes := index .releases .values.applicationSetGroup | toJson | fromJson -}}
37+
{{- $result := list -}}
38+
{{- $defaultVersion := dict -}}
39+
{{- /* Defining the Default Version in case we need to fall back */ -}}
40+
{{- range $releaseType := $releaseTypes -}}
41+
{{- if eq $releaseType.type "default" -}}
42+
{{- $defaultVersion = $releaseType -}}
43+
{{- end -}}
44+
{{- end -}}
45+
{{- /* We look for the defined releases */ -}}
46+
{{- range $releaseType := $releaseTypes -}}
47+
{{- /* Case 1: If selectors is true, include all group releases */ -}}
48+
{{- if eq $.values.useSelectors "true" -}}
49+
{{- $result = append $result $releaseType -}}
50+
{{- /* Case 2: If group version Release value exists, only include matching releases */ -}}
51+
{{- else if $.values.groupRelease -}}
52+
{{- if or (not $releaseType.type) (eq $releaseType.type $.values.groupRelease) -}}
53+
{{- $result = append $result $releaseType -}}
54+
{{- end -}}
55+
{{- /* Case 3: Default case - include version if it's the default type */ -}}
56+
{{- else -}}
57+
{{- if eq $releaseType.type "default" -}}
58+
{{- $result = append $result $releaseType -}}
59+
{{- end -}}
60+
{{- end -}}
61+
{{- end -}}
62+
{{- /* If no releases were selected, use default */ -}}
63+
{{- if eq (len $result) 0 -}}
64+
{{- $result = append $result $defaultVersion -}}
65+
{{- end -}}
66+
{{ $result | toJson }}
67+
###################################################
68+
#base template (everything common)
69+
###################################################
70+
template:
71+
metadata:
72+
name: 'cluster-{{.values.applicationSetGroup}}-{{.name}}-{{.type | lower }}'
73+
spec:
74+
project: default
75+
destination:
76+
namespace: argocd
77+
name: '{{ .name }}'
78+
# syncPolicy is identical for both variants
79+
syncPolicy:
80+
automated:
81+
selfHeal: false
82+
allowEmpty: true
83+
prune: false
84+
retry:
85+
limit: 100
86+
syncOptions:
87+
- CreateNamespace=true
88+
- ServerSideApply=true
89+
###################################################
90+
# conditional sources
91+
###################################################
92+
templatePatch: |
93+
spec:
94+
sources:
95+
- ref: values
96+
repoURL: '{{ .metadata.annotations.addons_repo_url }}'
97+
targetRevision: '{{ .metadata.annotations.addons_repo_revision }}'
98+
{{- if eq .use_helm_repo_path "false" }}
99+
- repoURL: '{{default .values.chartRepo .chartRepo }}'
100+
chart: '{{ default .values.chartName .ecrChartName }}'
101+
targetRevision: '{{.version}}'
102+
{{- else }}
103+
- repoURL: '{{ .metadata.annotations.addons_repo_url }}'
104+
path: '{{ .values.chartPath }}'
105+
targetRevision: '{{ .metadata.annotations.addons_repo_revision }}'
106+
{{- end }}
107+
helm:
108+
ignoreMissingValueFiles: true
109+
valuesObject:
110+
useSelectors: false
111+
useVersionSelectors: '{{.values.useVersionSelectors}}'
112+
# Defining the way to group addons This application set will handly Addons and ACK values
113+
mergeValues:
114+
addons:
115+
use: true
116+
ack:
117+
use: true
118+
releaseType: '{{.type | lower }}'
119+
# If we are using version selector we add the version of the releases on the matchlabels
120+
{{- if eq .values.useVersionSelectors "true"}}
121+
releases:
122+
{{.values.applicationSetGroup}}Release: '{{.type | lower}}'
123+
{{- end }}
124+
{{- if eq .values.useSelectors "false"}}
125+
globalSelectors:
126+
fleet_member: hub-cluster
127+
{{- end }}
128+
valueFiles:
129+
- defaults/{{.values.applicationSetGroup}}
130+
- clusters/{{`{{ .nameNormalized }}`}}/{{.values.applicationSetGroup}}
131+
valueFiles:
132+
- $values/{{ .metadata.annotations.addons_repo_basepath }}/bootstrap/defaults/{{.values.applicationSetGroup}}.yaml
133+
- $values/{{ .metadata.annotations.addons_repo_basepath }}/{{ .metadata.labels.tenant }}/defaults/{{ .values.chartName }}/{{.values.applicationSetGroup}}.yaml
134+
- $values/{{ .metadata.annotations.addons_repo_basepath }}/{{ .metadata.labels.tenant }}/clusters/{{ .name }}/{{ .values.chartName }}/{{.values.applicationSetGroup}}.yaml
135+
- $values/{{ .metadata.annotations.addons_repo_basepath }}/{{ .metadata.labels.tenant }}/environments/{{ .metadata.labels.environment }}/{{ .values.chartName }}/{{.values.applicationSetGroup}}.yaml
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: ApplicationSet
3+
metadata:
4+
name: fleet-hub-secret-store
5+
namespace: argocd
6+
spec:
7+
syncPolicy:
8+
preserveResourcesOnDeletion: true
9+
goTemplate: true
10+
goTemplateOptions:
11+
- missingkey=error
12+
generators:
13+
- matrix:
14+
generators:
15+
- matrix:
16+
generators:
17+
- clusters:
18+
selector:
19+
matchLabels:
20+
fleet_member: hub-cluster
21+
values:
22+
addonChart: fleet-secret
23+
fleet_memeber: hub-cluster
24+
addonChartPath: "charts/fleet-secret"
25+
- git:
26+
repoURL: '{{ .metadata.annotations.fleet_repo_url }}'
27+
revision: '{{ .metadata.annotations.fleet_repo_revision }}'
28+
files:
29+
- path: "{{ .metadata.annotations.fleet_repo_basepath }}/bootstrap/versions/fleetSecrets.yaml"
30+
- list:
31+
elementsYaml: "{{ .releases | toJson }}"
32+
###################################################
33+
#base template (everything common)
34+
###################################################
35+
template:
36+
metadata:
37+
name: 'fleet-hub-secret-store-{{.nameNormalized}}'
38+
spec:
39+
project: default
40+
destination:
41+
namespace: argocd
42+
name: '{{ .name }}'
43+
# syncPolicy is identical for both variants
44+
syncPolicy:
45+
automated:
46+
selfHeal: false
47+
allowEmpty: true
48+
prune: false
49+
retry:
50+
limit: 100
51+
syncOptions:
52+
- CreateNamespace=true
53+
- ServerSideApply=true
54+
###################################################
55+
# conditional sources
56+
###################################################
57+
templatePatch: |
58+
spec:
59+
sources:
60+
- repoURL: '{{.metadata.annotations.addons_repo_url}}'
61+
targetRevision: '{{.metadata.annotations.addons_repo_revision}}'
62+
ref: addonsValues
63+
- repoURL: '{{.metadata.annotations.resources_repo_url}}'
64+
targetRevision: '{{.metadata.annotations.resources_repo_revision}}'
65+
ref: resourcesValues
66+
{{- if eq .use_helm_repo_path "false" }}
67+
- repoURL: '{{ .chartRepo }}'
68+
chart: '{{ default .values.addonChart .ecrChartName }}'
69+
targetRevision: '{{.version}}'
70+
{{- else }}
71+
- repoURL: '{{ .metadata.annotations.fleet_repo_url }}'
72+
path: '{{ .values.addonChartPath }}'
73+
targetRevision: '{{ .metadata.annotations.fleet_repo_revision }}'
74+
{{- end }}
75+
helm:
76+
releaseName: '{{.nameNormalized}}'
77+
ignoreMissingValueFiles: true
78+
valuesObject:
79+
secretStore:
80+
enabled: true
81+
name: "fleet-eks-secret-store"
82+
kind: "SecretStore"
83+
region: '{{.metadata.annotations.aws_region}}'
84+
externalSecret:
85+
enabled: true
86+
server: self
87+
creationPolicy: Merge
88+
targetName: '{{.name}}'
89+
clusterName: '{{.name}}'
90+
secretManagerSecretName: 'hub/{{.name}}'
91+
secretStoreRefName: fleet-eks-secret-store
92+
secretStoreRefKind: SecretStore
93+
ignoreMissingValueFiles: true
94+
valueFiles:
95+
- $addonsValues/{{.metadata.annotations.addons_repo_basepath}}/defaults/fleet/{{.values.addonChart}}/values.yaml
96+
- $addonsValues/{{.metadata.annotations.addons_repo_basepath}}/{{.metadata.labels.tenant}}/fleet/{{.values.addonChart}}/values.yaml
97+
- $addonsValues/{{.metadata.annotations.addons_repo_basepath}}/{{.metadata.labels.tenant}}/clusters/{{.name}}/fleet/{{.values.addonChart}}/values.yaml
98+
- $resourcesValues/{{.metadata.annotations.resources_repo_basepath}}/defaults/fleet/{{.values.addonChart}}/values.yaml
99+
- $resourcesValues/{{.metadata.annotations.resources_repo_basepath}}/{{.metadata.labels.tenant}}/fleet/{{.values.addonChart}}/values.yaml
100+
- $resourcesValues/{{.metadata.annotations.resources_repo_basepath}}/{{.metadata.labels.tenant}}/clusters/{{.name}}/fleet/{{.values.addonChart}}/values.yaml

0 commit comments

Comments
 (0)