From 53db36b0c3a419cf03c63152abd3c89f03a8a3b8 Mon Sep 17 00:00:00 2001 From: Dmitry Chepurovskiy Date: Sun, 19 May 2019 20:22:23 +0300 Subject: [PATCH] Added chart for Contribsys/Faktory Signed-off-by: Dmitry Chepurovskiy --- incubator/faktory/.helmignore | 21 ++++++ incubator/faktory/Chart.yaml | 5 ++ incubator/faktory/README.md | 78 +++++++++++++++++++++ incubator/faktory/templates/NOTES.txt | 19 +++++ incubator/faktory/templates/_helpers.tpl | 32 +++++++++ incubator/faktory/templates/deployment.yaml | 78 +++++++++++++++++++++ incubator/faktory/templates/ingress.yaml | 38 ++++++++++ incubator/faktory/templates/pvc.yaml | 31 ++++++++ incubator/faktory/templates/service.yaml | 23 ++++++ incubator/faktory/values.yaml | 57 +++++++++++++++ 10 files changed, 382 insertions(+) create mode 100644 incubator/faktory/.helmignore create mode 100644 incubator/faktory/Chart.yaml create mode 100644 incubator/faktory/README.md create mode 100644 incubator/faktory/templates/NOTES.txt create mode 100644 incubator/faktory/templates/_helpers.tpl create mode 100644 incubator/faktory/templates/deployment.yaml create mode 100644 incubator/faktory/templates/ingress.yaml create mode 100644 incubator/faktory/templates/pvc.yaml create mode 100644 incubator/faktory/templates/service.yaml create mode 100644 incubator/faktory/values.yaml diff --git a/incubator/faktory/.helmignore b/incubator/faktory/.helmignore new file mode 100644 index 000000000000..f0c131944441 --- /dev/null +++ b/incubator/faktory/.helmignore @@ -0,0 +1,21 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/incubator/faktory/Chart.yaml b/incubator/faktory/Chart.yaml new file mode 100644 index 000000000000..67611deed07e --- /dev/null +++ b/incubator/faktory/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0.0" +description: A Helm chart for contribsys/faktory +name: faktory +version: 0.1.0 diff --git a/incubator/faktory/README.md b/incubator/faktory/README.md new file mode 100644 index 000000000000..c32310b2eb66 --- /dev/null +++ b/incubator/faktory/README.md @@ -0,0 +1,78 @@ +# Faktory Helm Chart + +[Faktory](https://github.com/contribsys/faktory) is an open-source background jobs server written on Golang. It have got clients for different programming languages. + +## TL;DR; + +```console +$ helm install incubator/faktory +``` + +## Introduction + +This chart bootstraps a [Faktory](https://github.com/contribsys/faktory) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release incubator/faktory +``` + +The command above deploys Faktory on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +$ helm delete my-release +``` + +The command above removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following table lists the configurable parameters of the Faktory chart and their default values. + +Parameter | Description | Default +--------- | ----------- | ------- +`image.repository` | faktory image repository | `contribsys/faktory` +`image.tag` | faktory image tag | `1.0.0` +`image.pullPolicy` | faktory image pullPolicy | `IfNotPresent` +`service.type` | service type | `ClusterIP` +`service.ui_port` | service port for WebUI | `80` +`service.commands_port` | service port for commands | `80` +`ingress.enabled` | If true, an ingress will be created for the api | `false` +`ingress.annotations` | ingress annotations | `{}` +`ingress.path` | ingress path | `/` +`ingress.hosts` | ingress hostnames | `[]` +`ingress.tls` | ingress TLS configuration | `[]` +`resources` | resource requests and limits | `{}` +`nodeSelector` | node selector labels for pod assignment | `{}` +`tolerations` | toleration for pod assignment | `[]` +`affinity` | affinity for pod assignment | `{}` +`password` | WebUI Password | `password` +`persistentVolume.enabled` | If true, create a Persistent Volume Claim | `true` +`persistentVolume.accessModes` | Persistent Volume access modes | `ReadWriteOnce` +`persistentVolume.annotations` | Annotations for Persistent Volume Claim | `{}` +`persistentVolume.existingClaim` | Persistent Volume existing claim name | `""` +`persistentVolume.size` | Persistent Volume size | `1Gi` + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install incubator/faktory --name my-release \ + --set api.replicaCount=5 +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install incubator/faktory --name my-release -f values.yaml +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/incubator/faktory/templates/NOTES.txt b/incubator/faktory/templates/NOTES.txt new file mode 100644 index 000000000000..7efed75921f9 --- /dev/null +++ b/incubator/faktory/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "faktory.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 svc -w {{ include "faktory.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "faktory.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + 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 "faktory.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 port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/incubator/faktory/templates/_helpers.tpl b/incubator/faktory/templates/_helpers.tpl new file mode 100644 index 000000000000..1c60505aea47 --- /dev/null +++ b/incubator/faktory/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "faktory.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 "faktory.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 "faktory.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/incubator/faktory/templates/deployment.yaml b/incubator/faktory/templates/deployment.yaml new file mode 100644 index 000000000000..667d69e78e70 --- /dev/null +++ b/incubator/faktory/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ include "faktory.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "faktory.name" . }} + helm.sh/chart: {{ include "faktory.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app.kubernetes.io/name: {{ include "faktory.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "faktory.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - /faktory + - -b + - :7419 + - -w + - :7420 + - -e + - production + env: + - name: FAKTORY_PASSWORD + value: {{ .Values.password | quote }} + ports: + - name: commands + containerPort: 7419 + protocol: TCP + - name: ui + containerPort: 7420 + protocol: TCP + livenessProbe: + httpGet: + path: /static + port: ui + readinessProbe: + httpGet: + path: /static + port: ui + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: + - name: data + mountPath: /var/lib/faktory + volumes: + - name: data + {{- if .Values.persistentVolume.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.persistentVolume.existingClaim }}{{ .Values.persistentVolume.existingClaim }}{{- else }}{{ template "faktory.fullname" . }}{{- end }} + {{- else }} + emptyDir: {} + {{- 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 }} diff --git a/incubator/faktory/templates/ingress.yaml b/incubator/faktory/templates/ingress.yaml new file mode 100644 index 000000000000..a96cfd851be0 --- /dev/null +++ b/incubator/faktory/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "faktory.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "faktory.name" . }} + helm.sh/chart: {{ include "faktory.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: ui + {{- end }} +{{- end }} diff --git a/incubator/faktory/templates/pvc.yaml b/incubator/faktory/templates/pvc.yaml new file mode 100644 index 000000000000..5fd029c4428a --- /dev/null +++ b/incubator/faktory/templates/pvc.yaml @@ -0,0 +1,31 @@ +{{- if and .Values.persistentVolume.enabled (not .Values.persistentVolume.existingClaim) -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ template "faktory.fullname" . }} + annotations: + "helm.sh/resource-policy": keep + {{- if .Values.persistentVolume.annotations }} +{{ toYaml .Values.persistentVolume.annotations | indent 4 }} + {{- end }} + labels: + app.kubernetes.io/name: {{ include "faktory.name" . }} + helm.sh/chart: {{ include "faktory.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + accessModes: +{{- range .Values.persistentVolume.accessModes }} + - {{ . | quote }} +{{- end }} + resources: + requests: + storage: {{ .Values.persistentVolume.size | quote }} +{{- if .Values.persistentVolume.storageClass }} +{{- if (eq "-" .Values.persistentVolume.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistentVolume.storageClass }}" +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/incubator/faktory/templates/service.yaml b/incubator/faktory/templates/service.yaml new file mode 100644 index 000000000000..251b6b4907aa --- /dev/null +++ b/incubator/faktory/templates/service.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "faktory.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "faktory.name" . }} + helm.sh/chart: {{ include "faktory.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.commands_port }} + targetPort: commands + protocol: TCP + name: commands + - port: {{ .Values.service.ui_port }} + targetPort: ui + protocol: TCP + name: ui + selector: + app.kubernetes.io/name: {{ include "faktory.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/incubator/faktory/values.yaml b/incubator/faktory/values.yaml new file mode 100644 index 000000000000..4bbf8da38887 --- /dev/null +++ b/incubator/faktory/values.yaml @@ -0,0 +1,57 @@ +# Default values for faktory. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: contribsys/faktory + tag: 1.0.0 + pullPolicy: IfNotPresent + +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + ui_port: 80 + commands_port: 7419 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +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: {} + +password: "password" + +persistentVolume: + enabled: true + accessModes: + - ReadWriteOnce + annotations: {} + existingClaim: "" + size: 1Gi