github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/kiali-server/templates/_helpers.tpl (about)

     1  {{/* vim: set filetype=mustache: */}}
     2  
     3  {{/*
     4  Create a default fully qualified instance name.
     5  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
     6  To simulate the way the operator works, use deployment.instance_name rather than the old fullnameOverride.
     7  For backwards compatibility, if fullnameOverride is not kiali but deployment.instance_name is kiali,
     8  use fullnameOverride, otherwise use deployment.instance_name.
     9  */}}
    10  {{- define "kiali-server.fullname" -}}
    11  {{- if (and (eq .Values.deployment.instance_name "kiali") (ne .Values.fullnameOverride "kiali")) }}
    12    {{- .Values.fullnameOverride | trunc 63 }}
    13  {{- else }}
    14    {{- .Values.deployment.instance_name | trunc 63 }}
    15  {{- end }}
    16  {{- end }}
    17  
    18  {{/*
    19  Create chart name and version as used by the chart label.
    20  */}}
    21  {{- define "kiali-server.chart" -}}
    22  {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
    23  {{- end }}
    24  
    25  {{/*
    26  Identifies the log_level with the old verbose_mode and the new log_level considered.
    27  */}}
    28  {{- define "kiali-server.logLevel" -}}
    29  {{- if .Values.deployment.verbose_mode -}}
    30  {{- .Values.deployment.verbose_mode -}}
    31  {{- else -}}
    32  {{- .Values.deployment.logger.log_level -}}
    33  {{- end -}}
    34  {{- end }}
    35  
    36  {{/*
    37  Common labels
    38  */}}
    39  {{- define "kiali-server.labels" -}}
    40  helm.sh/chart: {{ include "kiali-server.chart" . }}
    41  app: kiali
    42  {{ include "kiali-server.selectorLabels" . }}
    43  version: {{ .Values.deployment.version_label | default .Chart.AppVersion | quote }}
    44  app.kubernetes.io/version: {{ .Values.deployment.version_label | default .Chart.AppVersion | quote }}
    45  app.kubernetes.io/managed-by: {{ .Release.Service }}
    46  app.kubernetes.io/part-of: "kiali"
    47  {{- end }}
    48  
    49  {{/*
    50  Selector labels
    51  */}}
    52  {{- define "kiali-server.selectorLabels" -}}
    53  app.kubernetes.io/name: kiali
    54  app.kubernetes.io/instance: {{ include "kiali-server.fullname" . }}
    55  {{- end }}
    56  
    57  {{/*
    58  Determine the default login token signing key.
    59  */}}
    60  {{- define "kiali-server.login_token.signing_key" -}}
    61  {{- if .Values.login_token.signing_key }}
    62    {{- .Values.login_token.signing_key }}
    63  {{- else }}
    64    {{- randAlphaNum 16 }}
    65  {{- end }}
    66  {{- end }}
    67  
    68  {{/*
    69  Determine the default web root.
    70  */}}
    71  {{- define "kiali-server.server.web_root" -}}
    72  {{- if .Values.server.web_root  }}
    73    {{- if (eq .Values.server.web_root "/") }}
    74      {{- .Values.server.web_root }}
    75    {{- else }}
    76      {{- .Values.server.web_root | trimSuffix "/" }}
    77    {{- end }}
    78  {{- else }}
    79    {{- if .Capabilities.APIVersions.Has "route.openshift.io/v1" }}
    80      {{- "/" }}
    81    {{- else }}
    82      {{- "/kiali" }}
    83    {{- end }}
    84  {{- end }}
    85  {{- end }}
    86  
    87  {{/*
    88  Determine the default identity cert file. There is no default if on k8s; only on OpenShift.
    89  */}}
    90  {{- define "kiali-server.identity.cert_file" -}}
    91  {{- if hasKey .Values.identity "cert_file" }}
    92    {{- .Values.identity.cert_file }}
    93  {{- else }}
    94    {{- if .Capabilities.APIVersions.Has "route.openshift.io/v1" }}
    95      {{- "/kiali-cert/tls.crt" }}
    96    {{- else }}
    97      {{- "" }}
    98    {{- end }}
    99  {{- end }}
   100  {{- end }}
   101  
   102  {{/*
   103  Determine the default identity private key file. There is no default if on k8s; only on OpenShift.
   104  */}}
   105  {{- define "kiali-server.identity.private_key_file" -}}
   106  {{- if hasKey .Values.identity "private_key_file" }}
   107    {{- .Values.identity.private_key_file }}
   108  {{- else }}
   109    {{- if .Capabilities.APIVersions.Has "route.openshift.io/v1" }}
   110      {{- "/kiali-cert/tls.key" }}
   111    {{- else }}
   112      {{- "" }}
   113    {{- end }}
   114  {{- end }}
   115  {{- end }}
   116  
   117  {{/*
   118  Determine the default deployment.ingress.enabled. Disable it on k8s; enable it on OpenShift.
   119  */}}
   120  {{- define "kiali-server.deployment.ingress.enabled" -}}
   121  {{- if hasKey .Values.deployment.ingress "enabled" }}
   122    {{- .Values.deployment.ingress.enabled }}
   123  {{- else }}
   124    {{- if .Capabilities.APIVersions.Has "route.openshift.io/v1" }}
   125      {{- true }}
   126    {{- else }}
   127      {{- false }}
   128    {{- end }}
   129  {{- end }}
   130  {{- end }}
   131  
   132  {{/*
   133  Determine the istio namespace - default is where Kiali is installed.
   134  */}}
   135  {{- define "kiali-server.istio_namespace" -}}
   136  {{- if .Values.istio_namespace }}
   137    {{- .Values.istio_namespace }}
   138  {{- else }}
   139    {{- .Release.Namespace }}
   140  {{- end }}
   141  {{- end }}
   142  
   143  {{/*
   144  Determine the auth strategy to use - default is "token" on Kubernetes and "openshift" on OpenShift.
   145  */}}
   146  {{- define "kiali-server.auth.strategy" -}}
   147  {{- if .Values.auth.strategy }}
   148    {{- if (and (eq .Values.auth.strategy "openshift") (not .Values.kiali_route_url)) }}
   149      {{- fail "You did not define what the Kiali Route URL will be (--set kiali_route_url=...). Without this set, the openshift auth strategy will not work. Either set that or use a different auth strategy via the --set auth.strategy=... option." }}
   150    {{- end }}
   151    {{- .Values.auth.strategy }}
   152  {{- else }}
   153    {{- if .Capabilities.APIVersions.Has "route.openshift.io/v1" }}
   154      {{- if not .Values.kiali_route_url }}
   155        {{- fail "You did not define what the Kiali Route URL will be (--set kiali_route_url=...). Without this set, the openshift auth strategy will not work. Either set that or explicitly indicate another auth strategy you want via the --set auth.strategy=... option." }}
   156      {{- end }}
   157      {{- "openshift" }}
   158    {{- else }}
   159      {{- "token" }}
   160    {{- end }}
   161  {{- end }}
   162  {{- end }}
   163  
   164  {{/*
   165  Determine the root namespace - default is where Kiali is installed.
   166  */}}
   167  {{- define "kiali-server.external_services.istio.root_namespace" -}}
   168  {{- if .Values.external_services.istio.root_namespace }}
   169    {{- .Values.external_services.istio.root_namespace }}
   170  {{- else }}
   171    {{- .Release.Namespace }}
   172  {{- end }}
   173  {{- end }}
   174  
   175  {{/*
   176  Autodetect remote cluster secrets if enabled - looks for secrets in the same namespace where Kiali is installed.
   177  Returns a JSON dict whose keys are the cluster names and values are the cluster secret data.
   178  */}}
   179  {{- define "kiali-server.remote-cluster-secrets" -}}
   180  {{- $theDict := dict }}
   181  {{- if .Values.kiali_feature_flags.clustering.autodetect_secrets.enabled }}
   182    {{- $secretLabelToLookFor := (regexSplit "=" .Values.kiali_feature_flags.clustering.autodetect_secrets.label 2) }}
   183    {{- $secretLabelNameToLookFor := first $secretLabelToLookFor }}
   184    {{- $secretLabelValueToLookFor := last $secretLabelToLookFor }}
   185    {{- range $i, $secret := (lookup "v1" "Secret" .Release.Namespace "").items }}
   186      {{- if (and (and (hasKey $secret.metadata "labels") (hasKey $secret.metadata.labels $secretLabelNameToLookFor)) (eq (get $secret.metadata.labels $secretLabelNameToLookFor) ($secretLabelValueToLookFor))) }}
   187        {{- $clusterName := $secret.metadata.name }}
   188        {{- if (and (hasKey $secret.metadata "annotations") (hasKey $secret.metadata.annotations "kiali.io/cluster")) }}
   189          {{- $clusterName = get $secret.metadata.annotations "kiali.io/cluster" }}
   190        {{- end }}
   191        {{- $theDict = set $theDict $clusterName $secret.metadata.name }}
   192      {{- end }}
   193    {{- end }}
   194  {{- end }}
   195  {{- $theDict | toJson }}
   196  {{- end }}