Skip to content
Snippets Groups Projects
Verified Commit 65cf7c34 authored by Vincent Sellier's avatar Vincent Sellier
Browse files

swh: Support the deployment of a memcached instance

It will be used by graphq >= 0.0.8.1 and later by the webapp

Related to swh/infra/sysadm-environment#4785
parent fb6cd712
No related branches found
No related tags found
No related merge requests found
{{ if .Values.memcached.enabled -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: memcached
namespace: {{ .Values.namespace }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
app: memcached
spec:
selector:
matchLabels:
app: memcached
# TODO: allow to deploy clustered memcached
replicas: 1
template:
metadata:
labels:
app: memcached
spec:
containers:
- name: memcached
image: "{{ .Values.memcached.image }}"
args:
- -m
- {{ .Values.memcached.memory }}
imagePullPolicy: IfNotPresent
resources:
requests:
memory: {{ .Values.memcached.requestedMemory | default "300Mi" }}
cpu: {{ .Values.memcached.requestedCpu | default "100m" }}
readinessProbe:
tcpSocket:
port: 11211
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 11211
initialDelaySeconds: 15
periodSeconds: 20
{{- if .Values.memcached.prometheus.enabled }}
- name: metrics-exporter
image: {{ .Values.memcached.prometheus.image }}
readinessProbe:
httpGet:
path: /metrics
port: 9150
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /metrics
port: 9150
initialDelaySeconds: 5
periodSeconds: 10
{{- end }}
{{- end -}}
{{ if .Values.memcached.enabled -}}
---
apiVersion: v1
kind: Service
metadata:
name: memcached
namespace: {{ .Values.namespace }}
labels:
app: memcached
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
type: ClusterIP
selector:
app: memcached
ports:
- name: memcached
port: 11211
targetPort: 11212
{{- if .Values.memcached.prometheus.enabled }}
- name: metrics
port: 9150
targetPort: 9150
{{- end }}
{{- end -}}
{{ if and .Values.memcached.enabled .Values.memcached.prometheus.enabled -}}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: memcached
namespace: {{ .Values.namespace }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
endpoints:
- path: /metrics
port: metrics
interval: 10s
selector:
matchLabels:
app: memcached
namespaceSelector:
any: true
{{- end -}}
suite: test memcached deployment
templates:
- memcached/deployment.yaml
tests:
- it: memcached deployment is deployed with default values when activated
set:
memcached.enabled: true
memcached.image: myimage:myversion
asserts:
- containsDocument:
kind: Deployment
apiVersion: apps/v1
- equal:
path: metadata.namespace
value: swh
- equal:
path: spec.replicas
value: 1
- equal:
path: spec.template.spec.containers[0].image
value: myimage:myversion
- equal:
path: spec.template.spec.containers[0].args[1]
value: 256m
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 100m
- equal:
path: spec.template.spec.containers[0].resources.requests.memory
value: 300Mi
- lengthEqual:
path: spec.template.spec.containers
count: 2
- it: memcached memory check
set:
namespace: mynamespace
memcached.enabled: true
memcached.memory: 128m
memcached.requestedCpu: 1
memcached.requestedMemory: 2
asserts:
- equal:
path: .metadata.namespace
value: mynamespace
- equal:
path: spec.template.spec.containers[0].args[1]
value: 128m
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 1
- equal:
path: spec.template.spec.containers[0].resources.requests.memory
value: 2
- it: memcached prometheus disabled
set:
memcached.enabled: true
memcached.prometheus.enabled: true
asserts:
- lengthEqual:
path: spec.template.spec.containers
count: 2
- it: memcached prometheus properties
set:
memcached.enabled: true
memcached.prometheus.enabled: true
memcached.prometheus.image: myimage:myversion
asserts:
- lengthEqual:
path: spec.template.spec.containers
count: 2
- equal:
path: spec.template.spec.containers[1].image
value: myimage:myversion
suite: test memcached deployment
templates:
- memcached/deployment.yaml
- memcached/service.yaml
- memcached/servicemonitor.yaml
tests:
- it: memcached service is not deployed by default
values:
- ../values.yaml
asserts:
- hasDocuments:
count: 0
suite: test memcached service
templates:
- memcached/service.yaml
tests:
- it: memcached service is deployed with default values when activated
set:
memcached.enabled: true
asserts:
- containsDocument:
kind: Service
apiVersion: v1
- equal:
path: metadata.namespace
value: swh
- lengthEqual:
path: spec.ports
count: 2
- it: metrics port disabled when prometheus is disabled
set:
namespace: mynamespace
memcached.enabled: true
memcached.prometheus.enabled: false
asserts:
- equal:
path: metadata.namespace
value: mynamespace
- lengthEqual:
path: spec.ports
count: 1
suite: test memcached ServiceMonitor
templates:
- memcached/servicemonitor.yaml
tests:
- it: memcached servicemonitor is deployed with default values when activated
set:
memcached.enabled: true
asserts:
- containsDocument:
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
- equal:
path: metadata.namespace
value: swh
- it: memcached servicemonitor namespace
set:
memcached.enabled: true
namespace: mynamespace
asserts:
- equal:
path: metadata.namespace
value: mynamespace
- it: memcached servicemonitor not deployed when prometheus is disabled
set:
memcached.enabled: true
memcached.prometheus.enabled: false
asserts:
- hasDocuments:
count: 0
......@@ -126,3 +126,15 @@ statsd_exporter:
enabled: false
image: prom/statsd-exporter
imageVersion: "v0.22.7"
memcached:
# Deploy a memcached instance used by the webapp and graphql for sessions caching
enabled: false
image: memcached:1.6.18
memory: 256m
requestedCpu: 100m
requestedMemory: 300Mi
prometheus:
# Activate the deployment of the memcached exporter and ServiceMonitor
enabled: true
image: quay.io/prometheus/memcached-exporter:v0.11.1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment