-
Notifications
You must be signed in to change notification settings - Fork 2
/
helmfile.yaml
278 lines (245 loc) · 10.8 KB
/
helmfile.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
environments:
default:
values:
- sane-defaults.yaml
- cloudbees-ci.yaml
# calculated internal values:
# todo: I think we can use nil in the merge
- ldapGlobalPassword: {{ requiredEnv "ENV_ABSTRACTED_PW" }}
- ocUrl: {{ if .Values.https.enabled -}} https {{- else -}} http {{- end -}}://{{ .Values.domain }}/{{ .Values.cjoc.path }}
{{ $cbcoreChartYaml := exec "helm" (list "show" "chart" "cloudbees/cloudbees-core" "--version" .Values.cloudbeesCoreChartVersion) | fromYaml }}
{{ $cbcoreAppVersion := $cbcoreChartYaml.appVersion }}
{{ $cbcoreChartDeps := dict }}
{{ range $dep := $cbcoreChartYaml.dependencies }}
{{ $cbcoreChartDeps = set $cbcoreChartDeps $dep.name (dict "version" $dep.version) }}
{{ end }}
{{ $bundledNginxIngressVersion := (get "ingress-nginx" $cbcoreChartDeps).version }}
- cloudbeesCoreAppVersion: {{ $cbcoreAppVersion }}
{{ $url := nospace (cat "https://jenkins-updates.cloudbees.com/update-center/envelope-core-mm/update-center.json?version=" $cbcoreAppVersion) }}
{{ $uc := exec "sh" (list "-c" (cat "wget -q -O - " $url " | sed '1d' | sed '$d' | jq -r | yq e - -P")) | fromYaml }}
# Not entirely sure why our UC json has issues being converted into yaml/golang strings.
# The next two sections sorts that out, though, by just looping through the data and
# redefining the dicts. Very odd.
{{ $rawUcEnvelopePlugins := $uc.envelope.plugins }}
{{ $rawUcPlugins := $uc.plugins }}
{{ $ucEnvelopePlugins := dict }}
{{ range $k, $v := $rawUcEnvelopePlugins }}
{{ if eq (typeOf $k) "string" }}
{{ $ucEnvelopePlugins = set $ucEnvelopePlugins $k $v }}
{{ end }}
{{ end }}
{{ $ucPlugins := dict }}
{{ range $k, $v := $rawUcPlugins }}
{{ if eq (typeOf $k) "string" }}
{{ $ucPlugins = set $ucPlugins $k $v }}
{{ end }}
{{ end }}
- calculatedMasters:
masters:
{{ $globalAppIds := list }}
{{ $masters := dict }}
# Pull in anything from .Values here as var
{{ $defaultMasterTemplate := .Values.masters.defaultMasterTemplate }}
{{ $masterTemplates := .Values.masters.masterTemplates }}
{{ $masterDefinitions := .Values.masters.masterDefinitions }}
{{ $masterProvisioningYamlPatchTpl := .Values.masters.yamlPatchTemplate }}
{{ $ghOrgScriptTpl := .Values.appIdConfig.template }}
{{ $oneSpecificMasterOnly := .Values | get "oneSpecificMasterOnly" "" }}
# transform the manyMasters into named specific masters
{{ $manyMasters := list }}
{{ range $definition := get "manyMasters" $masterDefinitions }}
{{ range $i := until (get "quantity" $definition) }}
{{ $masterName := nospace (cat ($definition.prefix) (printf "%04d" (add $i 1))) }}
{{ $masterTemplate := $definition.masterTemplate }}
{{ $manyMasters = append $manyMasters (dict "name" $masterName "masterTemplate" $masterTemplate) }}
{{ end }}
{{ end }}
# restructure the dictionary of specificMasters into a list we can append to
{{ $listOfSpecificMasters := list }}
{{ $specificMasters := get "specificMasters" $masterDefinitions }}
{{ range $smName, $smDefinition := $specificMasters }}
{{ if (or (eq $oneSpecificMasterOnly "") (eq $smName $oneSpecificMasterOnly)) }}
{{ $smDefinition = set $smDefinition "name" $smName }}
{{ $listOfSpecificMasters = append $listOfSpecificMasters $smDefinition }}
{{ end }}
{{ end }}
# append manyMasters to specific masters and calculate them all
{{ $allMasters := concat $listOfSpecificMasters $manyMasters }}
{{ range $definition := $allMasters }}
{{ $masterName := $definition.name }}
{{ $masterTemplate := $defaultMasterTemplate }}
{{ if ne $definition.masterTemplate "default" }}
{{ $masterTemplate = get $definition.masterTemplate $masterTemplates }}
{{ end }}
# perform the merge (in the case of default master template, we double-merge, to no ill-effect
{{ $mergedDefinition := mergeOverwrite (deepCopy $defaultMasterTemplate) $masterTemplate (omit $definition "masterTemplate" "name") }}
# build appids safely as the node might not exist in definition
{{ $appIds := list }}
{{ if (hasKey $mergedDefinition "appIds") }}
{{ $appIds = $mergedDefinition.appIds }}
{{ end }}
# build provisioning node
{{ $provisioning := $mergedDefinition.provisioning }}
{{ $yaml := (tpl ($masterProvisioningYamlPatchTpl) (dict "masterName" $masterName)) }}
{{ $provisioning = set $provisioning "yaml" $yaml }}
# Add an APP_IDS envVar to provisioning.
{{ $envVars := "" }}
{{ if hasKey $provisioning "envVars" }}
{{ $envVars = $provisioning.envVars }}
{{ end }}
{{ $appIdsCsv := ($appIds | join ",") }}
{{ if or $envVars $appIdsCsv }}
{{ $appIdsEnvVar := nospace (cat "APP_IDS=" $appIdsCsv) }}
{{ $envVars = (cat $envVars "\n" $appIdsEnvVar) }}
{{ $provisioning = set $provisioning "envVars" $envVars }}
{{ else }}
{{ $provisioning = unset $provisioning "envVars" }}
{{ end }}
# build the jcasc node
{{ $jcasc := $mergedDefinition.jcasc }}
# special case for creating appId GH folders
{{ $jcascJobs := list }}
{{ if (hasKey $jcasc "jobs") }}
{{ $jcascJobs = $jcasc.jobs }}
{{ end }}
{{ range $appId := $appIds }}
{{ $ghOrgScript := (tpl ($ghOrgScriptTpl) (dict "appId" $appId)) }}
{{ $jcascJobs = append $jcascJobs (dict "script" $ghOrgScript) }}
{{ end }}
{{ $jcasc = set $jcasc "jobs" $jcascJobs }}
# build the plugin list, keep track of tier3s for use in building pluginCatalog
{{ $fullPluginList:= list }}
{{ $pluginCatalogList:= dict }}
{{ range $pluginName, $pluginValue := $mergedDefinition.plugins }}
{{ $fullPluginList = append $fullPluginList (dict "id" $pluginName) }}
{{ if not (hasKey $ucEnvelopePlugins $pluginName) }}
{{ $ucPlugin := get $pluginName $ucPlugins }}
{{ $version := $ucPlugin.version }}
{{ $pluginCatalogList = set $pluginCatalogList $pluginName (dict "version" $version) }}
{{ end }}
{{ end }}
# build pluginCatalog node
{{ $pluginCatalog := dict "type" "plugin-catalog" "version" "1" "name" (cat "catalog for" $masterName) "displayName" (cat "Catalog For" $masterName)}}
{{ $pluginCatalog = set $pluginCatalog "configurations" (list (dict "description" "tier 3 plugins" "includePlugins" $pluginCatalogList)) }}
# build the bundle node
{{ $bundle := dict }}
{{ $bundle = set $bundle "pluginCatalog" $pluginCatalog }}
{{ $bundle = set $bundle "plugins" $fullPluginList }}
{{ $bundle = set $bundle "jcasc" $jcasc }}
# build the master definition
{{ $calculatedMaster := dict }}
{{ $calculatedMaster = set $calculatedMaster "provisioning" $provisioning }}
{{ $calculatedMaster = set $calculatedMaster "bundle" $bundle }}
{{ $calculatedMaster = set $calculatedMaster "appIds" $appIds }}
# add calculated master to masters list
{{ $masters = set $masters $masterName $calculatedMaster }}
# append appids to running list
{{ $globalAppIds = concat $globalAppIds $appIds }}
{{ end }}
{{ $masters | toYaml | nindent 10 }}
- appIds: {{ $globalAppIds | uniq | toJson }}
repositories:
- name: prometheus-community
url: https://prometheus-community.github.io/helm-charts
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: incubator
url: https://charts.helm.sh/incubator
- name: cloudbees
url: https://charts.cloudbees.com/public/cloudbees
- name: jetstack
url: https://charts.jetstack.io
- name: cetic
url: https://cetic.github.io/helm-charts
- name: geek-cookbook
url: https://geek-cookbook.github.io/charts/
helmDefaults:
# wait for k8s resources via --wait. (default false)
wait: true
# time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks, and waits on pod/pvc/svc/deployment readiness) (default 300)
timeout: 600
# performs pods restart for the resource if applicable (default false)
recreatePods: false
# limit the maximum number of revisions saved per release. Use 0 for no limit. (default 10)
historyMax: 0
### can be used to pass in a specific kubeconfig
# args:
#- --kubeconfig=../tf-kubeconfig.yaml
releases:
- name: cbcore
namespace: cloudbees
chart: cloudbees/cloudbees-core
version: {{ .Values.cloudbeesCoreChartVersion }}
values:
- values/cbcore.yaml.gotmpl
needs:
- ingress-nginx/ingress-nginx
- cert-manager/cert-manager
- cloudbees/oc-extra-plugins
- ldap/ldap
- name: oc-extra-plugins
namespace: cloudbees
chart: incubator/raw
values:
- values/oc-extra-plugins.yaml.gotmpl
- name: master-provisioner
namespace: cloudbees
chart: incubator/raw
values:
- values/master-provisioner.yaml.gotmpl
needs:
- cloudbees/cbcore
- name: master-definitions
namespace: cloudbees
chart: incubator/raw
values:
- values/master-definitions.yaml.gotmpl
needs:
- cloudbees/master-provisioner
- name: prometheus-operator
condition: prometheus-operator.enabled
namespace: prometheus-operator
chart: prometheus-community/kube-prometheus-stack
version: 13.7.2
needs:
- ingress-nginx/ingress-nginx
values:
- values/prometheus-operator.yaml.gotmpl
- name: ingress-nginx
namespace: ingress-nginx
chart: ingress-nginx/ingress-nginx
version: {{ $bundledNginxIngressVersion }}
values:
- values/ingress-nginx.yaml.gotmpl
- name: cert-manager
namespace: cert-manager
condition: https.enabled
chart: jetstack/cert-manager
version: v1.2.0
values:
- values/cert-manager.yaml.gotmpl
needs:
- ingress-nginx/ingress-nginx
- name: ldap
namespace: ldap
chart: geek-cookbook/openldap
version: 1.2.9
values:
- values/ldap.yaml.gotmpl
- name: ldap-admin
condition: ldap-admin.enabled
namespace: ldap
chart: cetic/phpldapadmin
version: 0.1.3
values:
- values/phpldapadmin.yaml.gotmpl
needs:
- ldap/ldap
- name: cm-cluster-issuer
condition: https.enabled
namespace: cert-manager
chart: incubator/raw
values:
- values/cluster-issuer.yaml.gotmpl
needs:
- cert-manager/cert-manager