diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..61a7bed --- /dev/null +++ b/README.adoc @@ -0,0 +1,7 @@ += charts +ccremer's Helm charts repository +:toc: + +toc::[] + +include::charts/znapzend/README.adoc[] diff --git a/README.md b/README.md deleted file mode 100644 index 5da7d79..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# charts -Helm charts repository diff --git a/charts/znapzend/.helmignore b/charts/znapzend/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/znapzend/.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/znapzend/Chart.yaml b/charts/znapzend/Chart.yaml new file mode 100644 index 0000000..4dd0460 --- /dev/null +++ b/charts/znapzend/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +name: znapzend +description: Znapzend Helm Chart for automated ZFS snapshot & replication + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v0.19.1 diff --git a/charts/znapzend/README.adoc b/charts/znapzend/README.adoc new file mode 100644 index 0000000..ff46201 --- /dev/null +++ b/charts/znapzend/README.adoc @@ -0,0 +1,3 @@ +== Znapzend + +Some docs to follow soon. diff --git a/charts/znapzend/templates/NOTES.txt b/charts/znapzend/templates/NOTES.txt new file mode 100644 index 0000000..e4e7dad --- /dev/null +++ b/charts/znapzend/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.metrics.ingress.enabled }} +{{- range $host := .Values.metrics.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.metrics.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.metrics.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "znapzend.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.metrics.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "znapzend.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "znapzend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.metrics.service.port }} +{{- else if contains "ClusterIP" .Values.metrics.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "znapzend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/znapzend/templates/_helpers.tpl b/charts/znapzend/templates/_helpers.tpl new file mode 100644 index 0000000..4c1cd48 --- /dev/null +++ b/charts/znapzend/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "znapzend.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 "znapzend.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 "znapzend.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "znapzend.labels" -}} +helm.sh/chart: {{ include "znapzend.chart" . }} +{{ include "znapzend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "znapzend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "znapzend.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "znapzend.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "znapzend.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/znapzend/templates/ingress.yaml b/charts/znapzend/templates/ingress.yaml new file mode 100644 index 0000000..3556d65 --- /dev/null +++ b/charts/znapzend/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.metrics.ingress.enabled -}} +{{- $fullName := include "znapzend.fullname" . -}} +{{- $svcPort := .Values.metrics.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "znapzend.labels" . | nindent 4 }} + {{- with .Values.metrics.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.metrics.ingress.tls }} + tls: + {{- range .Values.metrics.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.metrics.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/znapzend/templates/secret.yaml b/charts/znapzend/templates/secret.yaml new file mode 100644 index 0000000..48a6295 --- /dev/null +++ b/charts/znapzend/templates/secret.yaml @@ -0,0 +1,25 @@ +{{- if not .Values.ssh.externalSecretName -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "znapzend.fullname" . }} + labels: + {{- include "znapzend.labels" . | nindent 4 }} +stringData: + {{- with .Values.ssh.knownHosts }} + known_hosts: | + {{- range . }} + {{ .host }} {{ .pubKey }} + {{ end }} + {{- end }} + {{- with .Values.ssh.config }} + config: | + {{- . | nindent 4 }} + {{- end }} + {{- with .Values.ssh.identities }} + {{ range $key,$value := . }} + {{- $key }}: | + {{- $value | nindent 4 }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/znapzend/templates/service.yaml b/charts/znapzend/templates/service.yaml new file mode 100644 index 0000000..c80c173 --- /dev/null +++ b/charts/znapzend/templates/service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.metrics.service.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "znapzend.fullname" . }} + labels: + {{- include "znapzend.labels" . | nindent 4 }} +spec: + type: {{ .Values.metrics.service.type }} + ports: + - port: {{ .Values.metrics.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "znapzend.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/znapzend/templates/statefulset.yaml b/charts/znapzend/templates/statefulset.yaml new file mode 100644 index 0000000..7701601 --- /dev/null +++ b/charts/znapzend/templates/statefulset.yaml @@ -0,0 +1,108 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "znapzend.fullname" . }} + labels: + {{- include "znapzend.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "znapzend.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "znapzend.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + livenessProbe: + exec: + command: + - pidof + - znapzend + periodSeconds: 30 + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: zfs + mountPath: /dev/zfs + {{- if or .Values.ssh.identities .Values.ssh.externalSecretName }} + - name: ssh + mountPath: {{ .Values.ssh.path }} + {{- end }} + + {{- if .Values.metrics.enabled }} + {{- with .Values.metrics }} + - name: exporter + image: "{{ .image.repository }}:{{ .image.tag }}" + imagePullPolicy: {{ .image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + env: + {{- if .jobs.register }} + - name: JOBS_REGISTER + value: "{{ .jobs.register | join "," }}" + {{- end }} + {{- range $key, $value := .env }} + - name: {{ $key }} + value: {{ $value }} + {{- end }} + readinessProbe: + httpGet: + path: /health/ready + port: http + failureThreshold: 1 + successThreshold: 1 + initialDelaySeconds: 5 + livenessProbe: + httpGet: + path: /health/alive + port: http + failureThreshold: 1 + successThreshold: 1 + initialDelaySeconds: 5 + resources: + {{- toYaml .resources | nindent 12 }} + {{- end }} + {{- 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 }} + volumes: + - name: zfs + hostPath: + path: "{{ .Values.host.zfsDevice }}" + type: CharDevice + {{- with .Values.ssh }} + {{- if or .identities .externalSecretName }} + - name: ssh + secret: + {{- if .externalSecretName }} + secretName: {{ .externalSecretName }} + {{- else }} + secretName: {{ include "znapzend.fullname" . }} + {{- end }} + defaultMode: 0600 + {{- end }} + {{- end }} diff --git a/charts/znapzend/values.yaml b/charts/znapzend/values.yaml new file mode 100644 index 0000000..fdf5422 --- /dev/null +++ b/charts/znapzend/values.yaml @@ -0,0 +1,77 @@ +# Default values for znapzend. + +replicaCount: 1 + +image: + repository: docker.io/oetiker/znapzend + tag: master + pullPolicy: IfNotPresent +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: + # The current image requires to run privileged in order to access ZFS + allowPrivilegeEscalation: true + privileged: true + +resources: {} + +host: + zfsDevice: /dev/zfs + +ssh: + path: /root/.ssh +# config: | +# Host my-host +# IdentityFile ~/.ssh/my-id +# User myuser +# externalSecretName: my-own-ssh-secret + identities: {} +# id_ed25519: | +# -----BEGIN OPENSSH PRIVATE KEY----- +# ... +# -----END OPENSSH PRIVATE KEY----- +# knownHosts: +# - host: my-host +# pubKey: ssh-ed25519 AAAAC3NzaC... + +metrics: + enabled: true + jobs: + register: [] + env: {} + + image: + repository: docker.io/braindoctor/znapzend-exporter + tag: v0.1.0 + pullPolicy: IfNotPresent + imagePullSecrets: [] + + service: + type: ClusterIP + port: 8080 + + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {}