Skip to content

Commit 64a51c3

Browse files
feat: add resource configuration for apps to teams (#1819)
Co-authored-by: jeho <[email protected]>
1 parent 497c66d commit 64a51c3

File tree

15 files changed

+262
-40
lines changed

15 files changed

+262
-40
lines changed

charts/team-ns/templates/tekton-tasks/buildpacks.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- $t := .Values.teamApps.tekton }}
12
apiVersion: tekton.dev/v1
23
kind: Task
34
metadata:
@@ -86,12 +87,7 @@ spec:
8687
- name: CNB_PLATFORM_API
8788
value: "0.9"
8889
computeResources:
89-
limits:
90-
cpu: "2"
91-
memory: 2Gi
92-
requests:
93-
cpu: 500m
94-
memory: 512Mi
90+
{{- $t.resources.buildpacksTask | toYaml | nindent 6 }}
9591
steps:
9692
- name: prepare
9793
computeResources: {}
@@ -201,4 +197,4 @@ spec:
201197
- name: empty-dir
202198
emptyDir: {}
203199
- name: layers-dir
204-
emptyDir: {}
200+
emptyDir: {}

charts/team-ns/templates/tekton-tasks/git-clone.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- $t := .Values.teamApps.tekton }}
12
apiVersion: tekton.dev/v1
23
kind: Task
34
metadata:
@@ -13,12 +14,7 @@ metadata:
1314
spec:
1415
stepTemplate:
1516
computeResources:
16-
limits:
17-
cpu: "2"
18-
memory: 2Gi
19-
requests:
20-
cpu: 500m
21-
memory: 512Mi
17+
{{- $t.resources.gitCloneTask | toYaml | nindent 6 }}
2218
description: >-
2319
These Tasks are Git tasks to work with repositories used by other tasks
2420
in your Pipeline.
@@ -259,4 +255,4 @@ spec:
259255
RESULT_COMMITTER_DATE="$(git log -1 --pretty=%ct)"
260256
printf "%s" "${RESULT_COMMITTER_DATE}" > "$(results.committer-date.path)"
261257
printf "%s" "${RESULT_SHA}" > "$(results.commit.path)"
262-
printf "%s" "${PARAM_URL}" > "$(results.url.path)"
258+
printf "%s" "${PARAM_URL}" > "$(results.url.path)"

charts/team-ns/templates/tekton-tasks/grype.yaml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- $t := .Values.teamApps.tekton }}
12
apiVersion: tekton.dev/v1
23
kind: Task
34
metadata:
@@ -13,12 +14,7 @@ metadata:
1314
spec:
1415
stepTemplate:
1516
computeResources:
16-
limits:
17-
cpu: "2"
18-
memory: 2Gi
19-
requests:
20-
cpu: 500m
21-
memory: 512Mi
17+
{{- $t.resources.grypeTask | toYaml | nindent 6 }}
2218
description: >-
2319
A vulnerability scanner for container images and filesystems.
2420
Works with Syft, the powerful SBOM (software bill of materials) tool for container images and filesystems.

charts/team-ns/templates/tekton-tasks/kaniko.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- $t := .Values.teamApps.tekton }}
12
apiVersion: tekton.dev/v1
23
kind: Task
34
metadata:
@@ -13,12 +14,7 @@ metadata:
1314
spec:
1415
stepTemplate:
1516
computeResources:
16-
limits:
17-
cpu: "2"
18-
memory: 2Gi
19-
requests:
20-
cpu: 500m
21-
memory: 512Mi
17+
{{- $t.resources.kanikoTask | toYaml | nindent 6 }}
2218
description: >-
2319
This Task builds a simple Dockerfile with kaniko and pushes to a registry.
2420
This Task stores the image name and digest as results, allowing Tekton Chains to pick up
@@ -79,4 +75,4 @@ spec:
7975
script: |
8076
set -e
8177
image="$(params.IMAGE)"
82-
echo -n "${image}" | tee "$(results.IMAGE_URL.path)"
78+
echo -n "${image}" | tee "$(results.IMAGE_URL.path)"

helmfile.d/helmfile-15.ingress-core.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
bases:
22
- snippets/defaults.yaml
33
---
4+
bases:
5+
- snippets/defaults.gotmpl
6+
---
47
bases:
58
- snippets/env.gotmpl
69
---
@@ -43,6 +46,7 @@ releases:
4346
teamId: admin
4447
_derived: {{- toYaml $v._derived | nindent 10 }}
4548
teamIds: {{- toYaml (keys $v.teamConfig) | nindent 10 }}
49+
teamApps: {{- $tca.apps | toYaml | nindent 10 }}
4650
apps: {{- $a | toYaml | nindent 10 }}
4751
oidc: {{- $v.oidc | toYaml | nindent 10 }}
4852
cluster: {{- $v.cluster | toYaml | nindent 10 }}

