Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom resource config for teams #1776

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions charts/team-ns/templates/tekton-tasks/buildpacks.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $v := .Values | merge (dict) }}
{{- $custom := dig "resources" "buildpacksTask" "enabled" false $v }}
apiVersion: tekton.dev/v1
kind: Task
metadata:
Expand Down Expand Up @@ -86,12 +88,16 @@ spec:
- name: CNB_PLATFORM_API
value: "0.9"
computeResources:
{{- if $custom }}
{{- $v.resources.buildpacksTask.resources | toYaml | nindent 6 }}
{{- else }}
limits:
cpu: "2"
memory: 2Gi
requests:
cpu: 500m
memory: 512Mi
{{- end }}
steps:
- name: prepare
computeResources: {}
Expand Down
6 changes: 6 additions & 0 deletions charts/team-ns/templates/tekton-tasks/git-clone.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $v := .Values | merge (dict) }}
{{- $custom := dig "resources" "gitcloneTask" "enabled" false $v }}
apiVersion: tekton.dev/v1
kind: Task
metadata:
Expand All @@ -13,12 +15,16 @@ metadata:
spec:
stepTemplate:
computeResources:
{{- if $custom }}
{{- $v.resources.gitcloneTask.resources | toYaml | nindent 6 }}
{{- else }}
limits:
cpu: "2"
memory: 2Gi
requests:
cpu: 500m
memory: 512Mi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we maybe want to set these defaults lower? I think its pretty high for a simple git-clone task

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because we want to provide a good initial user experience

