From 0873144d0baafaa910a7dc93ca8bc0f1f4efa375 Mon Sep 17 00:00:00 2001 From: Cas Lubbers Date: Fri, 22 Nov 2024 13:23:14 +0100 Subject: [PATCH] feat: add resources for team alertmanager and grafana --- helmfile.d/helmfile-60.teams.yaml | 8 +++ helmfile.d/snippets/defaults.gotmpl | 31 +++++++++ package.json | 2 +- tests/bootstrap/input.yaml | 63 +++++++++++++++++++ values-schema.yaml | 18 +++++- .../tekton-dashboard-teams.gotmpl | 5 +- 6 files changed, 121 insertions(+), 6 deletions(-) diff --git a/helmfile.d/helmfile-60.teams.yaml b/helmfile.d/helmfile-60.teams.yaml index 33a5d566fe..5727d96c68 100644 --- a/helmfile.d/helmfile-60.teams.yaml +++ b/helmfile.d/helmfile-60.teams.yaml @@ -43,6 +43,8 @@ releases: pipeline: otomi-task-teams values: - ../values/tekton-dashboard/tekton-dashboard-teams.gotmpl + - resources: + {{- $teamApps.tekton.resources.dashboard | toYaml | nindent 10 }} - name: prometheus-{{ $teamId }} installed: {{ or ($team | get "managedMonitoring.grafana" false) ($team | get "managedMonitoring.alertmanager" false) }} namespace: team-{{ $teamId }} @@ -66,6 +68,8 @@ releases: sidecar.istio.io/inject: "true" labels: prometheus: system + resources: + {{- $teamApps.alertmanager.resources | toYaml | nindent 14 }} # to do: load slackTpl and opsgenieTpl only if alerts.receicers = true config: {{- tpl (readFile "../helmfile.d/snippets/alertmanager-teams.gotmpl") (dict "instance" $team "root" $v "slackTpl" $slackTpl "opsgenieTpl" $opsgenieTpl) | nindent 12 }} defaultRules: @@ -78,6 +82,8 @@ releases: prometheusSpec: {} grafana: enabled: {{ $team | get "managedMonitoring.grafana" false }} + resources: + {{- $teamApps.grafana.resources.grafana | toYaml | nindent 12 }} namespaceOverride: null # team-{{ $teamId }} nameOverride: {{ $teamId }}-po-grafana fullnameOverride: {{ $teamId }}-po-grafana @@ -100,6 +106,8 @@ releases: enabled: true label: release labelValue: grafana-dashboards-{{ $teamId }} + resources: + {{- $teamApps.grafana.resources.sidecar | toYaml | nindent 14 }} additionalDataSources: - name: Prometheus-platform editable: false diff --git a/helmfile.d/snippets/defaults.gotmpl b/helmfile.d/snippets/defaults.gotmpl index 4b66083032..4f4d09ea4e 100644 --- a/helmfile.d/snippets/defaults.gotmpl +++ b/helmfile.d/snippets/defaults.gotmpl @@ -11,8 +11,39 @@ environments: {{- range $team := $teams }} {{ $team }}: apps: + alertmanager: + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 10m + memory: 64Mi + grafana: + resources: + grafana: + limits: + cpu: "1" + memory: 1Gi + requests: + cpu: 10m + memory: 128Mi + sidecar: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 10m + memory: 128Mi tekton: resources: + dashboard: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 10m + memory: 64Mi buildpacksTask: limits: cpu: "2" diff --git a/package.json b/package.json index cca61c7b4f..80c2e560f2 100644 --- a/package.json +++ b/package.json @@ -159,7 +159,7 @@ "validate-templates:all": "set -e; i=28; while [ $i -le 31 ]; do NODE_ENV=test binzx/otomi validate-templates -k 1.$i; i=$(($i+1)); done", "validate-values": "ENV_DIR=$PWD/tests/fixtures NODE_ENV=test binzx/otomi validate-values", "bootstrap-dev": "rm -rf /tmp/otomi-bootstrap-dev; CI=1 VALUES_INPUT=$PWD/tests/bootstrap/input.yaml ENV_DIR=/tmp/otomi-bootstrap-dev binzx/otomi bootstrap", - "bootstrap-dev-with-repo": "CI=1 ENV_DIR=/tmp/otomi-bootstrap-dev binzx/otomi bootstrap" + "bootstrap-dev-with-repo": "CI=1 ENV_DIR=/tmp/otomi-bootstrap-dev VALUES_INPUT=$PWD/tests/bootstrap/input.yaml binzx/otomi bootstrap" }, "standard-version": { "skip": { diff --git a/tests/bootstrap/input.yaml b/tests/bootstrap/input.yaml index d57fd75500..791329f705 100644 --- a/tests/bootstrap/input.yaml +++ b/tests/bootstrap/input.yaml @@ -25,3 +25,66 @@ teamConfig: networkPolicy: egressPublic: true ingressPrivate: true + builds: + - name: nodejs-hello-world + tag: v0.0.1 + trigger: false + mode: + docker: + repoUrl: https://github.com/redkubes/nodejs-helloworld + revision: HEAD + path: ./Docker + type: docker + - name: demo-java-maven + tag: v0.0.1 + trigger: false + mode: + buildpacks: + repoUrl: https://github.com/buildpacks/samples + revision: HEAD + path: apps/java-maven + type: buildpacks + - name: demo-java-trigger + tag: v_0_0_1 + trigger: true + mode: + docker: + repoUrl: https://github.com/buildpacks/samples + revision: HEAD + path: ./Docker + type: docker + services: + - headers: + response: + set: [] + id: 78595314-cdaf-4b60-acc2-3b1a7f80fe2b + ingressClassName: platform + name: httpbin + ownHost: true + port: 80 + type: public + - id: a106eb22-8c06-41b6-ab15-97aafb0888b5 + ingressClassName: platform + name: nginx-deployment + ownHost: true + paths: [] + port: 80 + type: public + - id: 91f6af98-ad8e-4111-b916-cf1b5bdcafb0 + ingressClassName: platform + ksvc: + predeployed: true + name: nginx-ksvc + ownHost: true + paths: [] + port: 80 + type: public + workloads: + - name: nodejs-helloworld + url: https://github.com/redkubes/nodejs-helloworld.git + path: ./ + revision: HEAD + - name: httpbin + path: charts/httpbin + revision: HEAD + url: https://github.com/linode/apl-core.git diff --git a/values-schema.yaml b/values-schema.yaml index 17125a71d6..73d9384f53 100644 --- a/values-schema.yaml +++ b/values-schema.yaml @@ -1087,14 +1087,28 @@ definitions: $ref: '#/definitions/alerts' apps: additionalProperties: true + alertmanager: + additionalProperties: false + properties: + resources: + $ref: '#/definitions/resources' + grafana: + additionalProperties: false + properties: + additionalProperties: false + properties: + grafana: + $ref: '#/definitions/resources' + sidecar: + $ref: '#/definitions/resources' tekton: additionalProperties: false properties: - _rawValues: - $ref: '#/definitions/rawValues' resources: additionalProperties: false properties: + dashboard: + $ref: '#/definitions/resources' buildpacksTask: $ref: '#/definitions/resources' gitCloneTask: diff --git a/values/tekton-dashboard/tekton-dashboard-teams.gotmpl b/values/tekton-dashboard/tekton-dashboard-teams.gotmpl index 5b58683648..8756e04ba9 100644 --- a/values/tekton-dashboard/tekton-dashboard-teams.gotmpl +++ b/values/tekton-dashboard/tekton-dashboard-teams.gotmpl @@ -1,8 +1,7 @@ {{- $teamId := .Release.Labels.team }} {{- $v := .Values }} {{- $t := $v.apps.tekton }} - -resources: {{- $t.resources.dashboard | toYaml | nindent 2 }} +{{- $custom := dig "resources" "dashboard" "enabled" false $v }} teamId: {{ $teamId }} @@ -17,4 +16,4 @@ args: - --namespace=team-{{ $teamId }} - --namespaces=team-{{ $teamId }} - --stream-logs=true - - --external-logs= \ No newline at end of file + - --external-logs=