Skip to content

Commit b81246a

Browse files
Ingress feature for nopo11y-stack (#23)
* Added istio common ingress helm chart * Removed nopo11y-health-check ingress, added it in nopo11y-ingress * Updated chart version to 1.4.0 from 1.3.1 * Updated max item limit to 500 from 20 * Added helper function to get service name, path and port of all nopo11y component * Added nopo11y_ingress values and removed nopo11y health check ingress option * Added istio and nginx ingress config for nopo11y component access * Removed istio-common-ingress * Updated the description for the ingress values * Added indentation * Changed default ingress type to istio * Updated logic for kiali path * Added double qoute for ingress type * Corrected istio gateway api version
1 parent b5956a3 commit b81246a

File tree

10 files changed

+289
-34
lines changed

10 files changed

+289
-34
lines changed

charts/nopo11y-stack/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ dependencies:
4444
description: A Helm chart for observability stack
4545
name: nopo11y-stack
4646
type: application
47-
version: 1.3.1
47+
version: 1.4.0

charts/nopo11y-stack/dashboards/home.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"id": 4,
3838
"options": {
39-
"maxItems": 20,
39+
"maxItems": 500,
4040
"query": "",
4141
"showHeadings": false,
4242
"showRecentlyViewed": false,

charts/nopo11y-stack/templates/_helpers.tpl

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,105 @@
66
{{- define "kuberhealthy-url" -}}
77
{{ $port:= .Values.kuberhealthy.service.externalPort |int }}
88
{{- printf "%s:%d" (include "kuberhealthy.name" .Subcharts.kuberhealthy) $port -}}
9+
{{- end -}}
10+
11+
{{- define "nopo11y.services" -}}
12+
13+
{{- if .Values.nopo11y_ingress.enabled }}
14+
{{- $servicesList:= list }}
15+
16+
{{- $prometheus:= dict }}
17+
{{- $prometheus = set $prometheus "name" (printf "%s-prometheus" (include "kube-prometheus-stack.fullname" (index .Subcharts "kube-prometheus-stack"))) }}
18+
{{- $port:= (index .Values "kube-prometheus-stack" "prometheus" "service" "port") |int }}
19+
{{- $path:= (index .Values "kube-prometheus-stack" "prometheus" "prometheusSpec" "routePrefix") }}
20+
{{- $prometheus = set $prometheus "port" $port }}
21+
{{- if ne $path "/" }}
22+
{{- $prometheus = set $prometheus "path" $path }}
23+
{{- $servicesList = append $servicesList $prometheus }}
24+
{{- end }}
25+
26+
{{- if (index .Values "kube-prometheus-stack" "grafana" "enabled" ) }}
27+
{{- $grafana:= dict }}
28+
{{- $path:= "" }}
29+
{{- if hasKey (index .Values "kube-prometheus-stack" "grafana" "grafana.ini" "server") "root_url" }}
30+
{{- $path = (urlParse (index .Values "kube-prometheus-stack" "grafana" "grafana.ini" "server" "root_url")).path }}
31+
{{- end }}
32+
{{- $port:= (index .Values "kube-prometheus-stack" "grafana" "service" "port") |int }}
33+
{{- $grafana = set $grafana "name" (printf "%s" (include "grafana.fullname" (index .Subcharts "kube-prometheus-stack").Subcharts.grafana)) }}
34+
{{- $grafana = set $grafana "port" (printf "%d" $port) }}
35+
{{- if ne $path "" }}
36+
{{- $grafana = set $grafana "path" (trimSuffix "/" $path) }}
37+
{{- $servicesList = append $servicesList $grafana }}
38+
{{- end }}
39+
{{- end }}
40+
41+
{{- if (index .Values "kube-prometheus-stack" "alertmanager" "enabled" ) }}
42+
{{- $alertmanager:= dict }}
43+
{{- $alertmanager = set $alertmanager "name" (printf "%s-alertmanager" (include "kube-prometheus-stack.fullname" (index .Subcharts "kube-prometheus-stack"))) }}
44+
{{- $port:= (index .Values "kube-prometheus-stack" "alertmanager" "service" "port") |int }}
45+
{{- $path:= (index .Values "kube-prometheus-stack" "alertmanager" "alertmanagerSpec" "routePrefix") }}
46+
{{- $alertmanager = set $alertmanager "port" (printf "%d" $port) }}
47+
{{- if ne $path "/" }}
48+
{{- $alertmanager = set $alertmanager "path" $path }}
49+
{{- $servicesList = append $servicesList $alertmanager }}
50+
{{- end }}
51+
{{- end }}
52+
53+
{{- if .Values.thanos.enabled }}
54+
{{- if .Values.thanos.query.enabled }}
55+
{{- $query:= dict }}
56+
{{- $query = set $query "name" (printf "%s-query" (include "common.names.fullname" .Subcharts.thanos)) }}
57+
{{- $query = set $query "port" .Values.thanos.query.service.ports.http }}
58+
{{- $path:= "" }}
59+
{{- if .Values.thanos.query.extraFlags }}
60+
{{- range .Values.thanos.query.extraFlags }}
61+
{{- if contains "--web.route-prefix" . }}
62+
{{- $path = (trimPrefix "--web.route-prefix=" . ) }}
63+
{{- end }}
64+
{{- end }}
65+
{{- end }}
66+
{{- if ne $path "" }}
67+
{{- $query = set $query "path" $path }}
68+
{{- $servicesList = append $servicesList $query }}
69+
{{- end }}
70+
{{- end }}
71+
{{- end }}
72+
73+
74+
{{- if (index .Values "kiali-server" "enabled") }}
75+
{{- $kiali:= dict }}
76+
{{- $kiali = set $kiali "name" (printf "%s" (include "kiali-server.fullname" (index .Subcharts "kiali-server"))) }}
77+
{{- $kiali = set $kiali "port" .Values.kiali.server.port }}
78+
{{- if (index .Values "kiali-server" "server" "web_root") }}
79+
{{- if ne (index .Values "kiali-server" "server" "web_root") "/" }}
80+
{{- $kiali = set $kiali "path" (index .Values "kiali-server" "server" "web_root") }}
81+
{{- $servicesList = append $servicesList $kiali }}
82+
{{- end }}
83+
{{- else }}
84+
{{- $kiali = set $kiali "path" "/kiali" }}
85+
{{- $servicesList = append $servicesList $kiali }}
86+
{{- end }}
87+
{{- end }}
88+
89+
{{- if .Values.jaeger.enabled}}
90+
{{- $jaeger:= dict }}
91+
{{- $jaeger = set $jaeger "name" (printf "%s-tracing" .Release.Name) }}
92+
{{- $jaeger = set $jaeger "port" 80 }}
93+
{{- $jaeger = set $jaeger "path" .Values.jaeger.jaeger.pathPrefix }}
94+
{{- $servicesList = append $servicesList $jaeger }}
95+
{{- end }}
96+
97+
{{- if .Values.kuberhealthy.enabled }}
98+
{{- $kuberhealthy:= dict }}
99+
{{- $kuberhealthy = set $kuberhealthy "name" (printf "%s" (include "kuberhealthy.name" .Subcharts.kuberhealthy)) }}
100+
{{- $kuberhealthy = set $kuberhealthy "port" .Values.kuberhealthy.service.externalPort }}
101+
{{- $kuberhealthy = set $kuberhealthy "path" "/nopo11y-health-check" }}
102+
{{- $kuberhealthy = set $kuberhealthy "rewritePath" "/" }}
103+
{{- $servicesList = append $servicesList $kuberhealthy }}
104+
{{- end }}
105+
106+
{{- toJson $servicesList }}
107+
108+
{{- end }}
109+
9110
{{- end -}}

charts/nopo11y-stack/templates/health-check-ingress.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- if and (.Values.nopo11y_ingress.enabled) (eq .Values.nopo11y_ingress.type "istio") }}
2+
{{- if gt (len (include "nopo11y.services" . |fromJsonArray)) 0 }}
3+
{{- if and (.Values.nopo11y_ingress.tls.enabled) (not .Values.nopo11y_ingress.host) }}
4+
{{- fail "if nopo11y_ingress tls is enabled then host is required host can not be empty" }}
5+
{{- end }}
6+
apiVersion: networking.istio.io/v1beta1
7+
kind: Gateway
8+
metadata:
9+
name: {{ .Release.Name }}-gateway
10+
namespace: {{ .Release.Namespace }}
11+
spec:
12+
selector:
13+
{{- toYaml .Values.nopo11y_ingress.istioGatewaySelector |nindent 4 }}
14+
servers:
15+
- port:
16+
{{- if $.Values.nopo11y_ingress.tls.enabled }}
17+
number: 443
18+
name: https
19+
protocol: HTTPS
20+
{{- else }}
21+
number: 80
22+
name: http
23+
protocol: HTTP
24+
{{- end }}
25+
hosts:
26+
{{- if .Values.nopo11y_ingress.host }}
27+
- {{ .Values.nopo11y_ingress.host |quote }}
28+
{{- else }}
29+
- "*"
30+
{{- end }}
31+
{{- if .Values.nopo11y_ingress.tls.enabled }}
32+
tls:
33+
mode: SIMPLE
34+
credentialName: {{ $.Release.Name }}-{{ $.Release.Namespace }}-tls-secret
35+
{{- end }}
36+
{{- end }}
37+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if and (.Values.nopo11y_ingress.enabled) (eq .Values.nopo11y_ingress.type "istio") }}
2+
{{- if .Values.nopo11y_ingress.tls.enabled }}
3+
{{- if gt (len (include "nopo11y.services" . |fromJsonArray)) 0 }}
4+
{{- if or (not .Values.nopo11y_ingress.tls.tlsKey) (not .Values.nopo11y_ingress.tls.tlsCert) }}
5+
{{- fail "If tls is enaled for nopo11y_ingress then tls.tlsKey and tls.tlsCert can not be empyt" }}
6+
{{- end }}
7+
apiVersion: v1
8+
kind: Secret
9+
metadata:
10+
name: {{ .Release.Name }}-{{ .Release.Namespace }}-tls-secret
11+
namespace: {{ .Values.nopo11y_ingress.istioNamespace }}
12+
type: kubernetes.io/tls
13+
data:
14+
tls.crt: |
15+
{{ .Values.nopo11y_ingress.tls.tlsCert }}
16+
tls.key: |
17+
{{ .Values.nopo11y_ingress.tls.tlsKey }}
18+
{{- end }}
19+
{{- end }}
20+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if and (.Values.nopo11y_ingress.enabled) (eq .Values.nopo11y_ingress.type "istio") }}
2+
{{- if gt (len (include "nopo11y.services" . |fromJsonArray)) 0 }}
3+
apiVersion: networking.istio.io/v1beta1
4+
kind: VirtualService
5+
metadata:
6+
name: {{ .Release.Name }}-vs
7+
namespace: {{ .Release.Namespace }}
8+
spec:
9+
hosts:
10+
{{- if .Values.nopo11y_ingress.host }}
11+
- {{ .Values.nopo11y_ingress.host |quote }}
12+
{{- else }}
13+
- "*"
14+
{{- end }}
15+
gateways:
16+
- {{ $.Release.Name }}-gateway
17+
http:
18+
{{- range (include "nopo11y.services" . |fromJsonArray) }}
19+
- match:
20+
- uri:
21+
prefix: {{ .path }}
22+
{{- if hasKey . "rewritePath"}}
23+
rewrite:
24+
uri: {{ .rewritePath }}
25+
{{- end }}
26+
route:
27+
- destination:
28+
host: {{ .name }}
29+
port:
30+
number: {{ .port }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{- if and (.Values.nopo11y_ingress.enabled) (eq .Values.nopo11y_ingress.type "nginx") }}
2+
{{- if gt (len (include "nopo11y.services" . |fromJsonArray)) 0 }}
3+
{{- if and (.Values.nopo11y_ingress.tls.enabled) (not .Values.nopo11y_ingress.host) }}
4+
{{- fail "if nopo11y_ingress tls is enabled host is required host can not be empty" }}
5+
{{- end }}
6+
{{- range (include "nopo11y.services" . |fromJsonArray) }}
7+
apiVersion: networking.k8s.io/v1
8+
kind: Ingress
9+
metadata:
10+
name: {{ .name }}-ingress
11+
namespace: {{ $.Release.Namespace }}
12+
{{- if hasKey . "rewritePath" }}
13+
{{- if contains "nopo11y-health-check" .path }}
14+
annotations:
15+
kubernetes.io/ingress.class: nginx
16+
nginx.ingress.kubernetes.io/rewrite-target: /
17+
nginx.ingress.kubernetes.io/add-base-url : "true"
18+
{{- end }}
19+
{{- else }}
20+
annotations:
21+
nginx.ingress.kubernetes.io/rewrite-target: /$1$2
22+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
23+
nginx.ingress.kubernetes.io/use-regex: "true"
24+
{{- end }}
25+
spec:
26+
{{- if $.Values.nopo11y_ingress.tls.enabled }}
27+
tls:
28+
- hosts:
29+
- {{ $.Values.nopo11y_ingress.host |quote }}
30+
secretName: {{ $.Release.Name }}-{{ $.Release.Namespace }}-tls-secret
31+
{{- end }}
32+
ingressClassName: nginx
33+
rules:
34+
{{- if $.Values.nopo11y_ingress.host }}
35+
- host: {{ $.Values.nopo11y_ingress.host }}
36+
http:
37+
{{- else }}
38+
- http:
39+
{{- end }}
40+
paths:
41+
{{- $path:= (trimPrefix "/" .path) }}
42+
{{- if contains "nopo11y-health-check" .path }}
43+
- path: {{ .path }}
44+
{{- else }}
45+
- path: "/({{ $path }})(/.*){0,}"
46+
{{- end }}
47+
pathType: Prefix
48+
backend:
49+
service:
50+
name: {{ .name }}
51+
port:
52+
number: {{ .port }}
53+
---
54+
{{- end }}
55+
{{- end }}
56+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if and (.Values.nopo11y_ingress.enabled) (eq .Values.nopo11y_ingress.type "nginx") }}
2+
{{- if gt (len (include "nopo11y.services" . |fromJsonArray)) 0 }}
3+
{{- if .Values.nopo11y_ingress.tls.enabled }}
4+
{{- if or (not .Values.nopo11y_ingress.tls.tlsKey) (not .Values.nopo11y_ingress.tls.tlsCert) }}
5+
{{- fail "If tls is enaled for nopo11y_ingress then tls.tlsKey and tls.tlsCert can not be empyt" }}
6+
{{- end }}
7+
apiVersion: v1
8+
kind: Secret
9+
metadata:
10+
name: {{ .Release.Name }}-{{ .Release.Namespace }}-tls-secret
11+
namespace: {{ .Release.Namespace }}
12+
type: kubernetes.io/tls
13+
data:
14+
tls.crt: |
15+
{{ .Values.nopo11y_ingress.tls.tlsCert }}
16+
tls.key: |
17+
{{ .Values.nopo11y_ingress.tls.tlsKey }}
18+
{{- end }}
19+
{{- end }}
20+
{{- end }}

