From 1c1732895b8990a75901fb0d6197ada255dad884 Mon Sep 17 00:00:00 2001 From: Tomy Guichard Date: Sat, 18 Jun 2022 20:12:57 +0200 Subject: [PATCH] Add Helm Chart --- charts/livebox-exporter/.helmignore | 23 +++++++ charts/livebox-exporter/Chart.yaml | 6 ++ charts/livebox-exporter/templates/NOTES.txt | 1 + .../livebox-exporter/templates/_helpers.tpl | 62 +++++++++++++++++ .../templates/deployment.yaml | 62 +++++++++++++++++ charts/livebox-exporter/templates/secret.yaml | 11 +++ .../livebox-exporter/templates/service.yaml | 17 +++++ .../templates/serviceaccount.yaml | 12 ++++ charts/livebox-exporter/values.yaml | 69 +++++++++++++++++++ 9 files changed, 263 insertions(+) create mode 100644 charts/livebox-exporter/.helmignore create mode 100644 charts/livebox-exporter/Chart.yaml create mode 100644 charts/livebox-exporter/templates/NOTES.txt create mode 100644 charts/livebox-exporter/templates/_helpers.tpl create mode 100644 charts/livebox-exporter/templates/deployment.yaml create mode 100644 charts/livebox-exporter/templates/secret.yaml create mode 100644 charts/livebox-exporter/templates/service.yaml create mode 100644 charts/livebox-exporter/templates/serviceaccount.yaml create mode 100644 charts/livebox-exporter/values.yaml diff --git a/charts/livebox-exporter/.helmignore b/charts/livebox-exporter/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/livebox-exporter/.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/livebox-exporter/Chart.yaml b/charts/livebox-exporter/Chart.yaml new file mode 100644 index 0000000..b3eb611 --- /dev/null +++ b/charts/livebox-exporter/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: livebox-exporter +description: A prometheus exporter for Livebox +type: application +version: 0.1.0 +appVersion: "v0.1.0" diff --git a/charts/livebox-exporter/templates/NOTES.txt b/charts/livebox-exporter/templates/NOTES.txt new file mode 100644 index 0000000..0247182 --- /dev/null +++ b/charts/livebox-exporter/templates/NOTES.txt @@ -0,0 +1 @@ +Installation successful \ No newline at end of file diff --git a/charts/livebox-exporter/templates/_helpers.tpl b/charts/livebox-exporter/templates/_helpers.tpl new file mode 100644 index 0000000..24efb25 --- /dev/null +++ b/charts/livebox-exporter/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "livebox-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 "livebox-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 "livebox-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "livebox-exporter.labels" -}} +helm.sh/chart: {{ include "livebox-exporter.chart" . }} +{{ include "livebox-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "livebox-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "livebox-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "livebox-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "livebox-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/livebox-exporter/templates/deployment.yaml b/charts/livebox-exporter/templates/deployment.yaml new file mode 100644 index 0000000..be2aa8d --- /dev/null +++ b/charts/livebox-exporter/templates/deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "livebox-exporter.fullname" . }} + labels: + {{- include "livebox-exporter.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "livebox-exporter.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "livebox-exporter.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "livebox-exporter.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: ADMIN_PASSWORD + valueFrom: + secretKeyRef: + {{- if .Values.adminPassword.secretKeyRef }} + name: {{ .Values.adminPassword.secretKeyRef.name}} + key: {{ .Values.adminPassword.secretKeyRef.key }} + {{- else }} + name: {{ include "livebox-exporter.fullname" . }}-admin + key: password + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/livebox-exporter/templates/secret.yaml b/charts/livebox-exporter/templates/secret.yaml new file mode 100644 index 0000000..f2f0c3b --- /dev/null +++ b/charts/livebox-exporter/templates/secret.yaml @@ -0,0 +1,11 @@ +{{- if not .Values.adminPassword.secretKeyRef }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "livebox-exporter.fullname" . }}-admin + labels: + {{- include "livebox-exporter.labels" . | nindent 4 }} +type: Opaque +data: + password: {{ .Values.adminPassword.value | b64enc }} +{{- end }} \ No newline at end of file diff --git a/charts/livebox-exporter/templates/service.yaml b/charts/livebox-exporter/templates/service.yaml new file mode 100644 index 0000000..b8e648f --- /dev/null +++ b/charts/livebox-exporter/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "livebox-exporter.fullname" . }} + labels: + {{- include "livebox-exporter.labels" . | nindent 4 }} + annotations: + prometheus.io/scrape: "true" +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "livebox-exporter.selectorLabels" . | nindent 4 }} diff --git a/charts/livebox-exporter/templates/serviceaccount.yaml b/charts/livebox-exporter/templates/serviceaccount.yaml new file mode 100644 index 0000000..904d5b4 --- /dev/null +++ b/charts/livebox-exporter/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "livebox-exporter.serviceAccountName" . }} + labels: + {{- include "livebox-exporter.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/livebox-exporter/values.yaml b/charts/livebox-exporter/values.yaml new file mode 100644 index 0000000..98120a7 --- /dev/null +++ b/charts/livebox-exporter/values.yaml @@ -0,0 +1,69 @@ +# Default values for livebox-exporter. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/tomy2e/livebox-exporter + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +adminPassword: + secretKeyRef: {} + # name: "" + # key: "" + + value: "changeme" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: + {} + # fsGroup: 2000 + +securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +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: {}