Skip to content

Commit

Permalink
Add a helm chart for garnet (microsoft#438)
Browse files Browse the repository at this point in the history
* Add a helm chart for garnet

Signed-off-by: babykart <babykart@gmail.com>

* Remove default password auth

Signed-off-by: babykart <babykart@gmail.com>

* Generate README.md

Signed-off-by: babykart <babykart@gmail.com>

---------

Signed-off-by: babykart <babykart@gmail.com>
Co-authored-by: Badrish Chandramouli <badrishc@microsoft.com>
Co-authored-by: vazois <96085550+vazois@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 12, 2024
1 parent 93145ee commit 91544e1
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 0 deletions.
1 change: 1 addition & 0 deletions charts/garnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/
23 changes: 23 additions & 0 deletions charts/garnet/.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/
20 changes: 20 additions & 0 deletions charts/garnet/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v2
name: garnet
description: A Helm chart for Microsoft garnet
type: application
version: 0.1.0
appVersion: 1.0.12
home: https://github.com/microsoft/garnet
icon: https://avatars.githubusercontent.com/u/6154722?s=200&v=4

keywords:
- garnet
- database
- key
- value
- in-memory

sources:
- https://github.com/microsoft/garnet.git

maintainers: []
54 changes: 54 additions & 0 deletions charts/garnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# garnet

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.12](https://img.shields.io/badge/AppVersion-1.0.12-informational?style=flat-square)

A Helm chart for Microsoft garnet

**Homepage:** <https://github.com/microsoft/garnet>

## Source Code

* <https://github.com/microsoft/garnet.git>

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Affinity |
| containers.args | list | `["--port","6379","-m","128m","-i","128m"]` | Containers args |
| containers.livenessProbe | object | `{}` | Containers livenessProbe |
| containers.port | int | `6379` | Containers port |
| containers.readinessProbe | object | `{}` | Containers livenessProbe |
| dnsConfig | object | `{}` | DNS config |
| dnsPolicy | string | `"ClusterFirst"` | DNS policy |
| extraVolumeMounts | list | `[]` | Extra Volume Mounts |
| extraVolumes | list | `[]` | Extra Volumes |
| fullnameOverride | string | `""` | Chart full name override |
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy |
| image.registry | string | `"ghcr.io"` | Image registry |
| image.repository | string | `"microsoft/garnet"` | Image repository |
| image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. |
| imagePullSecrets | list | `[]` | Image pull secrets |
| initContainers | list | `[]` | Init containers |
| nameOverride | string | `""` | Chart name override |
| nodeSelector | object | `{}` | Node Selector labels |
| persistence.enabled | bool | `false` | persistence enabled |
| podAnnotations | object | `{}` | Pod annotations |
| podSecurityContext | object | `{}` | Pod Security Context |
| resources | object | `{}` | Resources |
| securityContext | object | `{}` | Security Context |
| service.annotations | object | `{}` | Service annotations |
| service.port | int | `6379` | Service port |
| service.type | string | `"ClusterIP"` | Service type |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `false` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| serviceAccount.token | bool | `false` | Creates the token object |
| statefulSet.annotations | object | `{}` | StatefulSet annotations |
| statefulSet.replicas | int | `1` | StatefulSet replicas |
| statefulSet.revisionHistoryLimit | int | `1` | StatefulSet revisionHistoryLimit |
| statefulSet.updateStrategy.type | string | `"RollingUpdate"` | StatefulSet updateStrategy type |
| tolerations | list | `[]` | Tolerations |
| volumeClaimTemplates.requestsStorage | string | `"1Gi"` | Volume Claim Templates Requests Storage |
| volumeClaimTemplates.storageClassName | string | `"local-storage"` | Volume Claim Templates Storage Class Name |

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "garnet.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "garnet.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/garnet/templates/service-headless.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "garnet.fullname" . }}-headless
labels:
{{- include "garnet.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
clusterIP: None
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.containers.port }}
protocol: TCP
name: garnet
selector:
{{- include "garnet.selectorLabels" . | nindent 4 }}
19 changes: 19 additions & 0 deletions charts/garnet/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "garnet.fullname" . }}
labels:
{{- include "garnet.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.containers.port }}
protocol: TCP
name: garnet
selector:
{{- include "garnet.selectorLabels" . | nindent 4 }}
16 changes: 16 additions & 0 deletions charts/garnet/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "garnet.serviceAccountName" . }}
labels:
{{- include "garnet.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if and .Values.serviceAccount.token (semverCompare ">=1.24-0" .Capabilities.KubeVersion.GitVersion) }}
secrets:
- name: {{ include "garnet.serviceAccountName" . }}-token
{{- end }}
{{- end }}
118 changes: 118 additions & 0 deletions charts/garnet/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "garnet.fullname" . }}
labels:
{{- include "garnet.labels" . | nindent 4 }}
{{- with .Values.statefulSet.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
serviceName: {{ include "garnet.fullname" . }}-headless
replicas: {{ .Values.statefulSet.replicas }}
revisionHistoryLimit: {{ .Values.statefulSet.revisionHistoryLimit }}
updateStrategy:
{{- with .Values.statefulSet.updateStrategy }}
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "garnet.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "garnet.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "garnet.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["./GarnetServer"]
{{- if .Values.containers.args }}
args:
{{- range .Values.containers.args }}
- {{ . | quote }}
{{- end }}
{{- end }}
ports:
- name: garnet
containerPort: {{ .Values.containers.port }}
protocol: TCP
{{- with .Values.containers.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.containers.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: data
mountPath: /data
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 10}}
{{- end }}
{{- with .Values.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
dnsPolicy: {{ .Values.dnsPolicy }}
{{- with .Values.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- 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 }}
{{- if or (eq .Values.persistence.enabled false) .Values.extraVolumes }}
volumes:
{{- if (eq .Values.persistence.enabled false) }}
- emptyDir: {}
name: data
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 6}}
{{- end }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
{{- if .Values.volumeClaimTemplates.storageClassName }}
{{- if (eq "-" .Values.volumeClaimTemplates.storageClassName) }}
storageClassName: ""
{{- else }}
storageClassName: {{ .Values.volumeClaimTemplates.storageClassName }}
{{- end }}
{{- end }}
resources:
requests:
storage: {{ .Values.volumeClaimTemplates.requestsStorage }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/garnet/templates/token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if and .Values.serviceAccount.create .Values.serviceAccount.token (semverCompare ">=1.24-0" .Capabilities.KubeVersion.GitVersion) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "garnet.serviceAccountName" . }}-token
labels:
{{- include "garnet.labels" . | nindent 4 }}
annotations:
kubernetes.io/service-account.name: {{ include "garnet.serviceAccountName" . }}
{{- with .Values.serviceAccount.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
type: kubernetes.io/service-account-token
{{- end }}
Loading

0 comments on commit 91544e1

Please sign in to comment.