helmfile.d/helmfile-60.teams.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
bases:
22
- snippets/defaults.yaml
33
---
4+
bases:
5+
- snippets/defaults.gotmpl
6+
---
47
bases:
58
- snippets/env.gotmpl
69
---
@@ -29,6 +32,7 @@ releases:
2932
{{- $prometheusDomain := printf "prometheus-%s.%s" $teamId $domain }}
3033
{{- $grafanaDomain := printf "grafana-%s.%s" $teamId $domain }}
3134
{{- $azure := $team | get "azure" dict }}
35+
{{- $teamApps := index $tc $teamId "apps" | default dict }}
3236
- name: tekton-dashboard-{{ $teamId }}
3337
installed: true
3438
namespace: team-{{ $teamId }}
@@ -39,6 +43,8 @@ releases:
3943
pipeline: otomi-task-teams
4044
values:
4145
- ../values/tekton-dashboard/tekton-dashboard-teams.gotmpl
46+
- resources:
47+
{{- $teamApps.tekton.resources.dashboard | toYaml | nindent 10 }}
4248
- name: prometheus-{{ $teamId }}
4349
installed: {{ or ($team | get "managedMonitoring.grafana" false) ($team | get "managedMonitoring.alertmanager" false) }}
4450
namespace: team-{{ $teamId }}
@@ -62,6 +68,8 @@ releases:
6268
sidecar.istio.io/inject: "true"
6369
labels:
6470
prometheus: system
71+
resources:
72+
{{- $teamApps.alertmanager.resources | toYaml | nindent 14 }}
6573
# to do: load slackTpl and opsgenieTpl only if alerts.receicers = true
6674
config: {{- tpl (readFile "../helmfile.d/snippets/alertmanager-teams.gotmpl") (dict "instance" $team "root" $v "slackTpl" $slackTpl "opsgenieTpl" $opsgenieTpl) | nindent 12 }}
6775
defaultRules:
@@ -74,6 +82,8 @@ releases:
7482
prometheusSpec: {}
7583
grafana:
7684
enabled: {{ $team | get "managedMonitoring.grafana" false }}
85+
resources:
86+
{{- $teamApps.grafana.resources.grafana | toYaml | nindent 12 }}
7787
namespaceOverride: null # team-{{ $teamId }}
7888
nameOverride: {{ $teamId }}-po-grafana
7989
fullnameOverride: {{ $teamId }}-po-grafana
@@ -96,6 +106,8 @@ releases:
96106
enabled: true
97107
label: release
98108
labelValue: grafana-dashboards-{{ $teamId }}
109+
resources:
110+
{{- $teamApps.grafana.resources.sidecar | toYaml | nindent 14 }}
99111
additionalDataSources:
100112
- name: Prometheus-platform
101113
editable: false
@@ -242,11 +254,12 @@ releases:
242254
tlsSecretName: {{ $v._derived.tlsSecretName }}
243255
- {{- omit $team "apps" | toYaml | nindent 8 }}
244256
teamId: {{ $teamId }}
257+
teamApps: {{- toYaml $teamApps | nindent 10 }}
245258
teamIds: {{- toYaml (keys $v.teamConfig) | nindent 10 }}
246259
- services: {{- concat $coreTeamServices $teamServices | toYaml | nindent 10 }}
247260
{{- if (gt (len $teamServices) 0) }}
248261
- name: blackbox
249262
svc: prometheus-blackbox-exporter
250263
port: 9115
251264
{{- end }}
252-
{{- end }}
265+
{{- end }}

helmfile.d/snippets/defaults.gotmpl

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{{- /* Only dynamic defauts */}}
2+
{{- $ENV_DIR := env "ENV_DIR" | default "../env" }}
3+
{{- $t := readFile (print $ENV_DIR "/env/teams.yaml") | fromYaml }}
4+
{{- if not (hasKey $t "teamConfig") }}{{ $_ := set $t "teamConfig" dict }}{{ end }}
5+
{{- $teams := keys $t.teamConfig}}
6+
7+
environments:
8+
default:
9+
values:
10+
- teamConfig:
11+
{{- range $team := $teams }}
12+
{{ $team }}:
13+
apps:
14+
alertmanager:
15+
resources:
16+
limits:
17+
cpu: 200m
18+
memory: 256Mi
19+
requests:
20+
cpu: 10m
21+
memory: 64Mi
22+
grafana:
23+
resources:
24+
grafana:
25+
limits:
26+
cpu: "1"
27+
memory: 1Gi
28+
requests:
29+
cpu: 10m
30+
memory: 128Mi
31+
sidecar:
32+
limits:
33+
cpu: 500m
34+
memory: 256Mi
35+
requests:
36+
cpu: 10m
37+
memory: 128Mi
38+
tekton:
39+
resources:
40+
dashboard:
41+
limits:
42+
cpu: 100m
43+
memory: 128Mi
44+
requests:
45+
cpu: 10m
46+
memory: 64Mi
47+
buildpacksTask:
48+
limits:
49+
cpu: "2"
50+
memory: 2Gi
51+
requests:
52+
cpu: 500m
53+
memory: 512Mi
54+
gitCloneTask:
55+
limits:
56+
cpu: "2"
57+
memory: 2Gi
58+
requests:
59+
cpu: 500m
60+
memory: 512Mi
61+
grypeTask:
62+
limits:
63+
cpu: "2"
64+
memory: 2Gi
65+
requests:
66+
cpu: 500m
67+
memory: 512Mi
68+
kanikoTask:
69+
limits:
70+
cpu: "2"
71+
memory: 2Gi
72+
requests:
73+
cpu: 500m
74+
memory: 512Mi
75+
managedMonitoring:
76+
grafana: true
77+
alertmanager: false
78+
{{- end }}

