Add HorizontalPodAutoscaler (autoscaling/v2) using CPU and memory utilization
metrics to all deployment templates: app, static, gitserver, git-hook,
operator, adminrpc. Email-worker is excluded as requested.
- CPU target: 80% average utilization
- Memory target: 80% average utilization
- Each service has per-service min/max replicas in values.yaml
- Operator autoscaling defaults to disabled (enabled: false)
- Conditional via {{ if .Values.<service>.autoscaling.enabled }}
138 lines
5.0 KiB
YAML
138 lines
5.0 KiB
YAML
{{- if .Values.gitHook.enabled -}}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-git-hook
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-git-hook
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
app.kubernetes.io/version: {{ .Chart.AppVersion }}
|
|
spec:
|
|
replicas: {{ .Values.gitHook.replicaCount | default 2 }}
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-git-hook
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-git-hook
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
{{- if $.Values.image.pullSecrets }}
|
|
imagePullSecrets:
|
|
{{- range $.Values.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- end }}
|
|
containers:
|
|
- name: git-hook
|
|
image: "{{ .Values.image.registry }}/{{ .Values.gitHook.image.repository }}:{{ .Values.gitHook.image.tag }}"
|
|
imagePullPolicy: {{ .Values.gitHook.image.pullPolicy | default .Values.image.pullPolicy }}
|
|
ports:
|
|
- name: health
|
|
containerPort: 8083
|
|
protocol: TCP
|
|
envFrom:
|
|
- configMapRef:
|
|
name: {{ include "gitdata.fullname" . }}-config
|
|
env:
|
|
- name: APP_REPOS_ROOT
|
|
value: /data/repos
|
|
{{- range .Values.gitHook.env }}
|
|
- name: {{ .name }}
|
|
value: {{ .value | quote }}
|
|
{{- end }}
|
|
{{- if .Values.gitHook.livenessProbe }}
|
|
livenessProbe:
|
|
{{- if .Values.gitHook.livenessProbe.httpGet }}
|
|
httpGet:
|
|
path: {{ .Values.gitHook.livenessProbe.httpGet.path }}
|
|
port: {{ .Values.gitHook.livenessProbe.httpGet.port }}
|
|
{{- else }}
|
|
exec:
|
|
command:
|
|
{{- range .Values.gitHook.livenessProbe.exec.command }}
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
initialDelaySeconds: {{ .Values.gitHook.livenessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.gitHook.livenessProbe.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.gitHook.livenessProbe.timeoutSeconds }}
|
|
failureThreshold: {{ .Values.gitHook.livenessProbe.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.gitHook.readinessProbe }}
|
|
readinessProbe:
|
|
{{- if .Values.gitHook.readinessProbe.httpGet }}
|
|
httpGet:
|
|
path: {{ .Values.gitHook.readinessProbe.httpGet.path }}
|
|
port: {{ .Values.gitHook.readinessProbe.httpGet.port }}
|
|
{{- else }}
|
|
exec:
|
|
command:
|
|
{{- range .Values.gitHook.readinessProbe.exec.command }}
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
initialDelaySeconds: {{ .Values.gitHook.readinessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.gitHook.readinessProbe.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.gitHook.readinessProbe.timeoutSeconds }}
|
|
failureThreshold: {{ .Values.gitHook.readinessProbe.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.storage.enabled }}
|
|
volumeMounts:
|
|
- name: shared-data
|
|
mountPath: /data
|
|
{{- end }}
|
|
{{- with .Values.gitHook.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.gitHook.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.gitHook.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.storage.enabled }}
|
|
volumes:
|
|
- name: shared-data
|
|
persistentVolumeClaim:
|
|
claimName: {{ include "gitdata.fullname" . }}-shared-data
|
|
{{- end }}
|
|
{{- if .Values.gitHook.autoscaling.enabled }}
|
|
---
|
|
apiVersion: autoscaling/v2
|
|
kind: HorizontalPodAutoscaler
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-git-hook
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-git-hook
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
scaleTargetRef:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
name: {{ include "gitdata.fullname" . }}-git-hook
|
|
minReplicas: {{ .Values.gitHook.autoscaling.minReplicas }}
|
|
maxReplicas: {{ .Values.gitHook.autoscaling.maxReplicas }}
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: {{ .Values.gitHook.autoscaling.targetCPUUtilizationPercentage }}
|
|
- type: Resource
|
|
resource:
|
|
name: memory
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: {{ .Values.gitHook.autoscaling.targetMemoryUtilizationPercentage }}
|
|
{{- end }}
|
|
{{- end }}
|