From 8f36081623a234e9d7f602a8f7ff61c5f7a7d63a Mon Sep 17 00:00:00 2001 From: Suraj Deshmukh Date: Thu, 21 May 2020 16:47:03 +0530 Subject: [PATCH] Prometheus Operator: Allow user to expose grafana This commit adds a new variable `grafana_ingress_host` where user can provide the Ingress Host URL to expose Grafana on. Signed-off-by: Suraj Deshmukh --- pkg/components/prometheus-operator/component.go | 8 +++++--- pkg/components/prometheus-operator/template.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pkg/components/prometheus-operator/component.go b/pkg/components/prometheus-operator/component.go index d8add54fa..f15729cdc 100644 --- a/pkg/components/prometheus-operator/component.go +++ b/pkg/components/prometheus-operator/component.go @@ -46,9 +46,11 @@ type CoreDNS struct { } type component struct { - GrafanaAdminPassword string `hcl:"grafana_admin_password,attr"` - Namespace string `hcl:"namespace,optional"` - EtcdEndpoints []string `hcl:"etcd_endpoints,optional"` + GrafanaAdminPassword string `hcl:"grafana_admin_password,attr"` + GrafanaIngressHost string `hcl:"grafana_ingress_host,optional"` + + Namespace string `hcl:"namespace,optional"` + EtcdEndpoints []string `hcl:"etcd_endpoints,optional"` PrometheusOperatorNodeSelector map[string]string `hcl:"prometheus_operator_node_selector,optional"` diff --git a/pkg/components/prometheus-operator/template.go b/pkg/components/prometheus-operator/template.go index bc518c6c6..6f08400d5 100644 --- a/pkg/components/prometheus-operator/template.go +++ b/pkg/components/prometheus-operator/template.go @@ -46,6 +46,8 @@ alertmanager: resources: requests: storage: "{{.AlertManagerStorageSize}}" + + grafana: adminPassword: {{.GrafanaAdminPassword}} testFramework: @@ -55,6 +57,21 @@ grafana: searchNamespace: ALL rbac: pspUseAppArmor: false + + ingress: + enabled: {{printf "%t" (ne .GrafanaIngressHost "")}} + annotations: + kubernetes.io/ingress.class: contour + kubernetes.io/tls-acme: "true" + cert-manager.io/cluster-issuer: "letsencrypt-production" + hosts: + - {{ .GrafanaIngressHost }} + tls: + - hosts: + - {{ .GrafanaIngressHost }} + secretName: {{ .GrafanaIngressHost }}-tls + + kubeEtcd: enabled: {{.Monitor.Etcd}} endpoints: {{.EtcdEndpoints}}