diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json index 6a332631a9..c477a7aba5 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json @@ -1362,6 +1362,164 @@ "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", "description": "Wait for given period of time before scaling down the container", "title": "Wait For Seconds Before Scaling Down" + }, + "secondaryWorkload": { + "type": "object", + "description": "secondary workload deployment configuration", + "title": "Secondary Workload", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling secondary workload", + "title": "Enabled" + }, + "postfix": { + "type": "string", + "description": "postfix to distinguish secondary workload resources", + "title": "Postfix" + }, + "containerName": { + "type": "string", + "description": "override for secondary workload's main container name", + "title": "Container Name" + }, + "replicaCount": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "number of replicas for secondary workload", + "title": "Replica Count" + }, + "affinity": { + "type": "object", + "description": "affinity rules for secondary workload pods", + "title": "Affinity" + }, + "tolerations": { + "type": "array", + "items": {}, + "description": "tolerations for secondary workload pods", + "title": "Tolerations" + }, + "autoscaling": { + "type": "object", + "description": "autoscaling (HPA) settings for secondary workload", + "title": "Autoscaling", + "properties": { + "name": { + "type": "string", + "description": "custom name for secondary workload HPA", + "title": "Name" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling autoscaling for secondary workload", + "title": "Enabled" + }, + "MinReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Minimum number of replicas allowed for scaling secondary workload", + "title": "Minimum Replicas" + }, + "MaxReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Maximum number of replicas allowed for scaling secondary workload", + "title": "Maximum Replicas" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target CPU utilization that is expected for secondary workload", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target memory utilization that is expected for secondary workload", + "title": "TargetMemoryUtilizationPercentage" + }, + "behavior": { + "type": "object", + "description": "describes behavior and scaling policies for secondary workload HPA", + "title": "Behavior" + }, + "labels": { + "type": "object", + "description": "labels for secondary workload HPA", + "title": "labels" + }, + "annotations": { + "type": "object", + "description": "annotations for secondary workload HPA", + "title": "annotations" + }, + "extraMetrics": { + "type": "array", + "items": {}, + "description": "external metrics for secondary workload autoscaling", + "title": "Extra Metrics" + }, + "containerResource": { + "type": "object", + "description": "container resource metrics for secondary workload autoscaling", + "title": "Container Resource", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "enable container resource metrics", + "title": "Enabled" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "target CPU utilization for container", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "target memory utilization for container", + "title": "TargetMemoryUtilizationPercentage" + } + } + } + } + } + } } } } diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml index 5f8d35bd27..f93f0eac10 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml @@ -813,7 +813,7 @@ spec: {{- end}} {{- end}} containers: - - name: {{ $.Chart.Name }} + - name: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" imagePullPolicy: {{ $.Values.image.pullPolicy }} {{- if $.Values.containerSpec.lifecycle.enabled }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml index fd7c7e3f60..b812ba841e 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml @@ -91,7 +91,17 @@ spec: {{- toYaml $.Values.autoscaling.behavior | nindent 4 }} {{- end }} {{- end }} -{{- if and $.Values.secondaryWorkload.enabled $.Values.secondaryWorkload.autoscaling.enabled }} +{{- $primaryAutoscaling := $.Values.autoscaling | default dict }} +{{- $secAutoscaling := $.Values.secondaryWorkload.autoscaling | default dict }} +{{- $secHpaEnabled := false }} +{{- if $.Values.secondaryWorkload.enabled }} + {{- if hasKey $secAutoscaling "enabled" }} + {{- $secHpaEnabled = $secAutoscaling.enabled }} + {{- else }} + {{- $secHpaEnabled = $primaryAutoscaling.enabled }} + {{- end }} +{{- end }} +{{- if $secHpaEnabled }} --- {{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} apiVersion: autoscaling/v2 @@ -102,76 +112,104 @@ apiVersion: autoscaling/v2beta1 {{- end }} kind: HorizontalPodAutoscaler metadata: + {{- if and $secAutoscaling $secAutoscaling.name }} + name: {{ $secAutoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }}-hpa - {{- if .Values.autoscaling.annotations }} + {{- end }} + {{- if and $secAutoscaling $secAutoscaling.annotations }} annotations: -{{ toYaml .Values.autoscaling.annotations | indent 4 }} +{{ toYaml $secAutoscaling.annotations | indent 4 }} + {{- else if $primaryAutoscaling.annotations }} + annotations: +{{ toYaml $primaryAutoscaling.annotations | indent 4 }} {{- end }} - {{- if .Values.autoscaling.labels }} labels: -{{ toYaml .Values.autoscaling.labels | indent 4 }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + {{- if and $secAutoscaling $secAutoscaling.labels }} +{{ toYaml $secAutoscaling.labels | indent 4 }} + {{- else if $primaryAutoscaling.labels }} +{{ toYaml $primaryAutoscaling.labels | indent 4 }} {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: {{ include ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }} - {{- with $.Values.secondaryWorkload }} - minReplicas: {{ .autoscaling.MinReplicas }} - maxReplicas: {{ .autoscaling.MaxReplicas }} + minReplicas: {{ $secAutoscaling.MinReplicas | default $primaryAutoscaling.MinReplicas | default 1 }} + maxReplicas: {{ $secAutoscaling.MaxReplicas | default $primaryAutoscaling.MaxReplicas | default 2 }} metrics: - {{- if .autoscaling.containerResource.enabled }} - {{- with .autoscaling.containerResource }} - {{- if .TargetCPUUtilizationPercentage }} - - type: ContainerResource + {{- $containerResource := $secAutoscaling.containerResource | default $primaryAutoscaling.containerResource | default dict }} + {{- if $containerResource.enabled }} + {{- if $containerResource.TargetCPUUtilizationPercentage }} + - type: ContainerResource containerResource: name: cpu - container: {{ $.Chart.Name }} + container: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" target: type: Utilization - averageUtilization: {{ .TargetCPUUtilizationPercentage }} - {{- end}} - {{- if .TargetMemoryUtilizationPercentage }} - - type: ContainerResource + averageUtilization: {{ $containerResource.TargetCPUUtilizationPercentage }} + {{- end }} + {{- if $containerResource.TargetMemoryUtilizationPercentage }} + - type: ContainerResource containerResource: name: memory - container: {{ $.Chart.Name }} + container: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" target: type: Utilization - averageUtilization: {{ .TargetMemoryUtilizationPercentage }} - {{- end}} - {{- end }} - {{- end }} - {{- if .autoscaling.TargetMemoryUtilizationPercentage }} + averageUtilization: {{ $containerResource.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- end }} + {{- $targetMemory := "" }} + {{- if hasKey $secAutoscaling "TargetMemoryUtilizationPercentage" }} + {{- $targetMemory = $secAutoscaling.TargetMemoryUtilizationPercentage }} + {{- else if hasKey $primaryAutoscaling "TargetMemoryUtilizationPercentage" }} + {{- $targetMemory = $primaryAutoscaling.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- if $targetMemory }} - type: Resource resource: name: memory {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} target: type: Utilization - averageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + averageUtilization: {{ $targetMemory }} {{- else }} - targetAverageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + targetAverageUtilization: {{ $targetMemory }} {{- end }} {{- end }} - {{- if .autoscaling.TargetCPUUtilizationPercentage }} + {{- $targetCPU := "" }} + {{- if hasKey $secAutoscaling "TargetCPUUtilizationPercentage" }} + {{- $targetCPU = $secAutoscaling.TargetCPUUtilizationPercentage }} + {{- else if hasKey $primaryAutoscaling "TargetCPUUtilizationPercentage" }} + {{- $targetCPU = $primaryAutoscaling.TargetCPUUtilizationPercentage }} + {{- end }} + {{- if $targetCPU }} - type: Resource resource: name: cpu {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} target: type: Utilization - averageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + averageUtilization: {{ $targetCPU }} {{- else }} - targetAverageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + targetAverageUtilization: {{ $targetCPU }} {{- end }} {{- end }} - {{- if and .autoscaling.extraMetrics (semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion) }} - {{- toYaml .autoscaling.extraMetrics | nindent 2 }} - {{- end}} - {{- if and .autoscaling.behavior (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - behavior: - {{- toYaml .autoscaling.behavior | nindent 4 }} - {{- end }} + {{- $extraMetrics := $secAutoscaling.extraMetrics | default $primaryAutoscaling.extraMetrics }} + {{- if and $extraMetrics (semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion) }} + {{- toYaml $extraMetrics | nindent 2 }} {{- end }} + {{- $behavior := $secAutoscaling.behavior | default $primaryAutoscaling.behavior }} + {{- if and $behavior (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + behavior: + {{- toYaml $behavior | nindent 4 }} {{- end }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml index 55219ab5cb..9b417e497d 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml @@ -703,6 +703,8 @@ verticalPodScaling: secondaryWorkload: enabled: false + # Optional override for secondary workload's main container name + containerName: "" Spec: Affinity: Key: "" @@ -711,6 +713,9 @@ secondaryWorkload: affinity: {} tolerations: [] autoscaling: - enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: "" containerResource: enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/schema.json b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/schema.json index 6a332631a9..c477a7aba5 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/schema.json +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/schema.json @@ -1362,6 +1362,164 @@ "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", "description": "Wait for given period of time before scaling down the container", "title": "Wait For Seconds Before Scaling Down" + }, + "secondaryWorkload": { + "type": "object", + "description": "secondary workload deployment configuration", + "title": "Secondary Workload", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling secondary workload", + "title": "Enabled" + }, + "postfix": { + "type": "string", + "description": "postfix to distinguish secondary workload resources", + "title": "Postfix" + }, + "containerName": { + "type": "string", + "description": "override for secondary workload's main container name", + "title": "Container Name" + }, + "replicaCount": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "number of replicas for secondary workload", + "title": "Replica Count" + }, + "affinity": { + "type": "object", + "description": "affinity rules for secondary workload pods", + "title": "Affinity" + }, + "tolerations": { + "type": "array", + "items": {}, + "description": "tolerations for secondary workload pods", + "title": "Tolerations" + }, + "autoscaling": { + "type": "object", + "description": "autoscaling (HPA) settings for secondary workload", + "title": "Autoscaling", + "properties": { + "name": { + "type": "string", + "description": "custom name for secondary workload HPA", + "title": "Name" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling autoscaling for secondary workload", + "title": "Enabled" + }, + "MinReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Minimum number of replicas allowed for scaling secondary workload", + "title": "Minimum Replicas" + }, + "MaxReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Maximum number of replicas allowed for scaling secondary workload", + "title": "Maximum Replicas" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target CPU utilization that is expected for secondary workload", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target memory utilization that is expected for secondary workload", + "title": "TargetMemoryUtilizationPercentage" + }, + "behavior": { + "type": "object", + "description": "describes behavior and scaling policies for secondary workload HPA", + "title": "Behavior" + }, + "labels": { + "type": "object", + "description": "labels for secondary workload HPA", + "title": "labels" + }, + "annotations": { + "type": "object", + "description": "annotations for secondary workload HPA", + "title": "annotations" + }, + "extraMetrics": { + "type": "array", + "items": {}, + "description": "external metrics for secondary workload autoscaling", + "title": "Extra Metrics" + }, + "containerResource": { + "type": "object", + "description": "container resource metrics for secondary workload autoscaling", + "title": "Container Resource", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "enable container resource metrics", + "title": "Enabled" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "target CPU utilization for container", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "target memory utilization for container", + "title": "TargetMemoryUtilizationPercentage" + } + } + } + } + } + } } } } diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/deployment.yaml index eed0b4acc3..26dd523b8a 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/deployment.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/deployment.yaml @@ -825,7 +825,7 @@ spec: {{- end}} {{- end}} containers: - - name: "{{ if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" + - name: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" imagePullPolicy: {{ $.Values.image.pullPolicy }} {{- if $.Values.containerSpec.lifecycle.enabled }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/hpa.yaml index 78c89c4c2c..f389f09650 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/hpa.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/templates/hpa.yaml @@ -91,7 +91,17 @@ spec: {{- toYaml $.Values.autoscaling.behavior | nindent 4 }} {{- end }} {{- end }} -{{- if and $.Values.secondaryWorkload.enabled $.Values.secondaryWorkload.autoscaling.enabled }} +{{- $primaryAutoscaling := $.Values.autoscaling | default dict }} +{{- $secAutoscaling := $.Values.secondaryWorkload.autoscaling | default dict }} +{{- $secHpaEnabled := false }} +{{- if $.Values.secondaryWorkload.enabled }} + {{- if hasKey $secAutoscaling "enabled" }} + {{- $secHpaEnabled = $secAutoscaling.enabled }} + {{- else }} + {{- $secHpaEnabled = $primaryAutoscaling.enabled }} + {{- end }} +{{- end }} +{{- if $secHpaEnabled }} --- {{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} apiVersion: autoscaling/v2 @@ -102,76 +112,104 @@ apiVersion: autoscaling/v2beta1 {{- end }} kind: HorizontalPodAutoscaler metadata: + {{- if and $secAutoscaling $secAutoscaling.name }} + name: {{ $secAutoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }}-hpa - {{- if .Values.autoscaling.annotations }} + {{- end }} + {{- if and $secAutoscaling $secAutoscaling.annotations }} annotations: -{{ toYaml .Values.autoscaling.annotations | indent 4 }} +{{ toYaml $secAutoscaling.annotations | indent 4 }} + {{- else if $primaryAutoscaling.annotations }} + annotations: +{{ toYaml $primaryAutoscaling.annotations | indent 4 }} {{- end }} - {{- if .Values.autoscaling.labels }} labels: -{{ toYaml .Values.autoscaling.labels | indent 4 }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + {{- if and $secAutoscaling $secAutoscaling.labels }} +{{ toYaml $secAutoscaling.labels | indent 4 }} + {{- else if $primaryAutoscaling.labels }} +{{ toYaml $primaryAutoscaling.labels | indent 4 }} {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: {{ include ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }} - {{- with $.Values.secondaryWorkload }} - minReplicas: {{ .autoscaling.MinReplicas }} - maxReplicas: {{ .autoscaling.MaxReplicas }} + minReplicas: {{ $secAutoscaling.MinReplicas | default $primaryAutoscaling.MinReplicas | default 1 }} + maxReplicas: {{ $secAutoscaling.MaxReplicas | default $primaryAutoscaling.MaxReplicas | default 2 }} metrics: - {{- if .autoscaling.containerResource.enabled }} - {{- with .autoscaling.containerResource }} - {{- if .TargetCPUUtilizationPercentage }} - - type: ContainerResource + {{- $containerResource := $secAutoscaling.containerResource | default $primaryAutoscaling.containerResource | default dict }} + {{- if $containerResource.enabled }} + {{- if $containerResource.TargetCPUUtilizationPercentage }} + - type: ContainerResource containerResource: name: cpu - container: "{{ if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" + container: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" target: type: Utilization - averageUtilization: {{ .TargetCPUUtilizationPercentage }} - {{- end}} - {{- if .TargetMemoryUtilizationPercentage }} - - type: ContainerResource + averageUtilization: {{ $containerResource.TargetCPUUtilizationPercentage }} + {{- end }} + {{- if $containerResource.TargetMemoryUtilizationPercentage }} + - type: ContainerResource containerResource: name: memory - container: "{{ if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" + container: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" target: type: Utilization - averageUtilization: {{ .TargetMemoryUtilizationPercentage }} - {{- end}} - {{- end }} - {{- end }} - {{- if .autoscaling.TargetMemoryUtilizationPercentage }} + averageUtilization: {{ $containerResource.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- end }} + {{- $targetMemory := "" }} + {{- if hasKey $secAutoscaling "TargetMemoryUtilizationPercentage" }} + {{- $targetMemory = $secAutoscaling.TargetMemoryUtilizationPercentage }} + {{- else if hasKey $primaryAutoscaling "TargetMemoryUtilizationPercentage" }} + {{- $targetMemory = $primaryAutoscaling.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- if $targetMemory }} - type: Resource resource: name: memory {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} target: type: Utilization - averageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + averageUtilization: {{ $targetMemory }} {{- else }} - targetAverageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + targetAverageUtilization: {{ $targetMemory }} {{- end }} {{- end }} - {{- if .autoscaling.TargetCPUUtilizationPercentage }} + {{- $targetCPU := "" }} + {{- if hasKey $secAutoscaling "TargetCPUUtilizationPercentage" }} + {{- $targetCPU = $secAutoscaling.TargetCPUUtilizationPercentage }} + {{- else if hasKey $primaryAutoscaling "TargetCPUUtilizationPercentage" }} + {{- $targetCPU = $primaryAutoscaling.TargetCPUUtilizationPercentage }} + {{- end }} + {{- if $targetCPU }} - type: Resource resource: name: cpu {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} target: type: Utilization - averageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + averageUtilization: {{ $targetCPU }} {{- else }} - targetAverageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + targetAverageUtilization: {{ $targetCPU }} {{- end }} {{- end }} - {{- if and .autoscaling.extraMetrics (semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion) }} - {{- toYaml .autoscaling.extraMetrics | nindent 2 }} - {{- end}} - {{- if and .autoscaling.behavior (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - behavior: - {{- toYaml .autoscaling.behavior | nindent 4 }} - {{- end }} + {{- $extraMetrics := $secAutoscaling.extraMetrics | default $primaryAutoscaling.extraMetrics }} + {{- if and $extraMetrics (semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion) }} + {{- toYaml $extraMetrics | nindent 2 }} {{- end }} + {{- $behavior := $secAutoscaling.behavior | default $primaryAutoscaling.behavior }} + {{- if and $behavior (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + behavior: + {{- toYaml $behavior | nindent 4 }} {{- end }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/values.yaml index d0f96f7dd8..147a517afe 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-21-0/values.yaml @@ -718,6 +718,9 @@ secondaryWorkload: affinity: {} tolerations: [] autoscaling: - enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: "" containerResource: enabled: false diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/schema.json b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/schema.json index 6a332631a9..c477a7aba5 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/schema.json +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/schema.json @@ -1362,6 +1362,164 @@ "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", "description": "Wait for given period of time before scaling down the container", "title": "Wait For Seconds Before Scaling Down" + }, + "secondaryWorkload": { + "type": "object", + "description": "secondary workload deployment configuration", + "title": "Secondary Workload", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling secondary workload", + "title": "Enabled" + }, + "postfix": { + "type": "string", + "description": "postfix to distinguish secondary workload resources", + "title": "Postfix" + }, + "containerName": { + "type": "string", + "description": "override for secondary workload's main container name", + "title": "Container Name" + }, + "replicaCount": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "number of replicas for secondary workload", + "title": "Replica Count" + }, + "affinity": { + "type": "object", + "description": "affinity rules for secondary workload pods", + "title": "Affinity" + }, + "tolerations": { + "type": "array", + "items": {}, + "description": "tolerations for secondary workload pods", + "title": "Tolerations" + }, + "autoscaling": { + "type": "object", + "description": "autoscaling (HPA) settings for secondary workload", + "title": "Autoscaling", + "properties": { + "name": { + "type": "string", + "description": "custom name for secondary workload HPA", + "title": "Name" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling autoscaling for secondary workload", + "title": "Enabled" + }, + "MinReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Minimum number of replicas allowed for scaling secondary workload", + "title": "Minimum Replicas" + }, + "MaxReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Maximum number of replicas allowed for scaling secondary workload", + "title": "Maximum Replicas" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target CPU utilization that is expected for secondary workload", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target memory utilization that is expected for secondary workload", + "title": "TargetMemoryUtilizationPercentage" + }, + "behavior": { + "type": "object", + "description": "describes behavior and scaling policies for secondary workload HPA", + "title": "Behavior" + }, + "labels": { + "type": "object", + "description": "labels for secondary workload HPA", + "title": "labels" + }, + "annotations": { + "type": "object", + "description": "annotations for secondary workload HPA", + "title": "annotations" + }, + "extraMetrics": { + "type": "array", + "items": {}, + "description": "external metrics for secondary workload autoscaling", + "title": "Extra Metrics" + }, + "containerResource": { + "type": "object", + "description": "container resource metrics for secondary workload autoscaling", + "title": "Container Resource", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "enable container resource metrics", + "title": "Enabled" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "target CPU utilization for container", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "target memory utilization for container", + "title": "TargetMemoryUtilizationPercentage" + } + } + } + } + } + } } } } diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/deployment.yaml index eed0b4acc3..26dd523b8a 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/deployment.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/deployment.yaml @@ -825,7 +825,7 @@ spec: {{- end}} {{- end}} containers: - - name: "{{ if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" + - name: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" imagePullPolicy: {{ $.Values.image.pullPolicy }} {{- if $.Values.containerSpec.lifecycle.enabled }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/hpa.yaml index 78c89c4c2c..f389f09650 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/hpa.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/templates/hpa.yaml @@ -91,7 +91,17 @@ spec: {{- toYaml $.Values.autoscaling.behavior | nindent 4 }} {{- end }} {{- end }} -{{- if and $.Values.secondaryWorkload.enabled $.Values.secondaryWorkload.autoscaling.enabled }} +{{- $primaryAutoscaling := $.Values.autoscaling | default dict }} +{{- $secAutoscaling := $.Values.secondaryWorkload.autoscaling | default dict }} +{{- $secHpaEnabled := false }} +{{- if $.Values.secondaryWorkload.enabled }} + {{- if hasKey $secAutoscaling "enabled" }} + {{- $secHpaEnabled = $secAutoscaling.enabled }} + {{- else }} + {{- $secHpaEnabled = $primaryAutoscaling.enabled }} + {{- end }} +{{- end }} +{{- if $secHpaEnabled }} --- {{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} apiVersion: autoscaling/v2 @@ -102,76 +112,104 @@ apiVersion: autoscaling/v2beta1 {{- end }} kind: HorizontalPodAutoscaler metadata: + {{- if and $secAutoscaling $secAutoscaling.name }} + name: {{ $secAutoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }}-hpa - {{- if .Values.autoscaling.annotations }} + {{- end }} + {{- if and $secAutoscaling $secAutoscaling.annotations }} annotations: -{{ toYaml .Values.autoscaling.annotations | indent 4 }} +{{ toYaml $secAutoscaling.annotations | indent 4 }} + {{- else if $primaryAutoscaling.annotations }} + annotations: +{{ toYaml $primaryAutoscaling.annotations | indent 4 }} {{- end }} - {{- if .Values.autoscaling.labels }} labels: -{{ toYaml .Values.autoscaling.labels | indent 4 }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + {{- if and $secAutoscaling $secAutoscaling.labels }} +{{ toYaml $secAutoscaling.labels | indent 4 }} + {{- else if $primaryAutoscaling.labels }} +{{ toYaml $primaryAutoscaling.labels | indent 4 }} {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: {{ include ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }} - {{- with $.Values.secondaryWorkload }} - minReplicas: {{ .autoscaling.MinReplicas }} - maxReplicas: {{ .autoscaling.MaxReplicas }} + minReplicas: {{ $secAutoscaling.MinReplicas | default $primaryAutoscaling.MinReplicas | default 1 }} + maxReplicas: {{ $secAutoscaling.MaxReplicas | default $primaryAutoscaling.MaxReplicas | default 2 }} metrics: - {{- if .autoscaling.containerResource.enabled }} - {{- with .autoscaling.containerResource }} - {{- if .TargetCPUUtilizationPercentage }} - - type: ContainerResource + {{- $containerResource := $secAutoscaling.containerResource | default $primaryAutoscaling.containerResource | default dict }} + {{- if $containerResource.enabled }} + {{- if $containerResource.TargetCPUUtilizationPercentage }} + - type: ContainerResource containerResource: name: cpu - container: "{{ if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" + container: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" target: type: Utilization - averageUtilization: {{ .TargetCPUUtilizationPercentage }} - {{- end}} - {{- if .TargetMemoryUtilizationPercentage }} - - type: ContainerResource + averageUtilization: {{ $containerResource.TargetCPUUtilizationPercentage }} + {{- end }} + {{- if $containerResource.TargetMemoryUtilizationPercentage }} + - type: ContainerResource containerResource: name: memory - container: "{{ if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" + container: "{{ if $.Values.secondaryWorkload.containerName }}{{ $.Values.secondaryWorkload.containerName }}{{ else if $.Values.containerName }}{{ $.Values.containerName }}{{ else }}{{ $.Chart.Name }}{{ end }}" target: type: Utilization - averageUtilization: {{ .TargetMemoryUtilizationPercentage }} - {{- end}} - {{- end }} - {{- end }} - {{- if .autoscaling.TargetMemoryUtilizationPercentage }} + averageUtilization: {{ $containerResource.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- end }} + {{- $targetMemory := "" }} + {{- if hasKey $secAutoscaling "TargetMemoryUtilizationPercentage" }} + {{- $targetMemory = $secAutoscaling.TargetMemoryUtilizationPercentage }} + {{- else if hasKey $primaryAutoscaling "TargetMemoryUtilizationPercentage" }} + {{- $targetMemory = $primaryAutoscaling.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- if $targetMemory }} - type: Resource resource: name: memory {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} target: type: Utilization - averageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + averageUtilization: {{ $targetMemory }} {{- else }} - targetAverageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + targetAverageUtilization: {{ $targetMemory }} {{- end }} {{- end }} - {{- if .autoscaling.TargetCPUUtilizationPercentage }} + {{- $targetCPU := "" }} + {{- if hasKey $secAutoscaling "TargetCPUUtilizationPercentage" }} + {{- $targetCPU = $secAutoscaling.TargetCPUUtilizationPercentage }} + {{- else if hasKey $primaryAutoscaling "TargetCPUUtilizationPercentage" }} + {{- $targetCPU = $primaryAutoscaling.TargetCPUUtilizationPercentage }} + {{- end }} + {{- if $targetCPU }} - type: Resource resource: name: cpu {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} target: type: Utilization - averageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + averageUtilization: {{ $targetCPU }} {{- else }} - targetAverageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + targetAverageUtilization: {{ $targetCPU }} {{- end }} {{- end }} - {{- if and .autoscaling.extraMetrics (semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion) }} - {{- toYaml .autoscaling.extraMetrics | nindent 2 }} - {{- end}} - {{- if and .autoscaling.behavior (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - behavior: - {{- toYaml .autoscaling.behavior | nindent 4 }} - {{- end }} + {{- $extraMetrics := $secAutoscaling.extraMetrics | default $primaryAutoscaling.extraMetrics }} + {{- if and $extraMetrics (semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion) }} + {{- toYaml $extraMetrics | nindent 2 }} {{- end }} + {{- $behavior := $secAutoscaling.behavior | default $primaryAutoscaling.behavior }} + {{- if and $behavior (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + behavior: + {{- toYaml $behavior | nindent 4 }} {{- end }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/values.yaml index d0f96f7dd8..147a517afe 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-22-0/values.yaml @@ -718,6 +718,9 @@ secondaryWorkload: affinity: {} tolerations: [] autoscaling: - enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: "" containerResource: enabled: false