Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dragonfly/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: dragonfly
description: "a modern superfast in-memory datastore, fully compatible with Redis and Memcached APIs"

version: v1.20.1
appVersion: "v1.20.1"
62 changes: 62 additions & 0 deletions dragonfly/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "dragonfly.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 "dragonfly.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 "dragonfly.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "dragonfly.labels" -}}
helm.sh/chart: {{ include "dragonfly.chart" . }}
{{ include "dragonfly.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "dragonfly.selectorLabels" -}}
app.kubernetes.io/name: {{ include "dragonfly.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "dragonfly.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "dragonfly.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
132 changes: 132 additions & 0 deletions dragonfly/templates/_pod.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{{- define "dragonfly.volumemounts" -}}
{{- if or (.Values.storage.enabled) (.Values.extraVolumeMounts) (.Values.tls.enabled) }}
volumeMounts:
{{- if .Values.storage.enabled }}
- mountPath: /data
name: "{{ .Release.Name }}-data"
{{- end }}
{{- if and .Values.tls .Values.tls.enabled }}
- mountPath: /etc/dragonfly/tls
name: tls
{{- end }}
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | trim | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}

{{- define "dragonfly.pod" -}}
{{- if ne .Values.priorityClassName "" }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | trim | nindent 2 -}}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | trim | nindent 2 -}}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | trim | nindent 2 -}}
{{- end }}
serviceAccountName: {{ include "dragonfly.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | trim | nindent 2 }}
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | trim | nindent 2 }}
{{- end }}
{{- with .Values.initContainers }}
initContainers:
{{- if eq (typeOf .) "string" }}
{{- tpl . $ | trim | nindent 2 }}
{{- else }}
{{- toYaml . | trim | nindent 2 }}
{{- end }}
{{- end }}
containers:
{{- with .Values.extraContainers }}
{{- if eq (typeOf .) "string" -}}
{{- tpl . $ | trim | nindent 2 }}
{{- else }}
{{- toYaml . | trim | nindent 2 }}
{{- end }}
{{- end }}
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | trim | nindent 6 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: dragonfly
containerPort: 6379
protocol: TCP
{{- with .Values.probes }}
{{- toYaml . | trim | nindent 4 }}
{{- end }}
{{- with .Values.command }}
command:
{{- toYaml . | trim | nindent 6 }}
{{- end }}
args:
- "--alsologtostderr"
{{- with .Values.extraArgs }}
{{- toYaml . | trim | nindent 6 }}
{{- end }}
{{- if .Values.tls.enabled }}
- "--tls"
- "--tls_cert_file=/etc/dragonfly/tls/tls.crt"
- "--tls_key_file=/etc/dragonfly/tls/tls.key"
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | trim | nindent 6 }}
{{- end }}
{{- include "dragonfly.volumemounts" . | trim | nindent 4 }}
{{- if .Values.passwordFromSecret.enable }}
{{- $appVersion := .Chart.AppVersion | trimPrefix "v" }}
{{- $imageTag := .Values.image.tag | trimPrefix "v" }}
{{- $effectiveVersion := $appVersion }}
{{- if and $imageTag (ne $imageTag "") }}
{{- $effectiveVersion = $imageTag }}
{{- end }}
env:
{{- if semverCompare ">=1.14.0" $effectiveVersion }}
- name: DFLY_requirepass
{{- else }}
- name: DFLY_PASSWORD
{{- end }}
valueFrom:
secretKeyRef:
name: {{ .Values.passwordFromSecret.existingSecret.name }}
key: {{ .Values.passwordFromSecret.existingSecret.key }}
{{- end }}

