diff --git a/deploy/templates/adminrpc-deployment.yaml b/deploy/templates/adminrpc-deployment.yaml index 37ca9ff..080d9c3 100644 --- a/deploy/templates/adminrpc-deployment.yaml +++ b/deploy/templates/adminrpc-deployment.yaml @@ -93,4 +93,35 @@ spec: 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 }} diff --git a/deploy/templates/app-deployment.yaml b/deploy/templates/app-deployment.yaml index eeabd8a..ec9ae61 100644 --- a/deploy/templates/app-deployment.yaml +++ b/deploy/templates/app-deployment.yaml @@ -108,4 +108,35 @@ spec: 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 }} diff --git a/deploy/templates/git-hook-deployment.yaml b/deploy/templates/git-hook-deployment.yaml index 7b96f7b..615aac8 100644 --- a/deploy/templates/git-hook-deployment.yaml +++ b/deploy/templates/git-hook-deployment.yaml @@ -103,4 +103,35 @@ spec: 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 }} diff --git a/deploy/templates/gitserver-deployment.yaml b/deploy/templates/gitserver-deployment.yaml index 6766748..2018514 100644 --- a/deploy/templates/gitserver-deployment.yaml +++ b/deploy/templates/gitserver-deployment.yaml @@ -171,4 +171,35 @@ spec: selector: app.kubernetes.io/name: {{ $fullName }}-gitserver app.kubernetes.io/instance: {{ $.Release.Name }} +{{- if $svc.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ $fullName }}-gitserver + namespace: {{ $ns }} + labels: + app.kubernetes.io/name: {{ $fullName }}-gitserver + app.kubernetes.io/instance: {{ $.Release.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ $fullName }}-gitserver + minReplicas: {{ $svc.autoscaling.minReplicas }} + maxReplicas: {{ $svc.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ $svc.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ $svc.autoscaling.targetMemoryUtilizationPercentage }} +{{- end }} {{- end }} diff --git a/deploy/templates/operator-deployment.yaml b/deploy/templates/operator-deployment.yaml index a57a72d..5690b78 100644 --- a/deploy/templates/operator-deployment.yaml +++ b/deploy/templates/operator-deployment.yaml @@ -114,4 +114,35 @@ roleRef: kind: Role name: {{ include "gitdata.fullname" . }}-operator apiGroup: rbac.authorization.k8s.io +{{- if .Values.operator.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "gitdata.fullname" . }}-operator + namespace: {{ include "gitdata.namespace" . }} + labels: + app.kubernetes.io/name: {{ include "gitdata.fullname" . }}-operator + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "gitdata.fullname" . }}-operator + minReplicas: {{ .Values.operator.autoscaling.minReplicas }} + maxReplicas: {{ .Values.operator.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.operator.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.operator.autoscaling.targetMemoryUtilizationPercentage }} +{{- end }} {{- end }} diff --git a/deploy/templates/static-deployment.yaml b/deploy/templates/static-deployment.yaml index 062ef9a..b0a8c0c 100644 --- a/deploy/templates/static-deployment.yaml +++ b/deploy/templates/static-deployment.yaml @@ -117,4 +117,35 @@ spec: selector: app.kubernetes.io/name: {{ $fullName }}-static app.kubernetes.io/instance: {{ .Release.Name }} +{{- if $svc.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ $fullName }}-static + namespace: {{ $ns }} + labels: + app.kubernetes.io/name: {{ $fullName }}-static + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ $fullName }}-static + minReplicas: {{ $svc.autoscaling.minReplicas }} + maxReplicas: {{ $svc.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ $svc.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ $svc.autoscaling.targetMemoryUtilizationPercentage }} +{{- end }} {{- end }} diff --git a/deploy/values.yaml b/deploy/values.yaml index ae63a4a..41c1c70 100644 --- a/deploy/values.yaml +++ b/deploy/values.yaml @@ -150,6 +150,13 @@ app: cpu: 100m memory: 256Mi + autoscaling: + enabled: true + minReplicas: 3 + maxReplicas: 20 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + livenessProbe: path: /health port: 8080 @@ -217,6 +224,13 @@ static: tolerations: [] affinity: {} + autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + # ============================================================================= # Gitserver – git daemon / SSH + HTTP server # ============================================================================= @@ -277,6 +291,13 @@ gitserver: tolerations: [] affinity: {} + autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + # ============================================================================= # Email worker – processes outgoing email queue # ============================================================================= @@ -361,6 +382,13 @@ gitHook: tolerations: [] affinity: {} + autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + # ============================================================================= # Migrate – database migration Job (runOnce) # ============================================================================= @@ -399,6 +427,13 @@ operator: tolerations: [] affinity: {} + autoscaling: + enabled: false + minReplicas: 2 + maxReplicas: 5 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + # ============================================================================= # Admin RPC – internal gRPC service for admin operations (k8s internal only) # ============================================================================= @@ -429,3 +464,10 @@ adminrpc: nodeSelector: {} tolerations: [] affinity: {} + + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 5 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80