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 }}
128 lines
4.1 KiB
YAML
128 lines
4.1 KiB
YAML
{{- if .Values.adminrpc.enabled -}}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
app.kubernetes.io/version: {{ .Chart.AppVersion }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
{{- if $.Values.image.pullSecrets }}
|
|
imagePullSecrets:
|
|
{{- range $.Values.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- end }}
|
|
terminationGracePeriodSeconds: 10
|
|
containers:
|
|
- name: adminrpc
|
|
image: "{{ .Values.image.registry }}/{{ .Values.adminrpc.image.repository }}:{{ .Values.adminrpc.image.tag }}"
|
|
imagePullPolicy: {{ .Values.adminrpc.image.pullPolicy | default .Values.image.pullPolicy }}
|
|
ports:
|
|
- name: grpc
|
|
containerPort: {{ .Values.adminrpc.service.port }}
|
|
protocol: TCP
|
|
- name: http
|
|
containerPort: {{ .Values.adminrpc.service.http_port }}
|
|
protocol: TCP
|
|
args:
|
|
- --bind
|
|
- "0.0.0.0:{{ .Values.adminrpc.service.port }}"
|
|
envFrom:
|
|
- configMapRef:
|
|
name: {{ include "gitdata.fullname" . }}-config
|
|
livenessProbe:
|
|
tcpSocket:
|
|
port: {{ .Values.adminrpc.service.http_port }}
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
readinessProbe:
|
|
tcpSocket:
|
|
port: {{ .Values.adminrpc.service.http_port }}
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 5
|
|
{{- if .Values.adminrpc.resources }}
|
|
resources:
|
|
{{- toYaml .Values.adminrpc.resources | nindent 12 }}
|
|
{{- end }}
|
|
{{- with .Values.adminrpc.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.adminrpc.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.adminrpc.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- port: {{ .Values.adminrpc.service.port }}
|
|
targetPort: grpc
|
|
protocol: TCP
|
|
name: grpc
|
|
- port: {{ .Values.adminrpc.service.http_port }}
|
|
targetPort: http
|
|
protocol: TCP
|
|
name: http
|
|
selector:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- if .Values.adminrpc.autoscaling.enabled }}
|
|
---
|
|
apiVersion: autoscaling/v2
|
|
kind: HorizontalPodAutoscaler
|
|
metadata:
|
|
name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
namespace: {{ include "gitdata.namespace" . }}
|
|
labels:
|
|
app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
spec:
|
|
scaleTargetRef:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
name: {{ include "gitdata.fullname" . }}-adminrpc
|
|
minReplicas: {{ .Values.adminrpc.autoscaling.minReplicas }}
|
|
maxReplicas: {{ .Values.adminrpc.autoscaling.maxReplicas }}
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: {{ .Values.adminrpc.autoscaling.targetCPUUtilizationPercentage }}
|
|
- type: Resource
|
|
resource:
|
|
name: memory
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: {{ .Values.adminrpc.autoscaling.targetMemoryUtilizationPercentage }}
|
|
{{- end }}
|
|
{{- end }}
|