{{- if or (.Values.tls.enabled) (.Values.extraVolumes) }}
volumes:
{{- if and .Values.tls .Values.tls.enabled }}
{{- if .Values.tls.existing_secret }}
- name: tls
secret:
secretName: {{ .Values.tls.existing_secret }}
{{- else if .Values.tls.createCerts }}
- name: tls
secret:
secretName: '{{ include "dragonfly.fullname" . }}-server-tls'
{{- else }}
- name: tls
secret:
secretName: {{ include "dragonfly.fullname" . }}-tls
{{- end }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | trim | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
31 changes: 31 additions & 0 deletions dragonfly/templates/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if and .Values.tls.enabled .Values.tls.createCerts }}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "dragonfly.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dragonfly.labels" . | nindent 4 }}
spec:
commonName: '{{ include "dragonfly.fullname" . }}'
dnsNames:
- '*.{{ include "dragonfly.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local'
- '{{ include "dragonfly.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local'
- '{{ include "dragonfly.fullname" . }}.{{ .Release.Namespace }}.svc'
- '{{ include "dragonfly.fullname" . }}.{{ .Release.Namespace }}'
- '{{ include "dragonfly.fullname" . }}'
- localhost
duration: {{ required "tls.duration is required, if createCerts is enabled" .Values.tls.duration }}
ipAddresses:
- 127.0.0.1
issuerRef:
kind: {{ required "tls.issuer.kind is required, if createCerts is enabled" .Values.tls.issuer.kind }}
name: {{ required "tls.issuer.name is required, if createCerts is enabled" .Values.tls.issuer.name }}
group: {{ .Values.tls.issuer.group }}
secretName: '{{ include "dragonfly.fullname" . }}-server-tls'
usages:
- client auth
- server auth
- signing
- key encipherment
{{- end }}
33 changes: 33 additions & 0 deletions dragonfly/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if not .Values.storage.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "dragonfly.fullname" .}}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dragonfly.labels" . | nindent 4 }}


spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "dragonfly.selectorLabels" . | nindent 6 }}

template:
metadata:
annotations:
{{- if and (.Values.tls.enabled) (not .Values.tls.existing_secret) }}
checksum/tls-secret: {{ include (print $.Template.BasePath "/tls-secret.yaml") . | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "dragonfly.selectorLabels" . | nindent 8 }}
spec:
{{- include "dragonfly.pod" . | trim | nindent 6 }}
{{- end }}



19 changes: 19 additions & 0 deletions dragonfly/templates/metrics-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "dragonfly.fullname" . }}-metrics
namespace: {{ .Release.Namespace }}
labels:
{{- include "dragonfly.labels" . | nindent 4 }}
type: metrics
spec:
type: {{ .Values.service.metrics.serviceType }}
ports:
- name: {{ .Values.service.metrics.portName }}
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
protocol: TCP
selector:
{{- include "dragonfly.selectorLabels" . | nindent 4 }}
{{- end }}
14 changes: 14 additions & 0 deletions dragonfly/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.serviceMonitor.enabled .Values.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "dragonfly.fullname" . }}-metrics
namespace: {{ .Values.prometheusRule.namespace | default .Release.Namespace }}
labels:
{{- include "dragonfly.labels" . | nindent 4 }}
spec:
groups:
- name: {{ template "dragonfly.name" . }}
rules:
{{- toYaml .Values.prometheusRule.spec | nindent 6 }}
{{- end }}
26 changes: 26 additions & 0 deletions dragonfly/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "dragonfly.fullname" . }}
namespace: {{ .Release.Namespace }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- with .Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "dragonfly.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- if and (eq .Values.service.type "LoadBalancer") (ne .Values.service.loadBalancerIP "") }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: dragonfly
protocol: TCP
name: dragonfly
selector:
{{- include "dragonfly.selectorLabels" . | nindent 4 }}
13 changes: 13 additions & 0 deletions dragonfly/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dragonfly.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "dragonfly.labels" . | nindent 4 }}
{{- end }}
37 changes: 37 additions & 0 deletions dragonfly/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if .Values.storage.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "dragonfly.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dragonfly.labels" . | nindent 4 }}
spec:
serviceName: {{ .Release.Name }}
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "dragonfly.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- if and (.Values.tls.enabled) (not .Values.tls.existing_secret) }}
checksum/tls-secret: {{ include (print $.Template.BasePath "/tls-secret.yaml") . | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "dragonfly.selectorLabels" . | nindent 8 }}
spec:
{{- include "dragonfly.pod" . | trim | nindent 6 }}
volumeClaimTemplates:
- metadata:
name: "{{ .Release.Name }}-data"
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: {{ .Values.storage.storageClassName }}
resources:
requests:
storage: {{ .Values.storage.requests }}
{{- end }}
Loading