helmfile.d/snippets/env.gotmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ environments:
4444
- {{ $database }}
4545
{{- end }}{{ end }}
4646
{{- range $team := $teams }}
47-
{{- range $type := list "services" "netpols" "jobs" "workloads" "backups" "builds" "policies" "sealedsecrets"}}
47+
{{- range $type := list "services" "netpols" "jobs" "workloads" "backups" "builds" "policies" "sealedsecrets" "apps"}}
4848
{{- if eq (exec "bash" (list "-c" (printf "( test -f $ENV_DIR/env/teams/%s.%s.yaml && echo 'true' ) || echo 'false'" $type $team)) | trim) "true" }}
4949
- {{ $ENV_DIR }}/env/teams/{{ $type }}.{{ $team }}.yaml
5050
{{- end }}
@@ -63,4 +63,4 @@ environments:
6363
{{- end }}
6464
{{- range $app := $appsSecret }}{{ if ne $app "" }}{{ $file := $app | replace (print $ENV_DIR "/env/apps/") "" }}
6565
- {{ $ENV_DIR }}/env/apps/{{ $file }}{{ $ext }}
66-
{{- end }}{{ end }}
66+
{{- end }}{{ end }}

helmfile.tpl/helmfile-dump-all.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
bases:
33
- ../helmfile.d/snippets/defaults.yaml
44
---
5+
bases:
6+
- ../helmfile.d/snippets/defaults.gotmpl
7+
---
58
bases:
69
- ../helmfile.d/snippets/env.gotmpl
710
---

helmfile.tpl/helmfile-dump-defaults.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
bases:
33
- ../helmfile.d/snippets/defaults.yaml
44
---
5+
bases:
6+
- ../helmfile.d/snippets/defaults.gotmpl
7+
---
58
bases:
69
- ../helmfile.d/snippets/env.gotmpl
710
---

tests/bootstrap/input.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,76 @@ users:
1515
isPlatformAdmin: false
1616
isTeamAdmin: false
1717
teams: ['demo']
18+
teamConfig:
19+
demo:
20+
password: somesecretvalue
21+
id: demo
22+
selfService:
23+
service:
24+
- ingress
25+
networkPolicy:
26+
egressPublic: true
27+
ingressPrivate: true
28+
builds:
29+
- name: nodejs-hello-world
30+
tag: v0.0.1
31+
trigger: false
32+
mode:
33+
docker:
34+
repoUrl: https://github.com/redkubes/nodejs-helloworld
35+
revision: HEAD
36+
path: ./Docker
37+
type: docker
38+
- name: demo-java-maven
39+
tag: v0.0.1
40+
trigger: false
41+
mode:
42+
buildpacks:
43+
repoUrl: https://github.com/buildpacks/samples
44+
revision: HEAD
45+
path: apps/java-maven
46+
type: buildpacks
47+
- name: demo-java-trigger
48+
tag: v_0_0_1
49+
trigger: true
50+
mode:
51+
docker:
52+
repoUrl: https://github.com/buildpacks/samples
53+
revision: HEAD
54+
path: ./Docker
55+
type: docker
56+
services:
57+
- headers:
58+
response:
59+
set: []
60+
id: 78595314-cdaf-4b60-acc2-3b1a7f80fe2b
61+
ingressClassName: platform
62+
name: httpbin
63+
ownHost: true
64+
port: 80
65+
type: public
66+
- id: a106eb22-8c06-41b6-ab15-97aafb0888b5
67+
ingressClassName: platform
68+
name: nginx-deployment
69+
ownHost: true
70+
paths: []
71+
port: 80
72+
type: public
73+
- id: 91f6af98-ad8e-4111-b916-cf1b5bdcafb0
74+
ingressClassName: platform
75+
ksvc:
76+
predeployed: true
77+
name: nginx-ksvc
78+
ownHost: true
79+
paths: []
80+
port: 80
81+
type: public
82+
workloads:
83+
- name: nodejs-helloworld
84+
url: https://github.com/redkubes/nodejs-helloworld.git
85+
path: ./
86+
revision: HEAD
87+
- name: httpbin
88+
path: charts/httpbin
89+
revision: HEAD
90+
url: https://github.com/linode/apl-core.git

0 commit comments

Comments
 (0)