From 5ebf39e0ae7ce4e3411095f7831aa8557a87a81c Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Tue, 5 Oct 2021 18:05:08 -0400 Subject: [PATCH] feat: init --- charts/gotify/.helmignore | 23 +++ charts/gotify/Chart.yaml | 24 +++ charts/gotify/templates/NOTES.txt | 22 +++ charts/gotify/templates/_helpers.tpl | 190 ++++++++++++++++++++++++ charts/gotify/templates/configmap.yaml | 27 ++++ charts/gotify/templates/deployment.yaml | 69 +++++++++ charts/gotify/templates/secrets.yaml | 8 + charts/gotify/templates/service.yaml | 15 ++ charts/gotify/values.yaml | 91 ++++++++++++ 9 files changed, 469 insertions(+) create mode 100644 charts/gotify/.helmignore create mode 100644 charts/gotify/Chart.yaml create mode 100644 charts/gotify/templates/NOTES.txt create mode 100644 charts/gotify/templates/_helpers.tpl create mode 100644 charts/gotify/templates/configmap.yaml create mode 100644 charts/gotify/templates/deployment.yaml create mode 100644 charts/gotify/templates/secrets.yaml create mode 100644 charts/gotify/templates/service.yaml create mode 100644 charts/gotify/values.yaml diff --git a/charts/gotify/.helmignore b/charts/gotify/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/gotify/.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/gotify/Chart.yaml b/charts/gotify/Chart.yaml new file mode 100644 index 0000000..d55fc78 --- /dev/null +++ b/charts/gotify/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: gotify +description: A Gotify Helm chart for Kubernetes + +# 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. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "latest" diff --git a/charts/gotify/templates/NOTES.txt b/charts/gotify/templates/NOTES.txt new file mode 100644 index 0000000..60d9f15 --- /dev/null +++ b/charts/gotify/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "gotify.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.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 "gotify.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "gotify.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "gotify.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/gotify/templates/_helpers.tpl b/charts/gotify/templates/_helpers.tpl new file mode 100644 index 0000000..e553847 --- /dev/null +++ b/charts/gotify/templates/_helpers.tpl @@ -0,0 +1,190 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "gotify.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 "gotify.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 "gotify.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "gotify.labels" -}} +helm.sh/chart: {{ include "gotify.chart" . }} +{{ include "gotify.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "gotify.selectorLabels" -}} +app.kubernetes.io/name: {{ include "gotify.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "gotify.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "gotify.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Expand the name of the chart. +*/}} +{{- define "gotify.worker.name" -}} +{{- default .Chart.Name .Values.worker.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 "gotify.worker.fullname" -}} +{{- if .Values.worker.fullnameOverride }} +{{- .Values.worker.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.worker.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 "gotify.worker.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "gotify.worker.labels" -}} +helm.sh/chart: {{ include "gotify.worker.chart" . }} +{{ include "gotify.worker.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "gotify.worker.selectorLabels" -}} +app.kubernetes.io/name: {{ include "gotify.worker.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "gotify.worker.serviceAccountName" -}} +{{- if .Values.worker.serviceAccount.create }} +{{- default (include "gotify.worker.fullname" .) .Values.worker.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.worker.serviceAccount.name }} +{{- end }} +{{- end }} + + + +{{/* +Expand the name of the chart. +*/}} +{{- define "gotify.mongo.name" -}} +{{- default .Chart.Name .Values.mongo.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 "gotify.mongo.fullname" -}} +{{- if .Values.mongo.fullnameOverride }} +{{- .Values.mongo.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.mongo.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 "gotify.mongo.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "gotify.mongo.labels" -}} +helm.sh/chart: {{ include "gotify.mongo.chart" . }} +{{ include "gotify.mongo.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "gotify.mongo.selectorLabels" -}} +app.kubernetes.io/name: {{ include "gotify.mongo.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "gotify.mongo.serviceAccountName" -}} +{{- if .Values.mongo.serviceAccount.create }} +{{- default (include "gotify.mongo.fullname" .) .Values.mongo.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.mongo.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/gotify/templates/configmap.yaml b/charts/gotify/templates/configmap.yaml new file mode 100644 index 0000000..caec460 --- /dev/null +++ b/charts/gotify/templates/configmap.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + # TODO: truc full name ici ? + name: "gotify" + # Pas de labels ? +data: + GOTIFY_DATABASE_CONNECTION: data/gotify.db + GOTIFY_DATABASE_DIALECT: sqlite3 + GOTIFY_PASSSTRENGTH: "10" + GOTIFY_PLUGINSDIR: data/plugins + GOTIFY_SERVER_KEEPALIVEPERIODSECONDS: "0" + GOTIFY_SERVER_LISTENADDR: "" + GOTIFY_SERVER_PORT: "80" + GOTIFY_SERVER_RESPONSEHEADERS: 'X-Custom-Header: "custom value"' + GOTIFY_SERVER_SSL_CERTFILE: "" + GOTIFY_SERVER_SSL_CERTKEY: "" + GOTIFY_SERVER_SSL_ENABLED: "false" + GOTIFY_SERVER_SSL_LETSENCRYPT_ACCEPTTOS: "false" + GOTIFY_SERVER_SSL_LETSENCRYPT_CACHE: certs + GOTIFY_SERVER_SSL_LETSENCRYPT_ENABLED: "false" + GOTIFY_SERVER_SSL_LISTENADDR: "" + GOTIFY_SERVER_SSL_PORT: "443" + GOTIFY_SERVER_SSL_REDIRECTTOHTTPS: "true" + GOTIFY_SERVER_STREAM_PINGPERIODSECONDS: "45" + GOTIFY_UPLOADEDIMAGESDIR: data/images + TZ: America/Los_Angeles diff --git a/charts/gotify/templates/deployment.yaml b/charts/gotify/templates/deployment.yaml new file mode 100644 index 0000000..89bbd05 --- /dev/null +++ b/charts/gotify/templates/deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fullname" . }} + labels: + {{- include "labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + # TODO: il manque strategy.type = RollingUpdate + selector: + matchLabels: + {{- include "selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} + 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 }} + env: + - configMapRef: + name: {{ include "fullname" . }} + - secretRef: + name: {{ include "fullname" . }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + # TODO: pas de volume mount ? + # TODO: ça sert à quoi encore ça ? :) + #resources: + # {{- toYaml .Values.resources | nindent 12 }} + {{- 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/gotify/templates/secrets.yaml b/charts/gotify/templates/secrets.yaml new file mode 100644 index 0000000..dbd6101 --- /dev/null +++ b/charts/gotify/templates/secrets.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + # TODO: pas de label ici ? + name: {{ $fullName }} +data: + user: {{ .Values.user }} + pass: {{ .Values.pass }} diff --git a/charts/gotify/templates/service.yaml b/charts/gotify/templates/service.yaml new file mode 100644 index 0000000..c00186b --- /dev/null +++ b/charts/gotify/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fullname" . }} + labels: + {{- include "labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "selectorLabels" . | nindent 4 }} diff --git a/charts/gotify/values.yaml b/charts/gotify/values.yaml new file mode 100644 index 0000000..771aed6 --- /dev/null +++ b/charts/gotify/values.yaml @@ -0,0 +1,91 @@ +# Default values for gotify. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: docker.io/gotify/server:2.1.0 + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" +automountServiceAccountToken: false + +serviceAccount: + # Specifies whether a service account should be created + create: false + # 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: "gotify" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: "ClusterIP" + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + backend: + serviceName: chart-example.local + servicePort: 80 + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressroute: + enabled: false + host: 'chart-example.local' + adminauth: 'dXNlcjpwYXNzd29yZA==' + tls: [] + annotations: {} + +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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 1 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}