{{- end }}
description: >-
These Tasks are Git tasks to work with repositories used by other tasks
in your Pipeline.
Expand Down
6 changes: 6 additions & 0 deletions charts/team-ns/templates/tekton-tasks/grype.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $v := .Values | merge (dict) }}
{{- $custom := dig "resources" "grypeTask" "enabled" false $v }}
apiVersion: tekton.dev/v1
kind: Task
metadata:
Expand All @@ -13,12 +15,16 @@ metadata:
spec:
stepTemplate:
computeResources:
{{- if $custom }}
{{- $v.resources.grypeTask.resources | toYaml | nindent 6 }}
{{- else }}
limits:
cpu: "2"
memory: 2Gi
requests:
cpu: 500m
memory: 512Mi
{{- end }}
description: >-
A vulnerability scanner for container images and filesystems.
Works with Syft, the powerful SBOM (software bill of materials) tool for container images and filesystems.
Expand Down
6 changes: 6 additions & 0 deletions charts/team-ns/templates/tekton-tasks/kaniko.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $v := .Values | merge (dict) }}
{{- $custom := dig "resources" "kanikoTask" "enabled" false $v }}
apiVersion: tekton.dev/v1
kind: Task
metadata:
Expand All @@ -13,12 +15,16 @@ metadata:
spec:
stepTemplate:
computeResources:
{{- if $custom }}
{{- $v.resources.grypeTask.resources | toYaml | nindent 6 }}
srodenhuis marked this conversation as resolved.
Show resolved Hide resolved
{{- else }}
limits:
cpu: "2"
memory: 2Gi
requests:
cpu: 500m
memory: 512Mi
{{- end }}
description: >-
This Task builds a simple Dockerfile with kaniko and pushes to a registry.
This Task stores the image name and digest as results, allowing Tekton Chains to pick up
Expand Down
43 changes: 43 additions & 0 deletions helmfile.d/helmfile-60.teams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ releases:
{{- $prometheusDomain := printf "prometheus-%s.%s" $teamId $domain }}
{{- $grafanaDomain := printf "grafana-%s.%s" $teamId $domain }}
{{- $azure := $team | get "azure" dict }}
{{- $customTektonDashboardResources := ($team | get "resources.tektonDashboard.enabled" false) }}
{{- $customAlertmanagerResources := ($team | get "resources.alertmanager.enabled" false) }}
{{- $customGrafanaResources := ($team | get "resources.grafana.enabled" false) }}
{{- $customGrafanaSidecarResources := ($team | get "resources.grafanaSidecar.enabled" false) }}
- name: tekton-dashboard-{{ $teamId }}
installed: true
namespace: team-{{ $teamId }}
Expand All @@ -39,6 +43,12 @@ releases:
pipeline: otomi-task-teams
values:
- ../values/tekton-dashboard/tekton-dashboard-teams.gotmpl
- resources:
{{- if $customTektonDashboardResources }}
{{- $team.resources.tektonDashboard.resources | toYaml | nindent 10 }}
{{- else }}
{{- $v.apps.tekton.resources.dashboard | toYaml | nindent 10 }}
{{- end }}
- name: prometheus-{{ $teamId }}
installed: {{ or ($team | get "managedMonitoring.grafana" false) ($team | get "managedMonitoring.alertmanager" false) }}
namespace: team-{{ $teamId }}
Expand All @@ -62,6 +72,17 @@ releases:
sidecar.istio.io/inject: "true"
labels:
prometheus: system
resources:
{{- if $customAlertmanagerResources }}
{{- $team.resources.alertmanager.resources | toYaml | nindent 14 }}
{{- else }}
requests:
cpu: 10m
memory: 64Mi
limits:
cpu: 200m
memory: 256Mi
{{- end }}
# 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:
Expand All @@ -74,6 +95,17 @@ releases:
prometheusSpec: {}
grafana:
enabled: {{ $team | get "managedMonitoring.grafana" false }}
resources:
{{- if $customGrafanaResources }}
{{- $team.resources.grafana.resources | toYaml | nindent 12 }}
{{- else }}
requests:
cpu: 10m
memory: 128Mi
limits:
cpu: "1"
memory: 1Gi
{{- end }}
namespaceOverride: null # team-{{ $teamId }}
nameOverride: {{ $teamId }}-po-grafana
fullnameOverride: {{ $teamId }}-po-grafana
Expand All @@ -89,6 +121,17 @@ releases:
enabled: true
label: release
labelValue: grafana-dashboards-{{ $teamId }}
resources:
{{- if $customGrafanaSidecarResources }}
{{- $team.resources.grafanaSidecar.resources | toYaml | nindent 14 }}
{{- else }}
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 10m
memory: 128Mi
{{- end }}
additionalDataSources:
- name: Prometheus-platform
editable: false
Expand Down
62 changes: 59 additions & 3 deletions values-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,65 @@ definitions:
resourceQuota:
description: 'List of kubernetes resource quota. Should adhere to the "spec.hard" format as described here: https://kubernetes.io/docs/concepts/policy/resource-quotas/. Not validated as there is no schema published. Change at your own risk.'
type: object
resources:
additionalProperties: false
properties:
alertmanager:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
grafana:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
grafanaSidecar:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
buildpacksTask:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
gitcloneTask:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
grypeTask:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
kanikoTask:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
tektonDashboard:
properties:
enabled:
type: boolean
default: false
resources:
$ref: '#/definitions/resources'
selfService:
$ref: '#/definitions/teamSelfService'
services:
Expand All @@ -1133,9 +1192,6 @@ definitions:
description: Activate managed Grafana, Prometheus or Alertmanager instances
srodenhuis marked this conversation as resolved.
Show resolved Hide resolved
properties:
grafana:
type: boolean
default: true
prometheus:
type: boolean
default: false
alertmanager:
Expand Down
27 changes: 0 additions & 27 deletions values/prometheus-operator/prometheus-operator-team.gotmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{{- $v := .Values }}
{{- $a := $v.apps | get "alertmanager" }}
{{- $g := $v.apps | get "grafana" }}

kubeApiServer:
enabled: false
coreDns:
Expand Down Expand Up @@ -60,33 +56,10 @@ grafana:
defaultDashboardsEnabled: false
assertNoLeakedSecrets: false
plugins: []
resources:
requests:
cpu: 10m
memory: 128Mi
limits:
cpu: "1"
memory: 1Gi
sidecar:
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 10m
memory: 128Mi

alertmanager:
serviceMonitor:
selfMonitor: false
alertmanagerSpec:
resources:
requests:
cpu: 10m
memory: 64Mi
limits:
cpu: 200m
memory: 256Mi

prometheus:
thanosService:
Expand Down
3 changes: 1 addition & 2 deletions values/tekton-dashboard/tekton-dashboard-teams.gotmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{{- $teamId := .Release.Labels.team }}
{{- $v := .Values }}
{{- $t := $v.apps.tekton }}

resources: {{- $t.resources.dashboard | toYaml | nindent 2 }}
{{- $custom := dig "resources" "tektonDashboard" "enabled" false $v }}

teamId: {{ $teamId }}

Expand Down