charts/nopo11y-stack/values.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16015,8 +16015,6 @@ kuberhealthy:
1601516015

1601616016
### Nopo11y-health-check
1601716017
nopo11y_health_check:
16018-
ingress:
16019-
enabled: false
1602016018
checks: []
1602116019
# - name: test
1602216020
# image: ghcr.io/znsio/nopo11y/system_health_check:1.0
@@ -16126,3 +16124,23 @@ nopo11y-operator:
1612616124
tolerations: []
1612716125

1612816126
affinity: {}
16127+
16128+
## Ingress for nopo11y-stack components
16129+
nopo11y_ingress:
16130+
## enable or disable ingress for nopo11y-stack components, the default it is disabled
16131+
enabled: false
16132+
## Ingress type either istio or nginx, the default is istio
16133+
type: "istio"
16134+
## DNS or host name to access nopo11y-stack components with.
16135+
host: ""
16136+
## istio gateway selector to select which istio gateway to use.
16137+
## if you set ingress type to istio, check the lables of your istio ingress gateway pod and add it as istioGatewaySelector
16138+
istioGatewaySelector: {}
16139+
# app: gateway
16140+
## if you set ingress type to istio then istio namespace is required, the default is istio-system
16141+
istioNamespace: "istio-system"
16142+
## TLS section for ingress
16143+
tls:
16144+
enabled: false
16145+
tlsKey: ""
16146+
tlsCert: ""

0 commit comments

Comments
 (0)