mirror of https://git.rancher.io/charts
134 lines
4.0 KiB
Diff
134 lines
4.0 KiB
Diff
--- charts-original/templates/_helpers.tpl
|
|
+++ charts/templates/_helpers.tpl
|
|
@@ -1,3 +1,130 @@
|
|
+# Rancher
|
|
+{{- define "system_default_registry" -}}
|
|
+{{- if .Values.global.cattle.systemDefaultRegistry -}}
|
|
+{{- printf "%s/" .Values.global.cattle.systemDefaultRegistry -}}
|
|
+{{- end -}}
|
|
+{{- end -}}
|
|
+
|
|
+{{/*
|
|
+https://github.com/helm/helm/issues/4535#issuecomment-477778391
|
|
+Usage: {{ include "call-nested" (list . "SUBCHART_NAME" "TEMPLATE") }}
|
|
+e.g. {{ include "call-nested" (list . "grafana" "grafana.fullname") }}
|
|
+*/}}
|
|
+{{- define "call-nested" }}
|
|
+{{- $dot := index . 0 }}
|
|
+{{- $subchart := index . 1 | splitList "." }}
|
|
+{{- $template := index . 2 }}
|
|
+{{- $values := $dot.Values }}
|
|
+{{- range $subchart }}
|
|
+{{- $values = index $values . }}
|
|
+{{- end }}
|
|
+{{- include $template (dict "Chart" (dict "Name" (last $subchart)) "Values" $values "Release" $dot.Release "Capabilities" $dot.Capabilities) }}
|
|
+{{- end }}
|
|
+
|
|
+# Special Exporters
|
|
+{{- define "exporter.kubeEtcd.enabled" -}}
|
|
+{{- if or .Values.kubeEtcd.enabled .Values.rkeEtcd.enabled .Values.kubeAdmEtcd.enabled .Values.rke2Etcd.enabled -}}
|
|
+"true"
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubeControllerManager.enabled" -}}
|
|
+{{- if or .Values.kubeControllerManager.enabled .Values.rkeControllerManager.enabled .Values.k3sServer.enabled .Values.kubeAdmControllerManager.enabled .Values.rke2ControllerManager.enabled -}}
|
|
+"true"
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubeScheduler.enabled" -}}
|
|
+{{- if or .Values.kubeScheduler.enabled .Values.rkeScheduler.enabled .Values.k3sServer.enabled .Values.kubeAdmScheduler.enabled .Values.rke2Scheduler.enabled -}}
|
|
+"true"
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubeProxy.enabled" -}}
|
|
+{{- if or .Values.kubeProxy.enabled .Values.rkeProxy.enabled .Values.k3sServer.enabled .Values.kubeAdmProxy.enabled .Values.rke2Proxy.enabled -}}
|
|
+"true"
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubelet.enabled" -}}
|
|
+{{- if or .Values.kubelet.enabled .Values.hardenedKubelet.enabled .Values.k3sServer.enabled -}}
|
|
+"true"
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubeletService.enabled" -}}
|
|
+{{- if or .Values.hardenedKubelet.enabled .Values.prometheusOperator.kubeletService.enabled .Values.k3sServer.enabled -}}
|
|
+"true"
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubeControllerManager.jobName" -}}
|
|
+{{- if .Values.k3sServer.enabled -}}
|
|
+k3s-server
|
|
+{{- else -}}
|
|
+kube-controller-manager
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubeScheduler.jobName" -}}
|
|
+{{- if .Values.k3sServer.enabled -}}
|
|
+k3s-server
|
|
+{{- else -}}
|
|
+kube-scheduler
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubeProxy.jobName" -}}
|
|
+{{- if .Values.k3sServer.enabled -}}
|
|
+k3s-server
|
|
+{{- else -}}
|
|
+kube-proxy
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "exporter.kubelet.jobName" -}}
|
|
+{{- if .Values.k3sServer.enabled -}}
|
|
+k3s-server
|
|
+{{- else -}}
|
|
+kubelet
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+{{- define "kubelet.serviceMonitor.resourcePath" -}}
|
|
+{{- $kubeTargetVersion := default .Capabilities.KubeVersion.GitVersion .Values.kubeTargetVersionOverride }}
|
|
+{{- if not (eq .Values.kubelet.serviceMonitor.resourcePath "/metrics/resource/v1alpha1") -}}
|
|
+{{ .Values.kubelet.serviceMonitor.resourcePath }}
|
|
+{{- else if semverCompare ">=1.20.0-0" $kubeTargetVersion -}}
|
|
+/metrics/resource
|
|
+{{- else -}}
|
|
+/metrics/resource/v1alpha1
|
|
+{{- end -}}
|
|
+{{- end }}
|
|
+
|
|
+# Windows Support
|
|
+
|
|
+{{/*
|
|
+Windows cluster will add default taint for linux nodes,
|
|
+add below linux tolerations to workloads could be scheduled to those linux nodes
|
|
+*/}}
|
|
+
|
|
+{{- define "linux-node-tolerations" -}}
|
|
+- key: "cattle.io/os"
|
|
+ value: "linux"
|
|
+ effect: "NoSchedule"
|
|
+ operator: "Equal"
|
|
+{{- end -}}
|
|
+
|
|
+{{- define "linux-node-selector" -}}
|
|
+{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
|
+beta.kubernetes.io/os: linux
|
|
+{{- else -}}
|
|
+kubernetes.io/os: linux
|
|
+{{- end -}}
|
|
+{{- end -}}
|
|
+
|
|
+# Prometheus Operator
|
|
+
|
|
{{/* vim: set filetype=mustache: */}}
|
|
{{/* Expand the name of the chart. This is suffixed with -alertmanager, which means subtract 13 from longest 63 available */}}
|
|
{{- define "kube-prometheus-stack.name" -}}
|