Skip to content
Open
Show file tree
Hide file tree
Changes from 13 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 @@ -8,7 +8,9 @@ metadata:
component: core
app.kubernetes.io/component: core
spec:
{{- if not .Values.core.autoscaling.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 .Values.core.autoscaling.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 }}
2 changes: 2 additions & 0 deletions templates/exporter/exporter-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ metadata:
component: exporter
app.kubernetes.io/component: exporter
spec:
{{- if not .Values.exporter.autoscaling.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 .Values.exporter.autoscaling.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 }}
2 changes: 2 additions & 0 deletions templates/jobservice/jobservice-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ metadata:
component: jobservice
app.kubernetes.io/component: jobservice
spec:
{{- if not .Values.jobservice.autoscaling.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 .Values.jobservice.autoscaling.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 }}
2 changes: 2 additions & 0 deletions templates/portal/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ metadata:
component: portal
app.kubernetes.io/component: portal
spec:
{{- if not .Values.portal.autoscaling.enabled }}
replicas: {{ .Values.portal.replicas }}
{{- end }}
revisionHistoryLimit: {{ .Values.portal.revisionHistoryLimit }}
selector:
matchLabels:
Expand Down
43 changes: 43 additions & 0 deletions templates/portal/portal-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.portal.autoscaling.enabled }}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
{{- with .Values.portal.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: portal
name: {{ template "harbor.portal" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "harbor.portal" . }}
minReplicas: {{ .Values.portal.autoscaling.minReplicas }}
maxReplicas: {{ .Values.portal.autoscaling.maxReplicas }}
metrics:
{{- with .Values.portal.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.portal.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.portal.autoscalingTemplate }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.portal.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions templates/registry/registry-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ metadata:
component: registry
app.kubernetes.io/component: registry
spec:
{{- if not .Values.registry.autoscaling.enabled }}
replicas: {{ .Values.registry.replicas }}
{{- end }}
revisionHistoryLimit: {{ .Values.registry.revisionHistoryLimit }}
strategy:
type: {{ .Values.updateStrategy.type }}
Expand Down
43 changes: 43 additions & 0 deletions templates/registry/registry-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.registry.autoscaling.enabled }}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
{{- with .Values.registry.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: registry
name: {{ template "harbor.registry" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "harbor.registry" . }}
minReplicas: {{ .Values.registry.autoscaling.minReplicas }}
maxReplicas: {{ .Values.registry.autoscaling.maxReplicas }}
metrics:
{{- with .Values.registry.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.registry.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.registry.autoscalingTemplate }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.registry.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
43 changes: 43 additions & 0 deletions templates/trivy/trivy-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.trivy.autoscaling.enabled }}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
{{- with .Values.trivy.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "harbor.labels" . | nindent 4 }}
app.kubernetes.io/component: trivy
name: {{ template "harbor.trivy" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
name: {{ template "harbor.trivy" . }}
minReplicas: {{ .Values.trivy.autoscaling.minReplicas }}
maxReplicas: {{ .Values.trivy.autoscaling.maxReplicas }}
metrics:
{{- with .Values.trivy.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.trivy.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.trivy.autoscalingTemplate }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.trivy.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions templates/trivy/trivy-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ metadata:
component: trivy
app.kubernetes.io/component: trivy
spec:
{{- if not .Values.trivy.autoscaling.enabled }}
replicas: {{ .Values.trivy.replicas }}
{{- end }}
serviceName: {{ template "harbor.trivy" . }}
selector:
matchLabels:
Expand Down
22 changes: 22 additions & 0 deletions test/unittest/core/core_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ tests:
path: spec.replicas
value: 2

- it: HPADisabledReplicas
set:
core:
replicas: 2
autoscaling:
enabled: false
template: templates/core/core-dpl.yaml
asserts:
- equal:
path: spec.replicas
value: 2

- it: HPAEnabledReplicas
set:
core:
autoscaling:
enabled: true
template: templates/core/core-dpl.yaml
asserts:
- notExists:
path: spec.replicas

- it: ServiceAccounts
set:
core:
Expand Down
Loading
Loading