Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm Chart Upgrades #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kubernetes/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
description: Grafana-Exporter Helm Chart
name: grafana-exporter
version: 0.1.0
version: 0.1.1
5 changes: 5 additions & 0 deletions kubernetes/helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The Grafana Operator has been installed. Check its status by running:
kubectl --namespace {{ .Release.Namespace }} get pods -l "app={{ template "grafana-exporter.name" . }},release={{ .Release.Name }}"

Visit https://github.com/tsloughter/grafana-operator for instructions on how
to create & configure Grafana Dashboards and Datasources using the Operator.
32 changes: 32 additions & 0 deletions kubernetes/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "grafana-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "grafana-exporter.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "grafana-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
21 changes: 21 additions & 0 deletions kubernetes/helm/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.rbacEnable }}
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1beta1" }}
apiVersion: rbac.authorization.k8s.io/v1beta1
{{- else if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1alpha1" }}
apiVersion: rbac.authorization.k8s.io/v1alpha1
{{- end }}
kind: ClusterRole
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious - why ClusterRole and not a Role?

metadata:
labels:
app: {{ template "grafana-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
operator: {{ template "grafana-exporter.name" . }}
release: {{ .Release.Name }}
name: {{ template "grafana-exporter.fullname" . }}
rules:
- apiGroups: [""]
resources:
- configmaps
verbs: ["get", "watch", "list"]
{{- end }}
24 changes: 24 additions & 0 deletions kubernetes/helm/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.rbacEnable }}
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1beta1" }}
apiVersion: rbac.authorization.k8s.io/v1beta1
{{- else if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1alpha1" }}
apiVersion: rbac.authorization.k8s.io/v1alpha1
{{- end }}
kind: ClusterRoleBinding
metadata:
labels:
app: {{ template "grafana-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
operator: {{ template "grafana-exporter.name" . }}
release: {{ .Release.Name }}
name: {{ template "grafana-exporter.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "grafana-exporter.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "grafana-exporter.fullname" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
91 changes: 52 additions & 39 deletions kubernetes/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,61 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "grafana-exporter.fullname" . }}
labels:
k8s-app: grafana-operator
operator: grafana
name: grafana-operator
app: {{ template "grafana-exporter.name" . }}
chart: {{ template "grafana-exporter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
operator: {{ template "grafana-exporter.name" . }}
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "grafana-exporter.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
k8s-app: grafana-operator
operator: grafana
app: {{ template "grafana-exporter.name" . }}
release: {{ .Release.Name }}
operator: {{ template "grafana-exporter.name" . }}
spec:
containers:
- name: grafana-operator
image: {{ .Values.grafana.watcher.image }}
imagePullPolicy: IfNotPresent
args:
- "-grafana-url={{ .Values.grafana.url }}"
ports:
- containerPort: {{ .Values.grafana.watcher.containerPort }}
name: http
protocol: TCP
env:
- name: GRAFANA_USER
valueFrom:
secretKeyRef:
name: grafana-auth
key: username
- name: GRAFANA_PASSWORD
valueFrom:
secretKeyRef:
name: grafana-auth
key: password
resources:
{{ toYaml .Values.grafana.watcher.resources | indent 11 }}
restartPolicy: Always
terminationGracePeriodSeconds: 30
{{- if .Values.grafana.watcher.serviceAccount }}
serviceAccountName: {{ .Values.grafana.watcher.serviceAccount }}
{{- end }}
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-grafana-url={{ required ".Values.url is required" .Values.url }}"
ports:
- name: http
containerPort: 8080
protocol: TCP
env:
- name: GRAFANA_USER
valueFrom:
secretKeyRef:
name: {{ template "grafana-exporter.fullname" . }}
key: username
- name: GRAFANA_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "grafana-exporter.fullname" . }}
key: password
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.rbacEnable }}
serviceAccountName: {{ template "grafana-exporter.fullname" . }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
16 changes: 10 additions & 6 deletions kubernetes/helm/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{{- if .Values.auth.enable }}
apiVersion: v1
kind: Secret
metadata:
name: grafana-auth
name: {{ template "grafana-exporter.fullname" . }}
labels:
app: {{ .Values.name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
app: {{ template "grafana-exporter.name" . }}
chart: {{ template "grafana-exporter.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
operator: {{ template "grafana-exporter.name" . }}
type: Opaque
data:
username: {{ b64enc .Values.grafana.auth.username }}
password: {{ b64enc .Values.grafana.auth.password }}
username: {{ required ".Values.auth.username is required" .Values.auth.username | b64enc }}
password: {{ required ".Values.auth.password is required" .Values.auth.password | b64enc }}
{{- end }}
12 changes: 12 additions & 0 deletions kubernetes/helm/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.rbacEnable }}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: {{ template "grafana-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
operator: {{ template "grafana-exporter.name" . }}
name: {{ template "grafana-exporter.fullname" . }}
{{- end }}
52 changes: 36 additions & 16 deletions kubernetes/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
grafana:
url: ""
auth:
username: ""
password: ""
watcher:
image: gavind/grafana-operator:201803061638
containerPort: 3000
resources: {}
serviceAccount:
# limits:
# cpu: 200m
# memory: 300Mi
# requests:
# cpu: 100m
# memory: 50Mi
# Default values for grafana-operator.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

rbacEnable: true

url: ""
auth:
enable: true
username: ""
password: ""

replicaCount: 1

image:
repository: gavind/grafana-operator
tag: "201803231635"
pullPolicy: IfNotPresent

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}