From ea4599f43ab467aec923989de597a1b826f7c90c Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Wed, 10 Jul 2024 13:50:02 +0100 Subject: [PATCH] feat: remove hpa, autoscaling --- .../templates/broker_deployment.yaml | 2 +- charts/snyk-broker/templates/broker_hpa.yaml | 33 -------- .../snyk-broker/templates/cra_deployment.yaml | 2 - .../tests/broker_autoscaling_test.yaml | 78 ------------------- charts/snyk-broker/values.schema.json | 57 -------------- charts/snyk-broker/values.yaml | 28 +++---- 6 files changed, 10 insertions(+), 190 deletions(-) delete mode 100644 charts/snyk-broker/templates/broker_hpa.yaml delete mode 100644 charts/snyk-broker/tests/broker_autoscaling_test.yaml diff --git a/charts/snyk-broker/templates/broker_deployment.yaml b/charts/snyk-broker/templates/broker_deployment.yaml index d1eeaeb..c178332 100644 --- a/charts/snyk-broker/templates/broker_deployment.yaml +++ b/charts/snyk-broker/templates/broker_deployment.yaml @@ -6,7 +6,7 @@ metadata: labels: {{- include "snyk-broker.labels" . }} spec: - {{- if and (not .Values.autoscaling.enabled) (.Values.highAvailabilityMode.enabled) }} + {{- if .Values.highAvailabilityMode.enabled }} replicas: {{ .Values.replicaCount }} {{ else }} replicas: 1 diff --git a/charts/snyk-broker/templates/broker_hpa.yaml b/charts/snyk-broker/templates/broker_hpa.yaml deleted file mode 100644 index f4dd029..0000000 --- a/charts/snyk-broker/templates/broker_hpa.yaml +++ /dev/null @@ -1,33 +0,0 @@ -{{- $autoscaling := .Values.autoscaling | default dict -}} -{{- $cpuType := ternary "Utilization" "Value" ( eq $autoscaling.cpu.type "Utilization" ) -}} -{{- $memoryType := ternary "Utilization" "Value" ( eq $autoscaling.memory.type "Utilization" ) -}} -{{- if ( and $autoscaling.enabled .Values.highAvailabilityMode.enabled ) -}} -kind: HorizontalPodAutoscaler -apiVersion: autoscaling/v2 -metadata: - name: "{{ .Values.scmType}}-broker{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: "{{ .Values.scmType}}-broker{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}" - minReplicas: {{ $autoscaling.minReplicas | default 2 }} - maxReplicas: {{ $autoscaling.maxReplicas | default 4 }} - metrics: - {{- if $autoscaling.cpu.enabled }} - - type: Resource - resource: - name: cpu - target: - type: {{ $autoscaling.cpu.type }} - {{ printf "average%s" $cpuType }}: {{ $autoscaling.cpu.value }} - {{- end -}} - {{- if $autoscaling.memory.enabled }} - - type: Resource - resource: - name: memory - target: - type: {{ $autoscaling.memory.type }} - {{ printf "average%s" $memoryType }}: {{ $autoscaling.memory.value }} - {{- end -}} -{{- end -}} diff --git a/charts/snyk-broker/templates/cra_deployment.yaml b/charts/snyk-broker/templates/cra_deployment.yaml index efa41be..fb83432 100644 --- a/charts/snyk-broker/templates/cra_deployment.yaml +++ b/charts/snyk-broker/templates/cra_deployment.yaml @@ -8,9 +8,7 @@ metadata: app.kubernetes.io/name: {{ .Release.Name }}-cr{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }} app.kubernetes.io/instance: {{ .Release.Name }} spec: - {{- if not .Values.autoscaling.enabled }} replicas: 1 - {{- end }} selector: matchLabels: app.kubernetes.io/name: {{ .Release.Name }}-cr{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }} diff --git a/charts/snyk-broker/tests/broker_autoscaling_test.yaml b/charts/snyk-broker/tests/broker_autoscaling_test.yaml deleted file mode 100644 index 315742d..0000000 --- a/charts/snyk-broker/tests/broker_autoscaling_test.yaml +++ /dev/null @@ -1,78 +0,0 @@ -suite: test broker hpa -chart: - version: 0.0.0 -templates: - - broker_hpa.yaml -values: - - ./fixtures/default_values.yaml - -tests: - - it: does not render if autoscaling enabled but ha mode is off - set: - autoscaling.enabled: true - asserts: - - containsDocument: - kind: HorizontalPodAutoscaler - apiVersion: autoscaling/v2 - name: github-com-broker-RELEASE-NAME - not: true - - it: does not render if autoscaling off and ha mode is on - set: - autoscaling.enabled: false - highAvailabilityMode.enabled: true - asserts: - - containsDocument: - kind: HorizontalPodAutoscaler - apiVersion: autoscaling/v2 - name: github-com-broker-RELEASE-NAME - not: true - - it: renders if autoscaling enabled and ha is on - set: - autoscaling.enabled: true - highAvailabilityMode.enabled: true - asserts: - - containsDocument: - kind: HorizontalPodAutoscaler - apiVersion: autoscaling/v2 - name: github-com-broker-RELEASE-NAME - - it: targets the correct deployment - set: - autoscaling.enabled: true - highAvailabilityMode.enabled: true - asserts: - - equal: - path: spec.scaleTargetRef.name - value: github-com-broker-RELEASE-NAME - - it: overrides cpu to value correctly - set: - autoscaling.enabled: true - highAvailabilityMode.enabled: true - autoscaling.cpu.type: "AverageValue" - autoscaling.cpu.value: 100m - asserts: - - contains: - path: spec.metrics - content: - type: Resource - resource: - name: cpu - target: - averageValue: 100m - type: AverageValue - - it: overrides memory to value correctly - set: - autoscaling.enabled: true - highAvailabilityMode.enabled: true - autoscaling.memory.enabled: true - autoscaling.memory.type: "AverageValue" - autoscaling.memory.value: 256Mi - asserts: - - contains: - path: spec.metrics - content: - type: Resource - resource: - name: memory - target: - averageValue: 256Mi - type: AverageValue diff --git a/charts/snyk-broker/values.schema.json b/charts/snyk-broker/values.schema.json index 2758e3b..67ea7fd 100644 --- a/charts/snyk-broker/values.schema.json +++ b/charts/snyk-broker/values.schema.json @@ -458,63 +458,6 @@ }, "extraPodSpecsCr":{ "nullable": true - }, - "autoscaling": { - "type": "object", - "additionalProperties": false, - "properties":{ - "enabled": { - "type": "boolean" - }, - "minReplicas": { - "type": "integer", - "minimum": 2, - "maximum": 4 - }, - "maxReplicas": { - "type": "integer", - "minimum": 2, - "maximum": 4 - }, - "cpu":{ - "type": "object", - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - "enum": [ - "Utilization", - "AverageValue" - ] - }, - "value": { - "type": ["integer","string"] - }, - "enabled": { - "type": "boolean" - } - } - }, - "memory": { - "type": "object", - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - "enum": [ - "Utilization", - "AverageValue" - ] - }, - "value": { - "type": ["integer","string"] - }, - "enabled": { - "type": "boolean" - } - } - } - } } }, "additionalProperties": true diff --git a/charts/snyk-broker/values.yaml b/charts/snyk-broker/values.yaml index b9e07c3..0121bd3 100644 --- a/charts/snyk-broker/values.yaml +++ b/charts/snyk-broker/values.yaml @@ -11,17 +11,21 @@ brokerToken: "" # Ex: http://kubernetes-ingress.domain.com:8000 brokerClientUrl: "" -# Do not touch unless directed by a Snyk Representative +# See https://docs.snyk.io/working-with-snyk/regional-hosting-and-data-residency#broker-urls for regional endpoints +# Default endpoints are for the Snyk US tenant. brokerServerUrl: "https://broker.snyk.io" +brokerDispatcherUrl: "https://api.snyk.io" + preflightChecks: enabled: true +# The Broker is designed to work with multiple replicas (min 2, max 4) with High Availability mode enabled. + highAvailabilityMode: enabled: false -brokerDispatcherUrl: "https://api.snyk.io" -# This number if only used if enableHighAvailabilityMode is true +# This number is only used if highAvailabilityMode.enabled is true replicaCount: 2 # Adds additional labels to broker deployment @@ -34,7 +38,8 @@ labels: {} # Allowed values for scmType: # GitHub.com: github-com # GitHub Enterprise: github-enterprise -# Bitbucket: bitbucket-server +# Bitbucket Server: bitbucket-server +# Bitbucket Server with Bearer Auth: bitbucket-server-bearer-auth # GitLab: gitlab # Azure Repos: azure-repos # Artifactory: artifactory @@ -431,18 +436,3 @@ extraPodSpecs: extraPodSpecsCr: # As above, for Container Registry Agent - -##### The Broker is designed to work with multiple replicas (min 2, max 4) only with High Availability mode enabled. - -autoscaling: - enabled: false - minReplicas: 2 - maxReplicas: 4 - cpu: - type: "Utilization" - value: 80 - enabled: true - memory: - type: "Utilization" - value: 80 - enabled: false