Skip to content

Commit

Permalink
Merge pull request #55 from empathyco/feat/motive-cache
Browse files Browse the repository at this point in the history
feat: add motive-cache chart
  • Loading branch information
jmsantorum authored May 16, 2024
2 parents c814ddf + 0eb7b81 commit 6d08c21
Show file tree
Hide file tree
Showing 9 changed files with 620 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ We are open to contributors, you can contribute to Empathy Helm Charts through c

Following the list complete list of supported Helm Charts:

* motive-cache
* motive-cronjob
* motive-service
* multi-service
23 changes: 23 additions & 0 deletions charts/motive-cache/.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/
9 changes: 9 additions & 0 deletions charts/motive-cache/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: motive-cache
description: A Helm chart for Kubernetes

type: application

version: 0.1.0

appVersion: "1.0.0"
76 changes: 76 additions & 0 deletions charts/motive-cache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# motive-cache

![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.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square)

A Helm chart for Kubernetes

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Similar to the nodeSelector, but slightly different: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity |
| backend.namespaces | list | `[]` | Namespace(s) to look for backend pods. By default - namespace the VarnishCluster is deployed to. |
| backend.onlyReady | bool | `false` | Include (false, by default) or exclude (true) backend pods from the VCL (.Backends template var). Alters .Backends template variable based on Kubernetes health checks (by default not ready pods are also included in VCL) instead of Varnish health probes. |
| backend.port | string | `"backend-port"` | The port of the backend pods being cached by Varnish. Can be port name or port number. |
| backend.selector | object | `{}` | The selector used to identify the backend Pods. |
| backend.zoneBalancing | object | `{"thresholds":[],"type":"disabled"}` | Controls Varnish backend topology aware routing which can assign weights to backends according to their geographical location. |
| backend.zoneBalancing.thresholds | list | `[]` | Array of thresholds objects to determine condition and respective weights to be assigned to backends: threshold, local - local backend weight, remote - remote backend weight |
| backend.zoneBalancing.type | string | `"disabled"` | Varnish backend zone-balancing type. Accepted values: disabled, auto, thresholds |
| fullnameOverride | string | `""` | |
| ingress.internal.annotations | object | `{}` | |
| ingress.internal.className | string | `"nginx-internal"` | |
| ingress.internal.enabled | bool | `false` | |
| ingress.internal.hosts[0].host | string | `"chart-example.local"` | |
| ingress.internal.hosts[0].paths[0].path | string | `"/"` | |
| ingress.internal.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.internal.hosts[0].paths[0].port | int | `8080` | |
| ingress.internal.hosts[0].paths[0].portName | string | `"http"` | |
| ingress.internal.tls | list | `[]` | |
| logFormat | string | `"json"` | Format of the logs. Can be json and console. |
| logLevel | string | `"info"` | The minimum enabled logging level. Allowed values: debug, info, warn, error, dpanic, panic, fatal. |
| monitoring | object | `{"grafanaDashboard":{"datasourceName":"","enabled":false,"labels":{},"namespace":"","title":""},"prometheusServiceMonitor":{"enabled":true,"labels":{},"namespace":""}}` | The operator monitoring configuration object |
| monitoring.grafanaDashboard | object | `{"datasourceName":"","enabled":false,"labels":{},"namespace":"","title":""}` | A dashboard that can be installed along with the operator and used in grafana. Installed as a ConfigMap. |
| monitoring.grafanaDashboard.datasourceName | string | `""` | Name of the Grafana datasource the dashboard should use. (required) |
| monitoring.grafanaDashboard.enabled | bool | `false` | Enable or disable the ConfigMap installation. |
| monitoring.grafanaDashboard.labels | object | `{}` | ConfigMap labels. Can be used to for discovery by grafana. |
| monitoring.grafanaDashboard.namespace | string | `""` | Namespace that the ConfigMap with the dashboard should be installed to. Default to the namespace VarnishCluster is installed to |
| monitoring.grafanaDashboard.title | string | `""` | Title of the Grafana dashboard. Default: Varnish (<cluster namespace>/<name>) |
| monitoring.prometheusServiceMonitor | object | `{"enabled":true,"labels":{},"namespace":""}` | The Prometheus ServiceMonitor that is preconfigured to monitors the operator pods. |
| monitoring.prometheusServiceMonitor.enabled | bool | `true` | Enable or disable ServiceMontitor installation. |
| monitoring.prometheusServiceMonitor.labels | object | `{}` | ServiceMonitor labels that will be used by Prometheus instance to discover this ServiceMonitor. |
| monitoring.prometheusServiceMonitor.namespace | string | `""` | The namespace it should be installed to. Default to the namespace VarnishCluster is installed to |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | Node selector to control where the Varnish pods should be scheduled |
| podAntiAffinity | string | `"hard"` | |
| podAntiAffinityTopologyKey | string | `"kubernetes.io/hostname"` | |
| podDisruptionBudget | object | `{"maxUnavailable":null,"minAvailable":1}` | Pod Disruption Budget configuration. Can be used to tell Kubernetes how many pods are required to be up (or allowed to be down) to not cause service disruption |
| podDisruptionBudget.maxUnavailable | string | `nil` | An eviction is allowed if at most maxUnavailable pods are unavailable after the eviction, i.e. even in absence of the evicted pod. This is a mutually exclusive setting with minAvailable |
| podDisruptionBudget.minAvailable | int | `1` | An eviction is allowed if at least minAvailable pods will still be available after the eviction, i.e. even in the absence of the evicted pod |
| replicas | int | `1` | Number of Varnish nodes |
| service | object | `{"annotations":{},"controllerMetricsNodePort":30002,"metricsNodePort":30001,"metricsPort":9131,"nodePort":30000,"port":80,"type":"ClusterIP"}` | Varnish service configuration. |
| service.annotations | object | `{}` | Additional annotations for the service. |
| service.controllerMetricsNodePort | int | `30002` | The port number used to set NodePort for Varnish Controller Metrics exporter. Service type `NodePort should be selected. |
| service.metricsNodePort | int | `30001` | The port number used to set NodePort for Varnish Metrics Exporter. Service type `NodePort should be selected. |
| service.metricsPort | int | `9131` | The port that will expose the Prometheus metrics exporter. |
| service.nodePort | int | `30000` | The port number used to set NodePort for Varnish. Service type `NodePort should be selected. |
| service.port | int | `80` | The port number used to expose Varnish pods. |
| service.type | string | `"ClusterIP"` | Type of the Service. Allowed values: ClusterIP; LoadBalancer; NodePort |
| tolerations | list | `[]` | Configuration that defines which node taints can the pods tolerate. For example to allow Varnish pods to run on nodes that are marked (tainted) as machines dedicated for in-memory cache |
| updateStrategy | object | `{"delayedRollingUpdate":{"delaySeconds":60},"rollingUpdate":{"partition":0},"type":"OnDelete"}` | Allows to control the way Varnish pods will be updated. |
| updateStrategy.delayedRollingUpdate | object | `{"delaySeconds":60}` | Configuration for DelayedRollingUpdate strategy |
| updateStrategy.delayedRollingUpdate.delaySeconds | int | `60` | Indicates the wait time between pod reloads during rolling update |
| updateStrategy.rollingUpdate | object | `{"partition":0}` | Used to communicate parameters when type is RollingUpdate |
| updateStrategy.rollingUpdate.partition | int | `0` | Partition indicates the ordinal at which the StatefulSet should be partitioned. |
| updateStrategy.type | string | `"OnDelete"` | Defines the type of the update strategy. (RollingUpdate, OnDelete, DelayedRollingUpdate) |
| varnish | object | `{"args":[],"controller":{"imagePullPolicy":"IfNotPresent","resources":{"limits":{"memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}}},"imagePullPolicy":"IfNotPresent","metricsExporter":{"imagePullPolicy":"IfNotPresent","resources":{"limits":{"memory":"32Mi"},"requests":{"cpu":"10m","memory":"16Mi"}}},"resources":{"limits":{"memory":"192Mi"},"requests":{"cpu":"20m","memory":"128Mi"}}}` | An object that defines the configuration of a particular Varnish instance being deployed |
| varnish.args | list | `[]` | Additional Varnish daemon arguments |
| varnish.controller | object | `{"imagePullPolicy":"IfNotPresent","resources":{"limits":{"memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}}}` | An object that defines the configuration of a particular Varnish controller being deployed |
| varnish.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy for the Varnish container. |
| varnish.metricsExporter | object | `{"imagePullPolicy":"IfNotPresent","resources":{"limits":{"memory":"32Mi"},"requests":{"cpu":"10m","memory":"16Mi"}}}` | An object that defines the configuration of a particular Varnish Prometheus metrics exporter being deployed |
| varnish.resources | object | `{"limits":{"memory":"192Mi"},"requests":{"cpu":"20m","memory":"128Mi"}}` | Resource requests and limits for Varnish container. |
| vcl | object | `{"configMapName":"tmp","entrypointFileName":"tmp"}` | An object that defines the VCL ConfigMap configuration |
| vcl.configMapName | string | `"tmp"` | Name of the ConfigMap containing the VCL configuration files |
| vcl.entrypointFileName | string | `"tmp"` | The name of the main VCL file |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3)
105 changes: 105 additions & 0 deletions charts/motive-cache/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "motive-cache.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 "motive-cache.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 "motive-cache.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "motive-cache.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "motive-cache.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Common affinity definition
Pod affinity
- Soft prefers different nodes
- Hard requires different nodes and prefers different availibility zones
Node affinity
- Soft prefers given user expressions
- Hard requires given user expressions
*/}}
{{- define "motive-cache.affinity" -}}
{{- if or $.Values.podAntiAffinity $.Values.affinity -}}
affinity:
{{- with $.Values.affinity }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- if eq $.Values.podAntiAffinity "hard" }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
{{- include "motive-cache.selectorLabels" $ | nindent 12 }}
topologyKey: {{ $.Values.podAntiAffinityTopologyKey }}
{{- if (semverCompare ">=1.29.0-0" $.Capabilities.KubeVersion.Version) -}}
matchLabelKeys:
- pod-template-hash
{{- end -}}
{{- else if eq $.Values.podAntiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
{{- include "motive-cache.selectorLabels" $ | nindent 14 }}
topologyKey: {{ $.Values.podAntiAffinityTopologyKey }}
{{- if (semverCompare ">=1.29.0-0" $.Capabilities.KubeVersion.Version) -}}
matchLabelKeys:
- pod-template-hash
{{- end -}}
{{- end -}}
{{- end }}
{{- end }}
61 changes: 61 additions & 0 deletions charts/motive-cache/templates/ingress-internal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- with .Values.ingress.internal -}}
{{- if .enabled -}}
{{- if and .className (not (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .annotations "kubernetes.io/ingress.class" .className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ include "motive-cache.fullname" $ }}-internal
labels:
{{- include "motive-cache.labels" $ | nindent 4 }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .className (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .className }}
{{- end }}
{{- if .tls }}
tls:
{{- range .tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ include "motive-cache.fullname" $ }}
port:
name: varnish
{{- else }}
serviceName: {{ include "motive-cache.fullname" $ }}
servicePort: {{ .port | default 80 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
29 changes: 29 additions & 0 deletions charts/motive-cache/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- range untilStep 0 (int .Values.replicas) 1 }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "motive-cache.fullname" $ }}-{{ . }}
labels:
{{- include "motive-cache.labels" $ | nindent 4 }}
annotations:
service.kubernetes.io/topology-mode: Auto
spec:
type: ClusterIP
ports:
- name: varnish
port: 80
targetPort: varnish
protocol: TCP
- name: metrics
port: 9131
protocol: TCP
targetPort: metrics
- name: ctrl-metrics
port: 8235
protocol: TCP
targetPort: ctrl-metrics
selector:
varnish-component: varnish
statefulset.kubernetes.io/pod-name: {{ include "motive-cache.fullname" $ }}-{{ . }}
{{- end }}
Loading

0 comments on commit 6d08c21

Please sign in to comment.