From ad516b146c8d0d33f660b90e8099bfb028bf75bc Mon Sep 17 00:00:00 2001 From: John Mazzitelli Date: Wed, 3 Nov 2021 14:52:34 -0400 Subject: [PATCH] support ingress class_name customization (#113) part of: https://github.com/kiali/kiali/issues/4342 --- README.adoc | 78 ++++++++++++++++++++++++++++- kiali-server/templates/_helpers.tpl | 15 ++++++ kiali-server/templates/ingress.yaml | 13 +++-- kiali-server/templates/route.yaml | 10 ++-- kiali-server/values.yaml | 8 +-- 5 files changed, 109 insertions(+), 15 deletions(-) diff --git a/README.adoc b/README.adoc index c6bb3d8..7584d81 100644 --- a/README.adoc +++ b/README.adoc @@ -7,11 +7,85 @@ Kiali Helm Charts are published at link:https://kiali.org/helm-charts/index.yaml For Kiali installation documentation, please see: -* link:https://kiali.io/documentation/latest/quick-start/[Kiali Quick Start Guide] -* link:https://kiali.io/documentation/latest/installation-guide/[Kiali Installation Guide] +* link:https://kiali.io/docs/installation/quick-start/#install-via-helm[Kiali Quick Start Guide] +* link:https://kiali.io/docs/installation/installation-guide/install-with-helm/[Kiali Installation Guide] == Chart Source Kiali Operator helm chart source is found in the link:./kiali-operator[kiali-operator folder]. Kiali Server helm chart source is found in the link:./kiali-server[kiali-server folder]. +== Developer Notes + +=== Building + +To build the helm charts, simply run `make clean build-helm-charts` which will generate the operator and server helm charts and stores their tarballs in the `_output/charts` directory. + +=== Using the local Helm chart builds + +==== Server + +To generate the server templates, run: + +``` +helm template -n istio-system --set auth.strategy=anonymous --set deployment.image_version=latest kiali-server _output/charts/kiali-server-*-SNAPSHOT.tgz +``` + +To install the server, run: + +``` +helm install -n istio-system --set auth.strategy=anonymous --set deployment.image_version=latest kiali-server _output/charts/kiali-server-*-SNAPSHOT.tgz +``` + +To uninstall the server, run: + +``` +helm uninstall -n istio-system kiali-server +``` + +==== Operator + +To generate the operator templates, run: + +``` +helm template -n kiali-operator --set allowAdHocKialiImage=true --set image.tag=latest --create-namespace kiali-operator _output/charts/kiali-operator-*-SNAPSHOT.tgz +``` + +To install the operator, run: + +``` +helm install -n kiali-operator --set allowAdHocKialiImage=true --set image.tag=latest --create-namespace kiali-operator _output/charts/kiali-operator-*-SNAPSHOT.tgz +``` + +To uninstall the operator, run: + +``` +helm uninstall -n kiali-operator kiali-operator +``` + +==== Overriding values + +You can pass `--set` options to the above commands if you wish to override the default values. You can set nested dictionary values using dot notation: `--set deployment.logger.log_level=debug`. For a list of items, comma-separate the values and wrap the list in curly braces: `--set "deployment.accessible_namespaces={bookinfo,demo2}"`. You can set individual list items using square brackets: `--set deployment.accessible_namespaces[0]=bookinfo`. + +If you locally built and pushed your Kiali server and Kiali operator images to your cluster, you can have the helm chart installations pull those images by the following settings: + +|=== +|Helm Chart|Cluster Type|Settings + +|Server|Minikube| +`--set deployment.image_name=localhost:5000/kiali/kiali` + +`--set deployment.image_version=dev` +|Server|OpenShift| +`--set deployment.image_name=image-registry.openshift-image-registry.svc:5000/kiali/kiali` + +`--set deployment.image_version=dev` +|Operator|Minikube| +`--set image.repo=localhost:5000/kiali/kiali-operator` + +`--set image.tag=dev` + +`--set cr.spec.deployment.image_name=localhost:5000/kiali/kiali` + +`--set cr.spec.deployment.image_version=dev` +|Operator|OpenShift| +`--set image.repo=image-registry.openshift-image-registry.svc:5000/kiali/kiali-operator` + +`--set image.tag=dev` + +`--set cr.spec.deployment.image_name=image-registry.openshift-image-registry.svc:5000/kiali/kiali` + +`--set cr.spec.deployment.image_version=dev` +|=== diff --git a/kiali-server/templates/_helpers.tpl b/kiali-server/templates/_helpers.tpl index 28302a5..8b6a7fc 100644 --- a/kiali-server/templates/_helpers.tpl +++ b/kiali-server/templates/_helpers.tpl @@ -114,6 +114,21 @@ Determine the default identity private key file. There is no default if on k8s; {{- end }} {{- end }} +{{/* +Determine the default deployment.ingress.enabled. Disable it on k8s; enable it on OpenShift. +*/}} +{{- define "kiali-server.deployment.ingress.enabled" -}} +{{- if hasKey .Values.deployment.ingress "enabled" }} + {{- .Values.deployment.ingress.enabled }} +{{- else }} + {{- if .Capabilities.APIVersions.Has "route.openshift.io/v1" }} + {{- true }} + {{- else }} + {{- false }} + {{- end }} +{{- end }} +{{- end }} + {{/* Determine the istio namespace - default is where Kiali is installed. */}} diff --git a/kiali-server/templates/ingress.yaml b/kiali-server/templates/ingress.yaml index 5cc9aa2..0ef603b 100644 --- a/kiali-server/templates/ingress.yaml +++ b/kiali-server/templates/ingress.yaml @@ -1,5 +1,5 @@ {{- if not (.Capabilities.APIVersions.Has "route.openshift.io/v1") }} -{{- if .Values.deployment.ingress_enabled }} +{{- if eq "true" (include "kiali-server.deployment.ingress.enabled" .) }} --- {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }} apiVersion: networking.k8s.io/v1 @@ -13,8 +13,8 @@ metadata: labels: {{- include "kiali-server.labels" . | nindent 4 }} annotations: - {{- if hasKey .Values.deployment.override_ingress_yaml.metadata "annotations" }} - {{- toYaml .Values.deployment.override_ingress_yaml.metadata.annotations | nindent 4 }} + {{- if hasKey .Values.deployment.ingress.override_yaml.metadata "annotations" }} + {{- toYaml .Values.deployment.ingress.override_yaml.metadata.annotations | nindent 4 }} {{- else }} # For ingress-nginx versions older than 0.20.0 use secure-backends. # (see: https://github.com/kubernetes/ingress-nginx/issues/3416#issuecomment-438247948) @@ -28,9 +28,12 @@ metadata: {{- end }} {{- end }} spec: - {{- if hasKey .Values.deployment.override_ingress_yaml "spec" }} - {{- toYaml .Values.deployment.override_ingress_yaml.spec | nindent 2 }} + {{- if hasKey .Values.deployment.ingress.override_yaml "spec" }} + {{- toYaml .Values.deployment.ingress.override_yaml.spec | nindent 2 }} {{- else }} + {{- if .Values.deployment.ingress.class_name }} + ingressClassName: {{ .Values.deployment.ingress.class_name }} + {{- end }} rules: - http: paths: diff --git a/kiali-server/templates/route.yaml b/kiali-server/templates/route.yaml index 95c99da..8e01120 100644 --- a/kiali-server/templates/route.yaml +++ b/kiali-server/templates/route.yaml @@ -1,5 +1,5 @@ {{- if .Capabilities.APIVersions.Has "route.openshift.io/v1" }} -{{- if .Values.deployment.ingress_enabled }} +{{- if eq "true" (include "kiali-server.deployment.ingress.enabled" .) }} # As of OpenShift 4.5, need to use --disable-openapi-validation when installing via Helm --- apiVersion: route.openshift.io/v1 @@ -9,13 +9,13 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "kiali-server.labels" . | nindent 4 }} - {{- if hasKey .Values.deployment.override_ingress_yaml.metadata "annotations" }}} + {{- if hasKey .Values.deployment.ingress.override_yaml.metadata "annotations" }}} annotations: - {{- toYaml .Values.deployment.override_ingress_yaml.metadata.annotations | nindent 4 }} + {{- toYaml .Values.deployment.ingress.override_yaml.metadata.annotations | nindent 4 }} {{- end }} spec: - {{- if hasKey .Values.deployment.override_ingress_yaml "spec" }} - {{- toYaml .Values.deployment.override_ingress_yaml.spec | nindent 2 }} + {{- if hasKey .Values.deployment.ingress.override_yaml "spec" }} + {{- toYaml .Values.deployment.ingress.override_yaml.spec | nindent 2 }} {{- else }} tls: termination: reencrypt diff --git a/kiali-server/values.yaml b/kiali-server/values.yaml index 2a24646..e1c6022 100644 --- a/kiali-server/values.yaml +++ b/kiali-server/values.yaml @@ -44,7 +44,11 @@ deployment: image_pull_policy: "Always" image_pull_secrets: [] image_version: ${HELM_IMAGE_TAG} # version like "v1.39" (see: https://quay.io/repository/kiali/kiali?tab=tags) or a digest hash - ingress_enabled: true + ingress: + class_name: "nginx" + #enabled: + override_yaml: + metadata: {} instance_name: "kiali" logger: log_format: "text" @@ -52,8 +56,6 @@ deployment: time_field_format: "2006-01-02T15:04:05Z07:00" sampler_rate: "1" node_selector: {} - override_ingress_yaml: - metadata: {} pod_annotations: {} pod_labels: {} priority_class_name: ""