Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(coroot): add statefulset for correct support HA mode. #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions charts/coroot/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{- if .Values.corootCE.enabled -}}
{{- if and .Values.corootCE.enabled (not .Values.corootCE.useStatefulSet) -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "coroot.fullname" . }}
labels:
{{- include "coroot.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.corootCE.replicas }}
replicas: 1
strategy:
{{- toYaml .Values.corootCE.strategy | nindent 4 }}
selector:
Expand Down
4 changes: 2 additions & 2 deletions charts/coroot/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.corootCE.enabled -}}
{{- if and .Values.corootCE.enabled (not .Values.corootCE.useStatefulSet) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
Expand All @@ -18,4 +18,4 @@ spec:
storageClassName: "{{ .Values.corootCE.persistentVolume.storageClassName }}"
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
112 changes: 112 additions & 0 deletions charts/coroot/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{{- if and .Values.corootCE.enabled .Values.corootCE.useStatefulSet -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "coroot.fullname" . }}
labels:
{{- include "coroot.labels" . | nindent 4 }}
spec:
serviceName: "{{ include "coroot.fullname" . }}"
replicas: {{ .Values.corootCE.replicas }}
selector:
matchLabels:
{{- include "coroot.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.corootCE.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "coroot.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.corootCE.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "coroot.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.corootCE.podSecurityContext | nindent 8 }}
{{- if .Values.corootCE.initContainers }}
initContainers:
{{- toYaml .Values.corootCE.initContainers | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.corootCE.securityContext | nindent 12 }}
image: "{{ .Values.corootCE.image.repository }}:{{ .Values.corootCE.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.corootCE.image.pullPolicy }}
args:
- --listen=:8080
- --data-dir=/data
{{- if and .Values.corootCE.bootstrap.refreshInterval .Values.existingPrometheus.enabled }}
- --bootstrap-prometheus-url={{ printf "http://%s.%s:%s" (.Values.existingPrometheus.service.serviceName) (.Values.existingPrometheus.service.serviceNamespace) (.Values.existingPrometheus.service.servicePort | toString ) }}
- --bootstrap-refresh-interval={{ .Values.corootCE.bootstrap.refreshInterval }}
{{- else if and .Values.corootCE.bootstrap.refreshInterval .Values.prometheus.enabled .Values.prometheus.server.enabled }}
- --bootstrap-prometheus-url={{ printf "http://%s:%s" (include "coroot.prometheus.server.fullname" .) (.Values.prometheus.server.service.servicePort | toString ) }}
- --bootstrap-refresh-interval={{ .Values.corootCE.bootstrap.refreshInterval }}
{{- end }}
env:
{{- if and .Values.clickhouse.enabled }}
- name: BOOTSTRAP_CLICKHOUSE_ADDRESS
value: {{ printf "%s:%s" (include "coroot.clickhouse.fullname" .) (.Values.clickhouse.service.ports.tcp | toString ) }}
{{- if .Values.clickhouse.auth.existingSecret }}
- name: BOOTSTRAP_CLICKHOUSE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.clickhouse.auth.existingSecret }}
key: {{ .Values.clickhouse.auth.existingSecretKey }}
{{- else }}
- name: BOOTSTRAP_CLICKHOUSE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "coroot.clickhouse.fullname" . }}
key: "admin-password"
{{- end }}
- name: BOOTSTRAP_CLICKHOUSE_USER
value: {{ .Values.corootCE.bootstrap.clickhouse.username }}
- name: BOOTSTRAP_CLICKHOUSE_DATABASE
value: {{ .Values.corootCE.bootstrap.clickhouse.database }}
{{- end }}
{{- with .Values.corootCE.env }}
{{- . | toYaml | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
readinessProbe:
httpGet:
path: /health
port: http
resources:
{{- toYaml .Values.corootCE.resources | nindent 12 }}
volumeMounts:
- mountPath: /data
name: data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: {{ .Values.corootCE.persistentVolume.size | quote }}
{{- with .Values.corootCE.persistentVolume.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- with .Values.corootCE.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.corootCE.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.corootCE.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
4 changes: 4 additions & 0 deletions charts/coroot/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
corootCE:
enabled: true
# useStatefulSet - Only for HA mode when use PostgreSQL
# https://docs.coroot.com/configuration/high-availability
useStatefulSet: false
bootstrap:
refreshInterval: 15s
clickhouse:
database: default
username: default
# replicas - can set more 1 when set `useStatefulSet: true`
replicas: 1
strategy:
type: Recreate
Expand Down