diff --git a/helm/api-firewall/Chart.yaml b/helm/api-firewall/Chart.yaml index e018ff2..6c9951d 100644 --- a/helm/api-firewall/Chart.yaml +++ b/helm/api-firewall/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: api-firewall -version: 0.6.2 +version: 0.6.4 description: Wallarm OpenAPI-based API Firewall keywords: - wallarm diff --git a/helm/api-firewall/templates/_helpers.tpl b/helm/api-firewall/templates/_helpers.tpl index 7d4329f..d2fc37b 100644 --- a/helm/api-firewall/templates/_helpers.tpl +++ b/helm/api-firewall/templates/_helpers.tpl @@ -132,3 +132,18 @@ Return the appropriate apiVersion for Ingress kind of objects. {{- end -}} {{- end -}} {{- end -}} + +{{/* +Return the appropriate apiVersion for HorizontalPodAutoscaler kind of objects. +*/}} +{{- define "horizontalPodAutoscaler.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "autoscaling/v2beta2/HorizontalPodAutoscaler" -}} +{{- print "autoscaling/v2beta2" -}} +{{- else -}} +{{- if .Capabilities.APIVersions.Has "autoscaling/v2beta1/HorizontalPodAutoscaler" -}} +{{- print "autoscaling/v2beta1" -}} +{{- else -}} +{{- fail "Kubernetes Autoscaling API ti old. You need to upgrade your cluster for using this feature" -}} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/helm/api-firewall/templates/hpa.yaml b/helm/api-firewall/templates/hpa.yaml index 27c7385..211c2b9 100644 --- a/helm/api-firewall/templates/hpa.yaml +++ b/helm/api-firewall/templates/hpa.yaml @@ -16,6 +16,21 @@ spec: name: {{ template "api-firewall.fullname" . }} minReplicas: {{ .Values.apiFirewall.autoscaling.minReplicas }} maxReplicas: {{ .Values.apiFirewall.autoscaling.maxReplicas }} + {{ if .Capabilities.APIVersions.Has "autoscaling/v2beta2/HorizontalPodAutoscaler" -}} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.apiFirewall.autoscaling.targetCPUUtilizationPercentage }} + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.apiFirewall.autoscaling.targetMemoryUtilizationPercentage }} + {{ else -}} + {{ if .Capabilities.APIVersions.Has "autoscaling/v2beta1/HorizontalPodAutoscaler" -}} metrics: - type: Resource resource: @@ -25,4 +40,6 @@ spec: resource: name: memory targetAverageUtilization: {{ .Values.apiFirewall.autoscaling.targetMemoryUtilizationPercentage }} + {{ end -}} + {{ end -}} {{- end }} diff --git a/helm/api-firewall/values.yaml b/helm/api-firewall/values.yaml index 6c8bcbb..b212c97 100644 --- a/helm/api-firewall/values.yaml +++ b/helm/api-firewall/values.yaml @@ -56,7 +56,7 @@ apiFirewall: image: registry: "" name: "wallarm/api-firewall" - tag: "v0.6.2" + tag: "v0.6.4" pullPolicy: IfNotPresent ## Array of private container registry credentials