From 607d8bcd9a833841eee057b263c0bdc06de0fbea Mon Sep 17 00:00:00 2001 From: sh2 Date: Wed, 5 Jun 2024 04:34:39 +0800 Subject: [PATCH] helm: add envoy gateway addon helm chart support (#3470) * initial dashboard addon helm chart Signed-off-by: shawnh2 * rename addon name and remove gateway-helm support Signed-off-by: shawnh2 * remove /charts from .helmignore Signed-off-by: shawnh2 * rename to gateway-addons-helm and keep one source of truth Signed-off-by: shawnh2 * restore examples values and fix comments Signed-off-by: shawnh2 * rewrite helm makefile Signed-off-by: shawnh2 --------- Signed-off-by: shawnh2 --- .gitignore | 3 + charts/gateway-addons-helm/.helmignore | 23 +++++++ charts/gateway-addons-helm/Chart.lock | 9 +++ charts/gateway-addons-helm/Chart.yaml | 33 ++++++++++ .../dashboards/envoy-clusters.json | 0 .../dashboards/envoy-gateway-global.json | 0 .../dashboards/envoy-global.json | 0 .../dashboards/envoy-pod-resource.json | 0 .../gateway-addons-helm/templates/NOTES.txt | 20 ++++++ charts/gateway-addons-helm/values.yaml | 39 +++++++++++ examples/prometheus/helm-values.yaml | 1 - tools/make/helm.mk | 66 +++++++++++++++---- 12 files changed, 181 insertions(+), 13 deletions(-) create mode 100644 charts/gateway-addons-helm/.helmignore create mode 100644 charts/gateway-addons-helm/Chart.lock create mode 100644 charts/gateway-addons-helm/Chart.yaml rename {examples/grafana => charts/gateway-addons-helm}/dashboards/envoy-clusters.json (100%) rename {examples/grafana => charts/gateway-addons-helm}/dashboards/envoy-gateway-global.json (100%) rename {examples/grafana => charts/gateway-addons-helm}/dashboards/envoy-global.json (100%) rename {examples/grafana => charts/gateway-addons-helm}/dashboards/envoy-pod-resource.json (100%) create mode 100644 charts/gateway-addons-helm/templates/NOTES.txt create mode 100644 charts/gateway-addons-helm/values.yaml diff --git a/.gitignore b/.gitignore index 0dee17ad8f4..5bf0184010e 100644 --- a/.gitignore +++ b/.gitignore @@ -32,5 +32,8 @@ vendor/ # values.yaml file is generated from its template counterpart. charts/gateway-helm/values.yaml +# dependency charts generated by addons helm. +charts/gateway-addons-helm/charts/ + # VIM .*.swp diff --git a/charts/gateway-addons-helm/.helmignore b/charts/gateway-addons-helm/.helmignore new file mode 100644 index 00000000000..0e8a0eb36f4 --- /dev/null +++ b/charts/gateway-addons-helm/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/gateway-addons-helm/Chart.lock b/charts/gateway-addons-helm/Chart.lock new file mode 100644 index 00000000000..5a8d142574b --- /dev/null +++ b/charts/gateway-addons-helm/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: prometheus + repository: https://prometheus-community.github.io/helm-charts + version: 23.1.0 +- name: grafana + repository: https://grafana.github.io/helm-charts + version: 6.58.4 +digest: sha256:d4ffdf4c4b286fd4fdebf553d4d48cf2654c8df431d75d7c22c0bfabfe1c6b15 +generated: "2024-06-02T11:28:44.08768+08:00" diff --git a/charts/gateway-addons-helm/Chart.yaml b/charts/gateway-addons-helm/Chart.yaml new file mode 100644 index 00000000000..8f48bed1a58 --- /dev/null +++ b/charts/gateway-addons-helm/Chart.yaml @@ -0,0 +1,33 @@ +apiVersion: v2 +name: gateway-addons-helm +description: An Add-ons Helm chart for Envoy Gateway +type: application + +version: v0.0.0-latest +appVersion: "latest" +icon: https://raw.githubusercontent.com/envoyproxy/gateway/main/site/assets/icons/logo.svg + +maintainers: + - name: envoy-gateway-steering-committee + url: https://github.com/envoyproxy/gateway/blob/main/GOVERNANCE.md + - name: envoy-gateway-maintainers + url: https://github.com/envoyproxy/gateway/blob/main/CODEOWNERS + +keywords: + - gateway-api + - envoyproxy + - envoy-gateway + - eg + +home: https://gateway.envoyproxy.io/ + +sources: + - https://github.com/envoyproxy/gateway + +dependencies: + - name: prometheus + version: 23.1.0 + repository: https://prometheus-community.github.io/helm-charts + - name: grafana + repository: https://grafana.github.io/helm-charts + version: 6.58.4 diff --git a/examples/grafana/dashboards/envoy-clusters.json b/charts/gateway-addons-helm/dashboards/envoy-clusters.json similarity index 100% rename from examples/grafana/dashboards/envoy-clusters.json rename to charts/gateway-addons-helm/dashboards/envoy-clusters.json diff --git a/examples/grafana/dashboards/envoy-gateway-global.json b/charts/gateway-addons-helm/dashboards/envoy-gateway-global.json similarity index 100% rename from examples/grafana/dashboards/envoy-gateway-global.json rename to charts/gateway-addons-helm/dashboards/envoy-gateway-global.json diff --git a/examples/grafana/dashboards/envoy-global.json b/charts/gateway-addons-helm/dashboards/envoy-global.json similarity index 100% rename from examples/grafana/dashboards/envoy-global.json rename to charts/gateway-addons-helm/dashboards/envoy-global.json diff --git a/examples/grafana/dashboards/envoy-pod-resource.json b/charts/gateway-addons-helm/dashboards/envoy-pod-resource.json similarity index 100% rename from examples/grafana/dashboards/envoy-pod-resource.json rename to charts/gateway-addons-helm/dashboards/envoy-pod-resource.json diff --git a/charts/gateway-addons-helm/templates/NOTES.txt b/charts/gateway-addons-helm/templates/NOTES.txt new file mode 100644 index 00000000000..6b412845ffd --- /dev/null +++ b/charts/gateway-addons-helm/templates/NOTES.txt @@ -0,0 +1,20 @@ +************************************************************************** +*** PLEASE BE PATIENT: Envoy Gateway may take a few minutes to install *** +************************************************************************** + +Envoy Gateway is an open source project for managing Envoy Proxy as a standalone or Kubernetes-based application gateway. + +Thank you for installing the Add-ons for Envoy Gateway! πŸŽ‰ + +Your release is named: {{ .Release.Name }}. πŸŽ‰ + +Your release is in namespace: {{ .Release.Namespace }}. πŸŽ‰ + +To learn more about the release, try: + + $ helm status {{ .Release.Name }} -n {{ .Release.Namespace }} + $ helm get all {{ .Release.Name }} -n {{ .Release.Namespace }} + +To have a quickstart of the Add-ons for Envoy Gateway, please refer to https://gateway.envoyproxy.io/latest/tasks/observability/. + +To get more details, please visit https://gateway.envoyproxy.io and https://github.com/envoyproxy/gateway. diff --git a/charts/gateway-addons-helm/values.yaml b/charts/gateway-addons-helm/values.yaml new file mode 100644 index 00000000000..7bf421ed12c --- /dev/null +++ b/charts/gateway-addons-helm/values.yaml @@ -0,0 +1,39 @@ +# Values for Grafana dependency +grafana: + datasources: + datasources.yaml: + apiVersion: 1 + datasources: + - name: Prometheus + type: prometheus + url: http://prometheus-server + adminPassword: admin + service: + type: LoadBalancer + +# Values for Prometheus dependency +prometheus: + # To simplify the deployment, disable non-essential components + alertmanager: + enabled: false + prometheus-pushgateway: + enabled: false + kube-state-metrics: + enabled: false + prometheus-node-exporter: + enabled: false + server: + fullnameOverride: prometheus + persistentVolume: + enabled: false + readinessProbeInitialDelay: 0 + global: + # Speed up scraping a bit from the default + scrape_interval: 15s + service: + # use LoadBalancer to expose prometheus + type: LoadBalancer + # use dockerhub + image: + repository: prom/prometheus + securityContext: null diff --git a/examples/prometheus/helm-values.yaml b/examples/prometheus/helm-values.yaml index 9de08834491..7cee4e7bcee 100644 --- a/examples/prometheus/helm-values.yaml +++ b/examples/prometheus/helm-values.yaml @@ -22,4 +22,3 @@ server: image: repository: prom/prometheus securityContext: null - diff --git a/tools/make/helm.mk b/tools/make/helm.mk index 4d336d359b1..de37f886ad8 100644 --- a/tools/make/helm.mk +++ b/tools/make/helm.mk @@ -1,35 +1,77 @@ # This is a wrapper to manage helm chart # -# All make targets related to helmß are defined in this file. +# All make targets related to helms are defined in this file. include tools/make/env.mk +CHARTS := $(wildcard charts/*) + IMAGE_PULL_POLICY ?= IfNotPresent OCI_REGISTRY ?= oci://docker.io/envoyproxy CHART_NAME ?= gateway-helm CHART_VERSION ?= ${RELEASE_VERSION} +RELEASE_NAMESPACE ?= envoy-gateway-system ##@ Helm +.PHONY: helm-package +helm-package: ## Package envoy gateway relevant helm charts. helm-package: -helm-package: ## Package envoy gateway helm chart. -helm-package: helm-generate - @$(LOG_TARGET) + @for chart in $(CHARTS); do \ + $(LOG_TARGET); \ + $(MAKE) $(addprefix helm-package., $$(basename $${chart})); \ + done + +.PHONY: helm-package.% +helm-package.%: helm-generate.% + $(eval COMMAND := $(word 1,$(subst ., ,$*))) + $(eval CHART_NAME := $(COMMAND)) helm package charts/${CHART_NAME} --app-version ${TAG} --version ${CHART_VERSION} --destination ${OUTPUT_DIR}/charts/ +.PHONY: helm-push +helm-push: ## Push envoy gateway relevant helm charts to OCI registry. helm-push: -helm-push: ## Push envoy gateway helm chart to OCI registry. - @$(LOG_TARGET) + @for chart in $(CHARTS); do \ + $(LOG_TARGET); \ + $(MAKE) $(addprefix helm-push., $$(basename $${chart})); \ + done + +.PHONY: helm-push.% +helm-push.%: helm-package.% + $(eval COMMAND := $(word 1,$(subst ., ,$*))) + $(eval CHART_NAME := $(COMMAND)) helm push ${OUTPUT_DIR}/charts/${CHART_NAME}-${CHART_VERSION}.tgz ${OCI_REGISTRY} +.PHONY: helm-install +helm-install: ## Install envoy gateway relevant helm charts from OCI registry. helm-install: -helm-install: helm-generate ## Install envoy gateway helm chart from OCI registry. - @$(LOG_TARGET) - helm install eg ${OCI_REGISTRY}/${CHART_NAME} --version ${CHART_VERSION} -n envoy-gateway-system --create-namespace + @for chart in $(CHARTS); do \ + $(LOG_TARGET); \ + $(MAKE) $(addprefix helm-install., $$(basename $${chart})); \ + done + +.PHONY: helm-install.% +helm-install.%: helm-generate.% + $(eval COMMAND := $(word 1,$(subst ., ,$*))) + $(eval CHART_NAME := $(COMMAND)) + helm install eg ${OCI_REGISTRY}/${CHART_NAME} --version ${CHART_VERSION} -n ${RELEASE_NAMESPACE} --create-namespace .PHONY: helm-generate helm-generate: - GatewayImage=${IMAGE}:${TAG} GatewayImagePullPolicy=${IMAGE_PULL_POLICY} envsubst < charts/gateway-helm/values.tmpl.yaml > ./charts/gateway-helm/values.yaml - helm lint charts/gateway-helm + @for chart in $(CHARTS); do \ + $(LOG_TARGET); \ + $(MAKE) $(addprefix helm-generate., $$(basename $${chart})); \ + done + +.PHONY: helm-generate.% +helm-generate.%: + $(eval COMMAND := $(word 1,$(subst ., ,$*))) + $(eval CHART_NAME := $(COMMAND)) + @if test -f "charts/${CHART_NAME}/values.tmpl.yaml"; then \ + GatewayImage=${IMAGE}:${TAG} GatewayImagePullPolicy=${IMAGE_PULL_POLICY} \ + envsubst < charts/${CHART_NAME}/values.tmpl.yaml > ./charts/${CHART_NAME}/values.yaml; \ + fi + helm lint charts/${CHART_NAME} + helm dependency update charts/${CHART_NAME} # Update dependencies for add-ons chart. HELM_VALUES := $(wildcard test/helm/*.in.yaml) @@ -38,5 +80,5 @@ helm-template: ## Template envoy gateway helm chart.z @for file in $(HELM_VALUES); do \ filename=$$(basename $${file}); \ output="$${filename%.in.*}.out.yaml"; \ - helm template eg charts/gateway-helm -f $${file} > test/helm/$$output --namespace=envoy-gateway-system; \ + helm template eg charts/${CHART_NAME} -f $${file} > test/helm/$$output --namespace=${RELEASE_NAMESPACE}; \ done