github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/rancher/templates/_helpers.tpl (about) 1 {{/* vim: set filetype=mustache: */}} 2 {{/* 3 Expand the name of the chart. 4 */}} 5 {{- define "rancher.name" -}} 6 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 {{- end -}} 8 9 {{/* 10 Create a default fully qualified app name. 11 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 */}} 13 {{- define "rancher.fullname" -}} 14 {{- $name := default .Chart.Name .Values.nameOverride -}} 15 {{- if contains $name .Release.Name -}} 16 {{- .Release.Name | trunc 63 | trimSuffix "-" -}} 17 {{- else -}} 18 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 19 {{- end -}} 20 {{- end -}} 21 22 {{/* 23 Create a default fully qualified chart name. 24 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 25 */}} 26 {{- define "rancher.chartname" -}} 27 {{- printf "%s-%s" .Chart.Name .Chart.Version | trunc 63 | trimSuffix "-" -}} 28 {{- end -}} 29 30 # Render Values in configurationSnippet 31 {{- define "configurationSnippet" -}} 32 {{- tpl (.Values.ingress.configurationSnippet) . | nindent 6 -}} 33 {{- end -}} 34 35 {{/* 36 Generate the labels. 37 */}} 38 {{- define "rancher.labels" -}} 39 app: {{ template "rancher.fullname" . }} 40 chart: {{ template "rancher.chartname" . }} 41 heritage: {{ .Release.Service }} 42 release: {{ .Release.Name }} 43 {{- end }} 44 45 # Windows Support 46 47 {{/* 48 Windows cluster will add default taint for linux nodes, 49 add below linux tolerations to workloads could be scheduled to those linux nodes 50 */}} 51 52 {{- define "linux-node-tolerations" -}} 53 - key: "cattle.io/os" 54 value: "linux" 55 effect: "NoSchedule" 56 operator: "Equal" 57 {{- end -}} 58 59 {{- define "linux-node-selector-terms" -}} 60 {{- $key := "kubernetes.io/os" -}} 61 - matchExpressions: 62 - key: {{ $key }} 63 operator: NotIn 64 values: 65 - windows 66 {{- end -}} 67 68 {{- define "system_default_registry" -}} 69 {{- if .Values.systemDefaultRegistry -}} 70 {{- if hasSuffix "/" .Values.systemDefaultRegistry -}} 71 {{- printf "%s" .Values.systemDefaultRegistry -}} 72 {{- else -}} 73 {{- printf "%s/" .Values.systemDefaultRegistry -}} 74 {{- end -}} 75 {{- end -}} 76 {{- end -}} 77 78 {{/* 79 Define the chosen value for PSPs. If this value is "", then the user did not set the value. This will 80 result in psps on <=1.24 and no psps on >=1.25. If the value is true/false, then the user specifically 81 chose an option, and that option will be used. If it is set otherwise, then we fail so the user can correct 82 the invalid value. 83 */}} 84 85 {{- define "rancher.chart_psp_enabled" -}} 86 {{- if kindIs "bool" .Values.global.cattle.psp.enabled -}} 87 {{ .Values.global.cattle.psp.enabled }} 88 {{- else if empty .Values.global.cattle.psp.enabled -}} 89 {{- if gt (len (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" "")) 0 -}} 90 {{- if (.Capabilities.APIVersions.Has "policy/v1beta1/PodSecurityPolicy") -}} 91 true 92 {{- else -}} 93 false 94 {{- end -}} 95 {{- else -}} 96 true 97 {{- end -}} 98 {{- else -}} 99 {{- fail "Invalid value for .Values.global.cattle.psp.enabled - must be a bool of true, false, or \"\"" -}} 100 {{- end -}} 101 {{- end -}}