From 17bcc630b324b760c02e442503fdf7e8b5e6e17e Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Mon, 26 Oct 2020 16:34:48 -0500 Subject: [PATCH] feat(chart): adds tekton-dashboard chart This introduces the tekton-dashboard [0] as chart into the repository. [0] https://github.com/tektoncd/dashboard Change-Id: I43156eb5fd67a15fc24092ad03b62215bcbf2386 Signed-off-by: Tin Lam --- charts/tekton-dashboard/.helmignore | 22 ++++ charts/tekton-dashboard/Chart.yaml | 14 +++ .../crds/crd_extension-dashboard.yaml | 47 +++++++ .../clusterrole_backend-dashboard.yaml | 70 +++++++++++ .../clusterrole_dashboard-dashboard.yaml | 17 +++ .../clusterrole_extensions-dashboard.yaml | 14 +++ .../clusterrole_pipelines-dashboard.yaml | 17 +++ .../clusterrole_tenant-dashboard.yaml | 116 +++++++++++++++++ .../clusterrole_triggers-dashboard.yaml | 17 +++ .../clusterrolebinding_backend-dashboard.yaml | 18 +++ ...usterrolebinding_extensions-dashboard.yaml | 17 +++ .../clusterrolebinding_tenant-dashboard.yaml | 18 +++ .../templates/deployment-dashboard.yaml | 71 +++++++++++ .../templates/helpers/_label.tpl | 61 +++++++++ .../templates/helpers/_pod.tpl | 21 ++++ .../templates/helpers/_template.tpl | 107 ++++++++++++++++ .../rolebinding_dashboard-dashboard.yaml | 19 +++ .../rolebinding_pipelines-dashboard.yaml | 19 +++ .../rolebinding_triggers-dashboard.yaml | 19 +++ .../templates/service-dashboard.yaml | 17 +++ .../templates/serviceaccount-dashboard.yaml | 11 ++ charts/tekton-dashboard/values.schema.json | 117 ++++++++++++++++++ charts/tekton-dashboard/values.yaml | 35 ++++++ 23 files changed, 884 insertions(+) create mode 100644 charts/tekton-dashboard/.helmignore create mode 100644 charts/tekton-dashboard/Chart.yaml create mode 100644 charts/tekton-dashboard/crds/crd_extension-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrole_backend-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrole_dashboard-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrole_extensions-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrole_pipelines-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrole_tenant-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrole_triggers-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrolebinding_backend-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrolebinding_extensions-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/clusterrolebinding_tenant-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/deployment-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/helpers/_label.tpl create mode 100644 charts/tekton-dashboard/templates/helpers/_pod.tpl create mode 100644 charts/tekton-dashboard/templates/helpers/_template.tpl create mode 100644 charts/tekton-dashboard/templates/rolebinding_dashboard-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/rolebinding_pipelines-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/rolebinding_triggers-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/service-dashboard.yaml create mode 100644 charts/tekton-dashboard/templates/serviceaccount-dashboard.yaml create mode 100644 charts/tekton-dashboard/values.schema.json create mode 100644 charts/tekton-dashboard/values.yaml diff --git a/charts/tekton-dashboard/.helmignore b/charts/tekton-dashboard/.helmignore new file mode 100644 index 00000000..50af0317 --- /dev/null +++ b/charts/tekton-dashboard/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/tekton-dashboard/Chart.yaml b/charts/tekton-dashboard/Chart.yaml new file mode 100644 index 00000000..a44811e5 --- /dev/null +++ b/charts/tekton-dashboard/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +appVersion: v0.10.1 +description: Tekton Dashboard +name: tekton-dashboard +version: 0.1.0 +icon: https://tekton.dev/images/tekton-horizontal-color.png +home: https://github.com/tektoncd/dashboard +keywords: + - helm + - tekton + - tektoncd + - dashboard +description: | + This chart bootstraps installation of [tekton dashboard](https://github.com/tektoncd/dashboard). diff --git a/charts/tekton-dashboard/crds/crd_extension-dashboard.yaml b/charts/tekton-dashboard/crds/crd_extension-dashboard.yaml new file mode 100644 index 00000000..aa8eaab1 --- /dev/null +++ b/charts/tekton-dashboard/crds/crd_extension-dashboard.yaml @@ -0,0 +1,47 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: extensions.dashboard.tekton.dev + labels: + app.kubernetes.io/component: tekton + app.kubernetes.io/name: extensions + app.kubernetes.io/part-of: tekton-dashboard +spec: + group: dashboard.tekton.dev + names: + categories: + - tekton + - tekton-dashboard + kind: Extension + plural: extensions + singular: extension + shortNames: + - ext + - exts + preserveUnknownFields: false + scope: Namespaced + versions: + - name: v1alpha1 + served: true + storage: true + additionalPrinterColumns: + - jsonPath: .spec.apiVersion + name: API version + type: string + - jsonPath: .spec.name + name: Kind + type: string + - jsonPath: .spec.displayname + name: Display name + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + schema: + openAPIV3Schema: + type: object + x-kubernetes-preserve-unknown-fields: true + subresources: + status: {} +... diff --git a/charts/tekton-dashboard/templates/clusterrole_backend-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrole_backend-dashboard.yaml new file mode 100644 index 00000000..270b26fd --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrole_backend-dashboard.yaml @@ -0,0 +1,70 @@ +{{- define "clusterrole_backend-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-backend +rules: + - apiGroups: + - apiextensions.k8s.io + resources: + - customresourcedefinitions + verbs: + - get + - list + - apiGroups: + - security.openshift.io + resources: + - securitycontextconstraints + verbs: + - use + - apiGroups: + - tekton.dev + resources: + - clustertasks + - clustertasks/status + verbs: + - get + - list + - watch + - apiGroups: + - triggers.tekton.dev + resources: + - clustertriggerbindings + verbs: + - get + - list + - watch + - apiGroups: + - dashboard.tekton.dev + resources: + - extensions + verbs: + - create + - update + - delete + - patch + - apiGroups: + - tekton.dev + resources: + - clustertasks + - clustertasks/status + verbs: + - create + - update + - delete + - patch + - apiGroups: + - triggers.tekton.dev + resources: + - clustertriggerbindings + verbs: + - create + - update + - delete + - patch + - add +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrole_backend-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrole_dashboard-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrole_dashboard-dashboard.yaml new file mode 100644 index 00000000..bec97f18 --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrole_dashboard-dashboard.yaml @@ -0,0 +1,17 @@ +{{- define "clusterrole_dashboard-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-dashboard +rules: + - apiGroups: + - apps + resources: + - deployments + verbs: + - list +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrole_dashboard-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrole_extensions-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrole_extensions-dashboard.yaml new file mode 100644 index 00000000..a4d41925 --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrole_extensions-dashboard.yaml @@ -0,0 +1,14 @@ +{{- define "clusterrole_extensions-dashboard" -}} +--- +aggregationRule: + clusterRoleSelectors: + - matchLabels: + rbac.dashboard.tekton.dev/aggregate-to-dashboard: "true" +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-extensions +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrole_extensions-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrole_pipelines-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrole_pipelines-dashboard.yaml new file mode 100644 index 00000000..8aaaff74 --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrole_pipelines-dashboard.yaml @@ -0,0 +1,17 @@ +{{- define "clusterrole_pipelines-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-pipelines +rules: + - apiGroups: + - apps + resources: + - deployments + verbs: + - list +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrole_pipelines-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrole_tenant-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrole_tenant-dashboard.yaml new file mode 100644 index 00000000..90c4c4c1 --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrole_tenant-dashboard.yaml @@ -0,0 +1,116 @@ +{{- define "clusterrole_tenant-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-tenant +rules: + - apiGroups: + - "" + resources: + - services + verbs: + - get + - list + - watch + - apiGroups: + - dashboard.tekton.dev + resources: + - extensions + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - serviceaccounts + - pods/log + - namespaces + verbs: + - get + - list + - watch + - apiGroups: + - tekton.dev + resources: + - tasks + - taskruns + - pipelines + - pipelineruns + - pipelineresources + - conditions + - tasks/status + - taskruns/status + - pipelines/status + - pipelineruns/status + - taskruns/finalizers + - pipelineruns/finalizers + verbs: + - get + - list + - watch + - apiGroups: + - triggers.tekton.dev + resources: + - eventlisteners + - triggerbindings + - triggertemplates + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - serviceaccounts + verbs: + - update + - patch + - apiGroups: + - "" + resources: + - secrets + verbs: + - get + - list + - watch + - create + - update + - delete + - apiGroups: + - tekton.dev + resources: + - tasks + - taskruns + - pipelines + - pipelineruns + - pipelineresources + - conditions + - taskruns/finalizers + - pipelineruns/finalizers + - tasks/status + - taskruns/status + - pipelines/status + - pipelineruns/status + verbs: + - create + - update + - delete + - patch + - apiGroups: + - triggers.tekton.dev + resources: + - eventlisteners + - triggerbindings + - triggertemplates + verbs: + - create + - update + - delete + - patch + - add +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrole_tenant-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrole_triggers-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrole_triggers-dashboard.yaml new file mode 100644 index 00000000..99cfdbfe --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrole_triggers-dashboard.yaml @@ -0,0 +1,17 @@ +{{- define "clusterrole_triggers-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-triggers +rules: + - apiGroups: + - apps + resources: + - deployments + verbs: + - list +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrole_triggers-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrolebinding_backend-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrolebinding_backend-dashboard.yaml new file mode 100644 index 00000000..2bdb452c --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrolebinding_backend-dashboard.yaml @@ -0,0 +1,18 @@ +{{- define "clusterrolebinding_backend-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-backend +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: tekton-dashboard-backend +subjects: + - kind: ServiceAccount + name: tekton-dashboard + namespace: {{ $.Release.Namespace }} +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrolebinding_backend-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrolebinding_extensions-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrolebinding_extensions-dashboard.yaml new file mode 100644 index 00000000..6fa366d8 --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrolebinding_extensions-dashboard.yaml @@ -0,0 +1,17 @@ +{{- define "clusterrolebinding_extensions-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-extensions +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: tekton-dashboard-extensions +subjects: + - kind: ServiceAccount + name: tekton-dashboard + namespace: {{ $.Release.Namespace }} +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrolebinding_extensions-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/clusterrolebinding_tenant-dashboard.yaml b/charts/tekton-dashboard/templates/clusterrolebinding_tenant-dashboard.yaml new file mode 100644 index 00000000..951fe3dc --- /dev/null +++ b/charts/tekton-dashboard/templates/clusterrolebinding_tenant-dashboard.yaml @@ -0,0 +1,18 @@ +{{- define "clusterrolebinding_tenant-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-tenant +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: tekton-dashboard-tenant +subjects: + - kind: ServiceAccount + name: tekton-dashboard + namespace: {{ $.Release.Namespace }} +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "clusterrolebinding_tenant-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/deployment-dashboard.yaml b/charts/tekton-dashboard/templates/deployment-dashboard.yaml new file mode 100644 index 00000000..67edd734 --- /dev/null +++ b/charts/tekton-dashboard/templates/deployment-dashboard.yaml @@ -0,0 +1,71 @@ +{{- define "deployment-dashboard" -}} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "helpers.labels.fullname" $ }} + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "dashboard") | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: {{- include "helpers.labels.matchLabels" (dict "Global" $) | nindent 6 }} + revisionHistoryLimit: 3 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 3 + template: + metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "dashboard") | nindent 8 }} + spec: + serviceAccountName: {{ template "helpers.labels.fullname" . }} + securityContext: + runAsNonRoot: true + runAsUser: 65532 + nodeSelector: {{- include "helpers.pod.node_selector" ( dict "Global" $ "Application" "tekton_dashboard" ) | nindent 8 }} + terminationGracePeriodSeconds: 30 + containers: + - name: tekton-dashboard + image: {{ include "helpers.pod.container.image" ( dict "Global" $ "Application" "tekton_dashboard" ) }} + imagePullPolicy: {{ $.Values.images.pull.policy | quote }} + args: + - --port={{ $.Values.params.endpoints.ports.web.port }} + - --logout-url={{ $.Values.config.args.logout_url }} + - --pipelines-namespace={{ $.Release.Namespace }} + - --triggers-namespace={{ $.Release.Namespace }} + - --read-only={{ $.Values.config.args.read_only }} + - --csrf-secure-cookie={{ $.Values.config.args.csrf_secure_cookie }} + - --log-level={{ $.Values.config.args.log_level }} + - --log-format={{ $.Values.config.args.log_format }} + - --namespace={{ $.Values.config.args.namespace }} + - --openshift={{ $.Values.config.args.openshift }} + - --stream-logs={{ $.Values.config.args.stream_logs }} + - --external-logs={{ $.Values.config.args.external_logs }} + env: + - name: INSTALLED_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + ports: + - name: web + containerPort: {{ $.Values.params.endpoints.ports.web.port }} + readinessProbe: + httpGet: + scheme: {{ $.Values.params.endpoints.ports.web.scheme | upper }} + path: /readiness + port: {{ $.Values.params.endpoints.ports.web.port }} + initialDelaySeconds: 15 + periodSeconds: 10 + livenessProbe: + httpGet: + scheme: {{ $.Values.params.endpoints.ports.web.scheme | upper }} + path: /health + port: {{ $.Values.params.endpoints.ports.web.port }} + initialDelaySeconds: 50 + periodSeconds: 20 + timeoutSeconds: 5 + volumes: [] +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "deployment-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/helpers/_label.tpl b/charts/tekton-dashboard/templates/helpers/_label.tpl new file mode 100644 index 00000000..5d45d179 --- /dev/null +++ b/charts/tekton-dashboard/templates/helpers/_label.tpl @@ -0,0 +1,61 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "helpers.labels.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "helpers.labels.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "helpers.labels.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Labels to use on {deploy|sts}.spec.selector.matchLabels and svc.spec.selector +*/}} +{{- define "helpers.labels.matchLabels" -}} +{{- $Global := index . "Global" -}} +app.kubernetes.io/name: {{ include "helpers.labels.name" $Global }} +app.kubernetes.io/instance: {{ $Global.Values.release_group | default $Global.Release.Name }} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "helpers.labels.labels" -}} +{{- $Global := index . "Global" -}} +{{- $PartOf := index . "PartOf" -}} +{{- $Component := index . "Component" -}} +{{- $Version := index . "Version" -}} +{{ include "helpers.labels.matchLabels" (dict "Global" $Global )}} +app.kubernetes.io/managed-by: {{ $Global.Release.Service }} +{{- if $PartOf }} +app.kubernetes.io/part-of: {{ $PartOf }} +{{- end }} +{{- if $Component }} +app.kubernetes.io/component: {{ $Component }} +{{- end }} +{{- if $Version }} +app.kubernetes.io/version: {{ $Version }} +{{- end }} +helm.sh/chart: {{ include "helpers.labels.chart" $Global }} +{{- end -}} diff --git a/charts/tekton-dashboard/templates/helpers/_pod.tpl b/charts/tekton-dashboard/templates/helpers/_pod.tpl new file mode 100644 index 00000000..add712ac --- /dev/null +++ b/charts/tekton-dashboard/templates/helpers/_pod.tpl @@ -0,0 +1,21 @@ +{{- define "helpers.pod.container.image" -}} + {{- $Global := index . "Global" -}} + {{- $Application := index . "Application" -}} + {{- with index $.Global.Values.images.applications $Application -}} + {{- printf "%s/%s:%s" .repo .name ( .tag | toString ) | quote -}} + {{- end -}} +{{- end -}} + +{{- define "helpers.pod.node_selector" -}} + {{- $Global := index . "Global" -}} + {{- $Application := index . "Application" -}} + {{- with index $.Global.Values.node_labels $Application -}} + {{- if kindIs "slice" . -}} + {{- range $k, $item := . }} +{{ $item.key }}: {{ $item.value | quote }} + {{- end }} + {{- else -}} +{{ .key }}: {{ .value | quote }} + {{- end }} + {{- end -}} +{{- end -}} diff --git a/charts/tekton-dashboard/templates/helpers/_template.tpl b/charts/tekton-dashboard/templates/helpers/_template.tpl new file mode 100644 index 00000000..b54f54e3 --- /dev/null +++ b/charts/tekton-dashboard/templates/helpers/_template.tpl @@ -0,0 +1,107 @@ +{{- define "helpers.template.overlay" -}} + {{- $local := dict -}} + {{/* + By default we merge lists with a 'name' key's values + */}} + {{- $_ := set $local "merge_same_named" true -}} + {{- if kindIs "map" $ -}} + {{- if hasKey $ "merge_same_named" -}} + {{- $_ := set $local "merge_same_named" $.merge_same_named -}} + {{- end -}} + {{- end -}} + {{- $_ := set $local "input" ( fromYaml ( toString ( include $.template_definition $.Global ) ) ) -}} + {{- $target := dict -}} + {{- $overlay_keys := regexSplit "-+" ( trimSuffix ".yaml" ( lower ( base $.Global.Template.Name ) ) ) 2 }} + {{- $_ := set $local "overlay" dict -}} + {{- if hasKey $.Global.Values.over_rides ( index $overlay_keys 0 ) -}} + {{- if hasKey ( index $.Global.Values.over_rides ( index $overlay_keys 0 ) ) ( index $overlay_keys 1 ) -}} + {{- $_ := set $local "overlay" ( index $.Global.Values.over_rides ( index $overlay_keys 0 ) ( index $overlay_keys 1 ) ) -}} + {{- end }} + {{- end }} + {{- range $item := tuple $local.input $local.overlay -}} + {{- $call := dict "target" $target "source" . "merge_same_named" $local.merge_same_named -}} + {{- $_ := include "helpers._merge" $call -}} + {{- $_ := set $local "result" $call.result -}} + {{- end -}} + {{- if kindIs "map" $ -}} + {{- $_ := set $ "result" $local.result -}} + {{- end -}} + {{ $target | toYaml }} +{{- end -}} + +{{- define "helpers._merge" -}} + {{- $local := dict -}} + {{- $_ := set $ "result" $.source -}} + {{/* + TODO: Should we `fail` when trying to merge a collection (map or slice) with + either a different kind of collection or a scalar? + */}} + {{- if and (kindIs "map" $.target) (kindIs "map" $.source) -}} + {{- range $key, $sourceValue := $.source -}} + {{- if not (hasKey $.target $key) -}} + {{- $_ := set $local "newTargetValue" $sourceValue -}} + {{- if kindIs "map" $sourceValue -}} + {{- $copy := dict -}} + {{- $call := dict "target" $copy "source" $sourceValue -}} + {{- $_ := include "helpers._merge.shallow" $call -}} + {{- $_ := set $local "newTargetValue" $copy -}} + {{- end -}} + {{- else -}} + {{- $targetValue := index $.target $key -}} + {{- $call := dict "target" $targetValue "source" $sourceValue "merge_same_named" $.merge_same_named -}} + {{- $_ := include "helpers._merge" $call -}} + {{- $_ := set $local "newTargetValue" $call.result -}} + {{- end -}} + {{- $_ := set $.target $key $local.newTargetValue -}} + {{- end -}} + {{- $_ := set $ "result" $.target -}} + {{- else if and (kindIs "slice" $.target) (kindIs "slice" $.source) -}} + {{- $call := dict "target" $.target "source" $.source -}} + {{- $_ := include "helpers._merge.append_slice" $call -}} + {{- if $.merge_same_named -}} + {{- $_ := set $local "result" list -}} + {{- $_ := set $local "named_items" dict -}} + {{- range $item := $call.result -}} + {{- $_ := set $local "has_name_key" false -}} + {{- if kindIs "map" $item -}} + {{- if hasKey $item "name" -}} + {{- $_ := set $local "has_name_key" true -}} + {{- end -}} + {{- end -}} + {{- if $local.has_name_key -}} + {{- if hasKey $local.named_items $item.name -}} + {{- $named_item := index $local.named_items $item.name -}} + {{- $call := dict "target" $named_item "source" $item "merge_same_named" $.merge_same_named -}} + {{- $_ := include "helpers._merge" $call -}} + {{- else -}} + {{- $copy := dict -}} + {{- $copy_call := dict "target" $copy "source" $item -}} + {{- $_ := include "helpers._merge.shallow" $copy_call -}} + {{- $_ := set $local.named_items $item.name $copy -}} + {{- $_ := set $local "result" (append $local.result $copy) -}} + {{- end -}} + {{- else -}} + {{- $_ := set $local "result" (append $local.result $item) -}} + {{- end -}} + {{- end -}} + {{- else -}} + {{- $_ := set $local "result" $call.result -}} + {{- end -}} + {{- $_ := set $ "result" (uniq $local.result) -}} + {{- end -}} +{{- end -}} + +{{- define "helpers._merge.shallow" -}} + {{- range $key, $value := $.source -}} + {{- $_ := set $.target $key $value -}} + {{- end -}} +{{- end -}} + +{{- define "helpers._merge.append_slice" -}} + {{- $local := dict -}} + {{- $_ := set $local "result" $.target -}} + {{- range $value := $.source -}} + {{- $_ := set $local "result" (append $local.result $value) -}} + {{- end -}} + {{- $_ := set $ "result" $local.result -}} +{{- end -}} diff --git a/charts/tekton-dashboard/templates/rolebinding_dashboard-dashboard.yaml b/charts/tekton-dashboard/templates/rolebinding_dashboard-dashboard.yaml new file mode 100644 index 00000000..9d14daac --- /dev/null +++ b/charts/tekton-dashboard/templates/rolebinding_dashboard-dashboard.yaml @@ -0,0 +1,19 @@ +{{- define "rolebinding_dashboard-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-dashboard + namespace: {{ $.Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: tekton-dashboard-dashboard +subjects: + - kind: ServiceAccount + name: tekton-dashboard + namespace: {{ $.Release.Namespace }} +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "rolebinding_dashboard-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/rolebinding_pipelines-dashboard.yaml b/charts/tekton-dashboard/templates/rolebinding_pipelines-dashboard.yaml new file mode 100644 index 00000000..16494ee4 --- /dev/null +++ b/charts/tekton-dashboard/templates/rolebinding_pipelines-dashboard.yaml @@ -0,0 +1,19 @@ +{{- define "rolebinding_pipelines-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-pipelines + namespace: {{ $.Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: tekton-dashboard-pipelines +subjects: + - kind: ServiceAccount + name: tekton-dashboard + namespace: {{ $.Release.Namespace }} +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "rolebinding_pipelines-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/rolebinding_triggers-dashboard.yaml b/charts/tekton-dashboard/templates/rolebinding_triggers-dashboard.yaml new file mode 100644 index 00000000..9831bf72 --- /dev/null +++ b/charts/tekton-dashboard/templates/rolebinding_triggers-dashboard.yaml @@ -0,0 +1,19 @@ +{{- define "rolebinding_triggers-dashboard" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: tekton-dashboard-triggers + namespace: {{ $.Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: tekton-dashboard-triggers +subjects: + - kind: ServiceAccount + name: tekton-dashboard + namespace: {{ $.Release.Namespace }} +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "rolebinding_triggers-dashboard" ) }} diff --git a/charts/tekton-dashboard/templates/service-dashboard.yaml b/charts/tekton-dashboard/templates/service-dashboard.yaml new file mode 100644 index 00000000..19098d95 --- /dev/null +++ b/charts/tekton-dashboard/templates/service-dashboard.yaml @@ -0,0 +1,17 @@ +{{- define "service-deployment" -}} +--- +apiVersion: v1 +kind: Service +metadata: + name: tekton-dashboard + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "dashboard") | nindent 4 }} +spec: + selector: {{- include "helpers.labels.matchLabels" (dict "Global" $) | nindent 4 }} + ports: + - name: web + protocol: TCP + port: {{ $.Values.params.endpoints.ports.web.port }} + targetPort: {{ $.Values.params.endpoints.ports.web.port }} +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "service-deployment" ) }} diff --git a/charts/tekton-dashboard/templates/serviceaccount-dashboard.yaml b/charts/tekton-dashboard/templates/serviceaccount-dashboard.yaml new file mode 100644 index 00000000..d63c13c7 --- /dev/null +++ b/charts/tekton-dashboard/templates/serviceaccount-dashboard.yaml @@ -0,0 +1,11 @@ +{{- define "serviceaccount-dashboard" -}} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: {{- include "helpers.labels.labels" (dict "Global" $ "Component" "tekton" "PartOf" "tekton-dashboard") | nindent 4 }} + name: {{ template "helpers.labels.fullname" . }} + namespace: {{ $.Release.Namespace }} +... +{{- end -}} +{{- include "helpers.template.overlay" ( dict "Global" $ "template_definition" "serviceaccount-dashboard" ) }} diff --git a/charts/tekton-dashboard/values.schema.json b/charts/tekton-dashboard/values.schema.json new file mode 100644 index 00000000..fcc2a9d1 --- /dev/null +++ b/charts/tekton-dashboard/values.schema.json @@ -0,0 +1,117 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/values.schema.json", + "type": "object", + "required": [ + "config", + "images", + "node_labels", + "params", + "over_rides" + ], + "properties": { + "config": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "string" + } + ] + } + }, + "images": { + "type": "object", + "additionalProperties": false, + "required": [ + "applications", + "pull" + ], + "properties": { + "applications": { + "type": "object", + "additionalProperties": { + "type": "object", + "required": [ + "name", + "repo", + "tag" + ], + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "repo": { + "type": "string" + }, + "tag": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "string" + } + ] + } + } + } + }, + "pull": { + "type": "object", + "additionalProperties": false, + "required": [ + "policy" + ], + "properties": { + "policy": { + "type": "string", + "enum": [ + "Always", + "IfNotPresent", + "Never" + ] + } + } + } + } + }, + "node_labels": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "object", + "required": [ + "key", + "value" + ], + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + }, + "params": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "over_rides": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } +} diff --git a/charts/tekton-dashboard/values.yaml b/charts/tekton-dashboard/values.yaml new file mode 100644 index 00000000..1b402790 --- /dev/null +++ b/charts/tekton-dashboard/values.yaml @@ -0,0 +1,35 @@ +--- +config: + args: + csrf_secure_cookie: false + external-logs: '' + log_format: json + log_level: info + logout_url: '' + namespace: '' + openshift: false + read_only: false + stream_logs: false + +images: + applications: + tekton_dashboard: + name: tektoncd/dashboard/cmd/dashboard + repo: gcr.io/tekton-releases/github.com + tag: v0.10.1 + pull: + policy: IfNotPresent + +node_labels: + tekton_dashboard: + - key: node-role.kubernetes.io/master + value: '' + +params: + endpoints: + ports: + web: + port: 9097 + scheme: http + +over_rides: {}