chore: update template with missing common parameters (#26562)

This commit is contained in:
Juan Ariza Toledano
2024-06-03 16:32:27 +02:00
committed by GitHub
parent cd90285f16
commit 34ba9cf2a3
7 changed files with 110 additions and 25 deletions

View File

@@ -119,8 +119,13 @@ spec:
name: {{ include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.extraEnvVarsSecret "context" $) }}
{{- end }}
ports:
- containerPort: foo
protocol: bar
- name: http
containerPort: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.http }}
- name: https
containerPort: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.https }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.extraContainerPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.extraContainerPorts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.resources }}
resources: {{- toYaml .Values.%%MAIN_OBJECT_BLOCK%%.resources | nindent 12 }}
{{- else if ne .Values.%%MAIN_OBJECT_BLOCK%%.resourcesPreset "none" }}

View File

@@ -15,7 +15,7 @@ metadata:
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.enabled }}
{{- if not .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.enabled }}
replicas: {{ .Values.%%MAIN_OBJECT_BLOCK%%.replicaCount }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.updateStrategy }}
@@ -136,6 +136,9 @@ spec:
containerPort: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.http }}
- name: https
containerPort: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.https }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.extraContainerPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.extraContainerPorts "context" $) | nindent 12 }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe "context" $) | nindent 12 }}

View File

@@ -3,7 +3,7 @@ Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.enabled }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.enabled }}
apiVersion: {{ include "common.capabilities.hpa.apiVersion" . }}
kind: HorizontalPodAutoscaler
metadata:
@@ -19,31 +19,31 @@ spec:
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
name: {{ include "common.names.fullname" . }}
minReplicas: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.minReplicas }}
maxReplicas: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.maxReplicas }}
minReplicas: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.minReplicas }}
maxReplicas: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.maxReplicas }}
metrics:
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.targetMemory }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.targetMemory }}
- type: Resource
resource:
name: memory
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
targetAverageUtilization: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.targetMemory }}
targetAverageUtilization: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.targetMemory }}
{{- else }}
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetMemory }}
averageUtilization: {{ .Values.worker.autoscaling.hpa.targetMemory }}
{{- end }}
{{- end }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.targetCPU }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.targetCPU }}
- type: Resource
resource:
name: cpu
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
targetAverageUtilization: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.targetCPU }}
targetAverageUtilization: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.targetCPU }}
{{- else }}
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetCPU }}
averageUtilization: {{ .Values.worker.autoscaling.hpa.targetCPU }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -40,6 +40,9 @@ spec:
- ports:
- port: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.http }}
- port: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.https }}
{{- range .Values.%%MAIN_OBJECT_BLOCK%%.extraContainerPorts }}
- port: {{ .containerPort }}
{{- end }}
{{- if not .Values.networkPolicy.allowExternal }}
from:
- podSelector:

View File

@@ -15,8 +15,8 @@ metadata:
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- if not .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.enabled }}
replicas: {{ .Values.%%MAIN_OBJECT_BLOCK%%.replicaCount }}
{{- end }}
podManagementPolicy: {{ .Values.podManagementPolicy | quote }}
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.%%MAIN_OBJECT_BLOCK%%.podLabels .Values.commonLabels) "context" .) }}
@@ -139,6 +139,9 @@ spec:
containerPort: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.http }}
- name: https
containerPort: {{ .Values.%%MAIN_OBJECT_BLOCK%%.containerPorts.https }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.extraContainerPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.extraContainerPorts "context" $) | nindent 12 }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.customLivenessProbe "context" $) | nindent 12 }}

View File

@@ -0,0 +1,44 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and (.Capabilities.APIVersions.Has "autoscaling.k8s.io/v1/VerticalPodAutoscaler") .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.enabled }}
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: %%COMPONENT_NAME%%
{{- if or .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
resourcePolicy:
containerPolicies:
- containerName: %%MAIN_OBJECT_BLOCK%%
{{- with .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.controlledResources }}
controlledResources:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.maxAllowed }}
maxAllowed:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.minAllowed }}
minAllowed:
{{- toYaml . | nindent 8 }}
{{- end }}
targetRef:
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
name: {{ include "common.names.fullname" . }}
{{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.updatePolicy }}
updatePolicy:
{{- with .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.updatePolicy.updateMode }}
updateMode: {{ . }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -112,6 +112,13 @@ diagnosticMode:
containerPorts:
http: 80
https: 443
## @param %%MAIN_OBJECT_BLOCK%%.extraContainerPorts Optionally specify extra list of additional ports for %%MAIN_CONTAINER_NAME%% containers
## e.g:
## extraContainerPorts:
## - name: myservice
## containerPort: 9090
##
extraContainerPorts: []
## Configure extra options for %%MAIN_CONTAINER_NAME%% containers' liveness and readiness probes
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes
## @param %%MAIN_OBJECT_BLOCK%%.livenessProbe.enabled Enable livenessProbe on %%MAIN_CONTAINER_NAME%% containers
@@ -386,19 +393,39 @@ diagnosticMode:
minAvailable: ""
maxUnavailable: ""
## Autoscaling configuration
## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.enabled Enable autoscaling for %%MAIN_OBJECT_BLOCK%%
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.minReplicas Minimum number of %%MAIN_OBJECT_BLOCK%% replicas
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.maxReplicas Maximum number of %%MAIN_OBJECT_BLOCK%% replicas
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.targetCPU Target CPU utilization percentage
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.targetMemory Target Memory utilization percentage
## ref: https://kubernetes.io/docs/concepts/workloads/autoscaling/
##
autoscaling:
enabled: false
minReplicas: ""
maxReplicas: ""
targetCPU: ""
targetMemory: ""
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.enabled Enable VPA for %%MAIN_CONTAINER_NAME%% pods
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.annotations Annotations for VPA resource
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.controlledResources VPA List of resources that the vertical pod autoscaler can control. Defaults to cpu and memory
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.maxAllowed VPA Max allowed resources for the pod
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.minAllowed VPA Min allowed resources for the pod
##
vpa:
enabled: false
annotations: {}
controlledResources: []
maxAllowed: {}
minAllowed: {}
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.vpa.updatePolicy.updateMode Autoscaling update policy
## Specifies whether recommended updates are applied when a Pod is started and whether recommended updates are applied during the life of a Pod
## Possible values are "Off", "Initial", "Recreate", and "Auto".
##
updatePolicy:
updateMode: Auto
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.enabled Enable HPA for %%MAIN_CONTAINER_NAME%% pods
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.minReplicas Minimum number of replicas
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.maxReplicas Maximum number of replicas
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.targetCPU Target CPU utilization percentage
## @param %%MAIN_OBJECT_BLOCK%%.autoscaling.hpa.targetMemory Target Memory utilization percentage
##
hpa:
enabled: false
minReplicas: ""
maxReplicas: ""
targetCPU: ""
targetMemory: ""
## %%SECONDARY_CONTAINER/POD_DESCRIPTION%%
##