Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Prometheus Operator: Allow user to expose grafana
Browse files Browse the repository at this point in the history
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 <suraj@kinvolk.io>
  • Loading branch information
surajssd committed May 21, 2020
1 parent 9e3eaf6 commit 14e30a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/components/prometheus-operator/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ 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"`
ExposeGrafana bool

Namespace string `hcl:"namespace,optional"`
EtcdEndpoints []string `hcl:"etcd_endpoints,optional"`

PrometheusOperatorNodeSelector map[string]string `hcl:"prometheus_operator_node_selector,optional"`

Expand Down Expand Up @@ -133,6 +136,11 @@ func (c *component) RenderManifests() (map[string]string, error) {
return nil, errors.Wrap(err, "load chart from assets")
}

// Expose Grafana if the ingress host is not empty.
if c.GrafanaIngressHost != "" {
c.ExposeGrafana = true
}

values, err := util.RenderTemplate(chartValuesTmpl, c)
if err != nil {
return nil, errors.Wrap(err, "render chart values template")
Expand Down
17 changes: 17 additions & 0 deletions pkg/components/prometheus-operator/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ alertmanager:
resources:
requests:
storage: "{{.AlertManagerStorageSize}}"
grafana:
adminPassword: {{.GrafanaAdminPassword}}
testFramework:
Expand All @@ -55,6 +57,21 @@ grafana:
searchNamespace: ALL
rbac:
pspUseAppArmor: false
ingress:
enabled: {{ .ExposeGrafana }}
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}}
Expand Down

0 comments on commit 14e30a9

Please sign in to comment.