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

Add support for HPA and Keda autoscaling #1756

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions templates/core/core-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ metadata:
component: core
app.kubernetes.io/component: core
spec:
{{- if eq .Values.core.autoscaling.enabled .Values.core.keda.enabled }}
replicas: {{ .Values.core.replicas }}
{{- end }}
revisionHistoryLimit: {{ .Values.core.revisionHistoryLimit }}
selector:
matchLabels:
Expand Down
43 changes: 43 additions & 0 deletions templates/core/core-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if and .Values.core.autoscaling.enabled (not .Values.core.keda.enabled) -}}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
{{- with .Values.core.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: core
name: {{ template "harbor.core" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "harbor.core" . }}
minReplicas: {{ .Values.core.autoscaling.minReplicas }}
maxReplicas: {{ .Values.core.autoscaling.maxReplicas }}
metrics:
{{- with .Values.core.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.core.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.core.autoscalingTemplate }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.core.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
42 changes: 42 additions & 0 deletions templates/core/core-keda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if and .Values.core.keda.enabled (not .Values.core.autoscaling.enabled) -}}
apiVersion: {{ .Values.core.keda.apiVersion }}
kind: ScaledObject
metadata:
{{- with .Values.core.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: core
name: {{ template "harbor.core" . }}
spec:
scaleTargetRef:
{{- if eq .Values.core.keda.apiVersion "keda.k8s.io/v1alpha1" }}
deploymentName: {{ template "harbor.core" . }}
{{- else if eq .Values.core.keda.apiVersion "keda.sh/v1alpha1" }}
name: {{ template "harbor.core" . }}
{{- end }}
pollingInterval: {{ .Values.core.keda.pollingInterval }}
cooldownPeriod: {{ .Values.core.keda.cooldownPeriod }}
minReplicaCount: {{ .Values.core.keda.minReplicas }}
maxReplicaCount: {{ .Values.core.keda.maxReplicas }}
{{- with .Values.core.keda.fallback }}
fallback:
failureThreshold: {{ .failureThreshold | default 3 }}
replicas: {{ .replicas | default $.Values.core.keda.maxReplicas }}
{{- end }}
triggers:
{{- with .Values.core.keda.triggers }}
{{ toYaml . | indent 2 }}
{{ end }}
advanced:
restoreToOriginalReplicaCount: {{ .Values.core.keda.restoreToOriginalReplicaCount }}
{{- if .Values.core.keda.behavior }}
horizontalPodAutoscalerConfig:
behavior:
{{ with .Values.core.keda.behavior -}}
{{ toYaml . | indent 8 }}
{{ end }}

{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions templates/exporter/exporter-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ metadata:
component: exporter
app.kubernetes.io/component: exporter
spec:
{{- if eq .Values.exporter.autoscaling.enabled .Values.exporter.keda.enabled }}
replicas: {{ .Values.exporter.replicas }}
{{- end }}
revisionHistoryLimit: {{ .Values.exporter.revisionHistoryLimit }}
selector:
matchLabels:
Expand Down
43 changes: 43 additions & 0 deletions templates/exporter/exporter-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if and .Values.exporter.autoscaling.enabled (not .Values.exporter.keda.enabled) -}}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
{{- with .Values.exporter.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: exporter
name: {{ template "harbor.exporter" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "harbor.exporter" . }}
minReplicas: {{ .Values.exporter.autoscaling.minReplicas }}
maxReplicas: {{ .Values.exporter.autoscaling.maxReplicas }}
metrics:
{{- with .Values.exporter.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.exporter.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.exporter.autoscalingTemplate }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.exporter.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
42 changes: 42 additions & 0 deletions templates/exporter/exporter-keda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if and .Values.exporter.keda.enabled (not .Values.exporter.autoscaling.enabled) -}}
apiVersion: {{ .Values.exporter.keda.apiVersion }}
kind: ScaledObject
metadata:
{{- with .Values.exporter.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: exporter
name: {{ template "harbor.exporter" . }}
spec:
scaleTargetRef:
{{- if eq .Values.exporter.keda.apiVersion "keda.k8s.io/v1alpha1" }}
deploymentName: {{ template "harbor.exporter" . }}
{{- else if eq .Values.exporter.keda.apiVersion "keda.sh/v1alpha1" }}
name: {{ template "harbor.exporter" . }}
{{- end }}
pollingInterval: {{ .Values.exporter.keda.pollingInterval }}
cooldownPeriod: {{ .Values.exporter.keda.cooldownPeriod }}
minReplicaCount: {{ .Values.exporter.keda.minReplicas }}
maxReplicaCount: {{ .Values.exporter.keda.maxReplicas }}
{{- with .Values.exporter.keda.fallback }}
fallback:
failureThreshold: {{ .failureThreshold | default 3 }}
replicas: {{ .replicas | default $.Values.exporter.keda.maxReplicas }}
{{- end }}
triggers:
{{- with .Values.exporter.keda.triggers }}
{{ toYaml . | indent 2 }}
{{ end }}
advanced:
restoreToOriginalReplicaCount: {{ .Values.exporter.keda.restoreToOriginalReplicaCount }}
{{- if .Values.exporter.keda.behavior }}
horizontalPodAutoscalerConfig:
behavior:
{{ with .Values.exporter.keda.behavior -}}
{{ toYaml . | indent 8 }}
{{ end }}

{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions templates/jobservice/jobservice-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ metadata:
component: jobservice
app.kubernetes.io/component: jobservice
spec:
{{- if eq .Values.jobservice.autoscaling.enabled .Values.jobservice.keda.enabled }}
replicas: {{ .Values.jobservice.replicas }}
{{- end }}
revisionHistoryLimit: {{ .Values.jobservice.revisionHistoryLimit }}
strategy:
type: {{ .Values.updateStrategy.type }}
Expand Down
43 changes: 43 additions & 0 deletions templates/jobservice/jobservice-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if and .Values.jobservice.autoscaling.enabled (not .Values.jobservice.keda.enabled) -}}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
{{- with .Values.jobservice.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: jobservice
name: {{ template "harbor.jobservice" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "harbor.jobservice" . }}
minReplicas: {{ .Values.jobservice.autoscaling.minReplicas }}
maxReplicas: {{ .Values.jobservice.autoscaling.maxReplicas }}
metrics:
{{- with .Values.jobservice.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.jobservice.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.jobservice.autoscalingTemplate }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.jobservice.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
42 changes: 42 additions & 0 deletions templates/jobservice/jobservice-keda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if and .Values.jobservice.keda.enabled (not .Values.jobservice.autoscaling.enabled) -}}
apiVersion: {{ .Values.jobservice.keda.apiVersion }}
kind: ScaledObject
metadata:
{{- with .Values.jobservice.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: jobservice
name: {{ template "harbor.jobservice" . }}
spec:
scaleTargetRef:
{{- if eq .Values.jobservice.keda.apiVersion "keda.k8s.io/v1alpha1" }}
deploymentName: {{ template "harbor.jobservice" . }}
{{- else if eq .Values.jobservice.keda.apiVersion "keda.sh/v1alpha1" }}
name: {{ template "harbor.jobservice" . }}
{{- end }}
pollingInterval: {{ .Values.jobservice.keda.pollingInterval }}
cooldownPeriod: {{ .Values.jobservice.keda.cooldownPeriod }}
minReplicaCount: {{ .Values.jobservice.keda.minReplicas }}
maxReplicaCount: {{ .Values.jobservice.keda.maxReplicas }}
{{- with .Values.jobservice.keda.fallback }}
fallback:
failureThreshold: {{ .failureThreshold | default 3 }}
replicas: {{ .replicas | default $.Values.jobservice.keda.maxReplicas }}
{{- end }}
triggers:
{{- with .Values.jobservice.keda.triggers }}
{{ toYaml . | indent 2 }}
{{ end }}
advanced:
restoreToOriginalReplicaCount: {{ .Values.jobservice.keda.restoreToOriginalReplicaCount }}
{{- if .Values.jobservice.keda.behavior }}
horizontalPodAutoscalerConfig:
behavior:
{{ with .Values.jobservice.keda.behavior -}}
{{ toYaml . | indent 8 }}
{{ end }}

{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions templates/nginx/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ metadata:
component: nginx
app.kubernetes.io/component: nginx
spec:
{{- if eq .Values.nginx.autoscaling.enabled .Values.nginx.keda.enabled }}
replicas: {{ .Values.nginx.replicas }}
{{- end }}
revisionHistoryLimit: {{ .Values.nginx.revisionHistoryLimit }}
selector:
matchLabels:
Expand Down
43 changes: 43 additions & 0 deletions templates/nginx/nginx-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if and .Values.nginx.autoscaling.enabled (not .Values.nginx.keda.enabled) -}}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
{{- with .Values.nginx.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: nginx
name: {{ template "harbor.nginx" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "harbor.nginx" . }}
minReplicas: {{ .Values.nginx.autoscaling.minReplicas }}
maxReplicas: {{ .Values.nginx.autoscaling.maxReplicas }}
metrics:
{{- with .Values.nginx.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.nginx.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.nginx.autoscalingTemplate }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.nginx.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
42 changes: 42 additions & 0 deletions templates/nginx/nginx-keda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if and .Values.nginx.keda.enabled (not .Values.nginx.autoscaling.enabled) -}}
apiVersion: {{ .Values.nginx.keda.apiVersion }}
kind: ScaledObject
metadata:
{{- with .Values.nginx.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: nginx
name: {{ template "harbor.nginx" . }}
spec:
scaleTargetRef:
{{- if eq .Values.nginx.keda.apiVersion "keda.k8s.io/v1alpha1" }}
deploymentName: {{ template "harbor.nginx" . }}
{{- else if eq .Values.nginx.keda.apiVersion "keda.sh/v1alpha1" }}
name: {{ template "harbor.nginx" . }}
{{- end }}
pollingInterval: {{ .Values.nginx.keda.pollingInterval }}
cooldownPeriod: {{ .Values.nginx.keda.cooldownPeriod }}
minReplicaCount: {{ .Values.nginx.keda.minReplicas }}
maxReplicaCount: {{ .Values.nginx.keda.maxReplicas }}
{{- with .Values.nginx.keda.fallback }}
fallback:
failureThreshold: {{ .failureThreshold | default 3 }}
replicas: {{ .replicas | default $.Values.nginx.keda.maxReplicas }}
{{- end }}
triggers:
{{- with .Values.nginx.keda.triggers }}
{{ toYaml . | indent 2 }}
{{ end }}
advanced:
restoreToOriginalReplicaCount: {{ .Values.nginx.keda.restoreToOriginalReplicaCount }}
{{- if .Values.nginx.keda.behavior }}
horizontalPodAutoscalerConfig:
behavior:
{{ with .Values.nginx.keda.behavior -}}
{{ toYaml . | indent 8 }}
{{ end }}

{{- end }}
{{- end }}
Loading
Loading