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 }}
143 lines
4.9 KiB
YAML
143 lines
4.9 KiB
YAML
{{- if .Values.app.enabled -}}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-app
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-app
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
app.kubernetes.io/version: {{ .Chart.AppVersion }}
|
|
spec:
|
|
replicas: {{ .Values.app.replicaCount }}
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-app
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-app
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
{{- if $.Values.image.pullSecrets }}
|
|
imagePullSecrets:
|
|
{{- range $.Values.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- end }}
|
|
terminationGracePeriodSeconds: 30
|
|
containers:
|
|
- name: app
|
|
image: "{{ .Values.image.registry }}/{{ .Values.app.image.repository }}:{{ .Values.app.image.tag }}"
|
|
imagePullPolicy: {{ .Values.app.image.pullPolicy | default .Values.image.pullPolicy }}
|
|
ports:
|
|
- name: http
|
|
containerPort: {{ .Values.app.service.port }}
|
|
protocol: TCP
|
|
args:
|
|
- --bind
|
|
- 0.0.0.0:{{ .Values.app.service.port }}
|
|
envFrom:
|
|
- configMapRef:
|
|
name: {{ include "gitdata.fullname" . }}-config
|
|
{{- range .Values.app.env }}
|
|
- name: {{ .name }}
|
|
value: {{ .value | quote }}
|
|
{{- end }}
|
|
livenessProbe:
|
|
httpGet:
|
|
path: {{ .Values.app.livenessProbe.path }}
|
|
port: {{ .Values.app.livenessProbe.port }}
|
|
initialDelaySeconds: {{ .Values.app.livenessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.app.livenessProbe.periodSeconds }}
|
|
readinessProbe:
|
|
httpGet:
|
|
path: {{ .Values.app.readinessProbe.path }}
|
|
port: {{ .Values.app.readinessProbe.port }}
|
|
initialDelaySeconds: {{ .Values.app.readinessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.app.readinessProbe.periodSeconds }}
|
|
{{- if .Values.app.startupProbe }}
|
|
startupProbe:
|
|
httpGet:
|
|
path: {{ .Values.app.startupProbe.path }}
|
|
port: {{ .Values.app.startupProbe.port }}
|
|
initialDelaySeconds: {{ .Values.app.startupProbe.initialDelaySeconds | default 0 }}
|
|
periodSeconds: {{ .Values.app.startupProbe.periodSeconds }}
|
|
failureThreshold: {{ .Values.app.startupProbe.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.storage.enabled }}
|
|
volumeMounts:
|
|
- name: shared-data
|
|
mountPath: /data
|
|
{{- end }}
|
|
{{- if .Values.storage.enabled }}
|
|
volumes:
|
|
- name: shared-data
|
|
persistentVolumeClaim:
|
|
claimName: {{ include "gitdata.fullname" . }}-shared-data
|
|
{{- end }}
|
|
{{- with .Values.app.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.app.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.app.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-app
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-app
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
type: {{ .Values.app.service.type }}
|
|
ports:
|
|
- port: {{ .Values.app.service.port }}
|
|
targetPort: http
|
|
protocol: TCP
|
|
name: http
|
|
selector:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-app
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- if .Values.app.autoscaling.enabled }}
|
|
---
|
|
apiVersion: autoscaling/v2
|
|
kind: HorizontalPodAutoscaler
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-app
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-app
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
scaleTargetRef:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
name: {{ include "gitdata.fullname" . }}-app
|
|
minReplicas: {{ .Values.app.autoscaling.minReplicas }}
|
|
maxReplicas: {{ .Values.app.autoscaling.maxReplicas }}
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: {{ .Values.app.autoscaling.targetCPUUtilizationPercentage }}
|
|
- type: Resource
|
|
resource:
|
|
name: memory
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: {{ .Values.app.autoscaling.targetMemoryUtilizationPercentage }}
|
|
{{- end }}
|
|
{{- end }}
|