[deployment] add statefulset for vmselect (#140)

This commit is contained in:
Artem Navoiev 2019-08-04 23:34:05 +03:00 committed by Aliaksandr Valialkin
parent a868f8607f
commit dd4ea63ed2
6 changed files with 159 additions and 2 deletions

View file

@ -1,4 +1,4 @@
{{- if .Values.vmselect.enabled -}}
{{- if and .Values.vmselect.enabled (not .Values.vmselect.statefulSet.enabled) -}}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
@ -68,5 +68,10 @@ spec:
{{- end }}
volumes:
- name: cache-volume
{{- if .Values.vmselect.persistentVolume.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.vmselect.persistentVolume.existingClaim }}{{ .Values.vmselect.persistentVolume.existingClaim }}{{- else }}{{ template "victoria-metrics.vmselect.fullname" . }}{{- end }}
{{- else }}
emptyDir: {}
{{- end -}}
{{- end }}

View file

@ -0,0 +1,24 @@
{{- if and .Values.vmselect.enabled .Values.vmselect.statefulSet.enabled -}}
apiVersion: v1
kind: Service
metadata:
{{- if .Values.vmselect.statefulSet.service.annotations }}
annotations:
{{ toYaml .Values.vmselect.statefulSet.service.annotations | indent 4}}
{{- end }}
labels:
{{- include "victoria-metrics.vmselect.labels" . | nindent 4 }}
{{- if .Values.vmselect.statefulSet.service.labels }}
{{ toYaml .Values.vmselect.statefulSet.service.labels | indent 4}}
{{- end }}
name: {{ template "victoria-metrics.vmselect.fullname" . }}
spec:
clusterIP: None
ports:
- name: http
port: {{ .Values.vmselect.statefulSet.service.servicePort }}
protocol: TCP
targetPort: http
selector:
{{- include "victoria-metrics.vmselect.matchLabels" . | nindent 4 }}
{{- end -}}

View file

@ -1,4 +1,4 @@
{{- if .Values.vmselect.enabled -}}
{{- if and .Values.vmselect.enabled (not .Values.vmselect.statefulSet.enabled) -}}
apiVersion: v1
kind: Service
metadata:

View file

@ -0,0 +1,97 @@
{{- if and .Values.vmselect.enabled .Values.vmselect.statefulSet.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
{{- include "victoria-metrics.vmselect.labels" . | nindent 4 }}
name: {{ template "victoria-metrics.vmselect.fullname" . }}
spec:
serviceName: {{ template "victoria-metrics.vmselect.fullname" . }}
selector:
matchLabels:
{{- include "victoria-metrics.vmselect.matchLabels" . | nindent 6 }}
replicas: {{ .Values.vmselect.replicaCount }}
podManagementPolicy: {{ .Values.vmselect.podManagementPolicy }}
template:
metadata:
{{- if .Values.vmselect.podAnnotations }}
annotations:
{{ toYaml .Values.vmselect.podAnnotations | indent 8 }}
{{- end }}
labels:
{{- include "victoria-metrics.vmselect.labels" . | nindent 8 }}
spec:
{{- if .Values.vmselect.priorityClassName }}
priorityClassName: "{{ .Values.vmselect.priorityClassName }}"
{{- end }}
containers:
- name: {{ template "victoria-metrics.name" . }}-{{ .Values.vmselect.name }}
image: "{{ .Values.vmselect.image.repository }}:{{ .Values.vmselect.image.tag }}"
imagePullPolicy: "{{ .Values.vmselect.image.pullPolicy }}"
args:
- {{ printf "%s=%s" "--cacheDataPath" .Values.vmselect.cacheMountPath | quote}}
{{- include "victoria-metrics.vmselect.vmstorage-pod-fqdn" . | nindent 12 }}
{{- range $key, $value := .Values.vmselect.extraArgs }}
- --{{ $key }}={{ $value }}
{{- end }}
ports:
- name: http
containerPort: 8481
readinessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 5
periodSeconds: 15
volumeMounts:
- mountPath: {{ .Values.vmselect.cacheMountPath }}
name: cache-volume
resources:
{{ toYaml .Values.vmselect.resources | indent 12 }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 2 }}
{{- end }}
{{- if .Values.vmselect.nodeSelector }}
nodeSelector:
{{ toYaml .Values.vmselect.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.vmselect.securityContext }}
securityContext:
{{ toYaml .Values.vmselect.securityContext | indent 8 }}
{{- end }}
{{- if .Values.vmselect.tolerations }}
tolerations:
{{ toYaml .Values.vmselect.tolerations | indent 8 }}
{{- end }}
{{- if .Values.vmselect.affinity }}
affinity:
{{ toYaml .Values.vmselect.affinity | indent 8 }}
{{- end }}
{{- if .Values.vmselect.persistentVolume.enabled }}
volumeClaimTemplates:
- metadata:
name: cache-volume
{{- if .Values.vmselect.persistentVolume.annotations }}
annotations:
{{ toYaml .Values.vmselect.persistentVolume.annotations | indent 10 }}
{{- end }}
spec:
accessModes:
{{ toYaml .Values.vmselect.persistentVolume.accessModes | indent 10 }}
resources:
requests:
storage: "{{ .Values.vmselect.persistentVolume.size }}"
{{- if .Values.vmselect.persistentVolume.storageClass }}
{{- if (eq "-" .Values.vmselect.persistentVolume.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.vmselect.persistentVolume.storageClass }}"
{{- end }}
{{- end }}
{{- else }}
volumes:
- name: cache-volume
emptyDir: {}
{{- end }}
{{- end }}

View file

@ -158,6 +158,7 @@ spec:
{{- end }}
{{- end }}
{{- else }}
volumes:
- name: vmstorage-volume
emptyDir: {}
{{- end }}

View file

@ -53,6 +53,36 @@ vmselect:
loadBalancerSourceRanges: []
servicePort: 8481
type: ClusterIP
statefulSet:
## Creates statefulset instead of deployment, useful when you want to keep the cache
enabled: false
podManagementPolicy: OrderedReady
## Headless service for statefulset
service:
annotations: {}
labels: {}
servicePort: 8481
persistentVolume:
## If true, vmselect will create/use a Persistent Volume Claim
## If false, use emptyDir
##
enabled: false
## Must match those of existing PV or dynamic provisioner
## Ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
accessModes:
- ReadWriteOnce
annotations: {}
## Requires vmselect.persistentVolume.enabled: true
## If defined, PVC must be created manually before volume will be bound
existingClaim: ""
## Vmselect data Persistent Volume mount root path
##
size: 2Gi
subPath: ""
vminsert:
enabled: true