Skip to content

Commit

Permalink
[znapzend] Add first playground chart with znapzend
Browse files Browse the repository at this point in the history
  • Loading branch information
ccremer committed Feb 29, 2020
1 parent 1b35f1e commit 725fece
Show file tree
Hide file tree
Showing 12 changed files with 406 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
= charts
ccremer's Helm charts repository
:toc:

toc::[]

include::charts/znapzend/README.adoc[]
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

23 changes: 23 additions & 0 deletions charts/znapzend/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
21 changes: 21 additions & 0 deletions charts/znapzend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions charts/znapzend/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
== Znapzend

Some docs to follow soon.
21 changes: 21 additions & 0 deletions charts/znapzend/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 }}
63 changes: 63 additions & 0 deletions charts/znapzend/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}
41 changes: 41 additions & 0 deletions charts/znapzend/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 25 additions & 0 deletions charts/znapzend/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
17 changes: 17 additions & 0 deletions charts/znapzend/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
108 changes: 108 additions & 0 deletions charts/znapzend/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading

0 comments on commit 725fece

Please sign in to comment.