File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
charts/k8s-service/templates Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,13 @@ metadata:
9696{{ toYaml . | indent 4 }}
9797{{- end }}
9898spec:
99- replicas: {{ if .isCanary }}{{ .Values.canary.replicaCount | default 1 }}{{ else }}{{ .Values.replicaCount }}{{ end }}
99+ {{- if .isCanary }}
100+ replicas: {{ .Values.canary.replicaCount | default 1 }}
101+ {{ else }}
102+ {{- if not .Values.horizontalPodAutoscaler.enabled }}
103+ replicas: {{ .Values.replicaCount }}
104+ {{- end }}
105+ {{- end }}
100106{{- if .Values.deploymentStrategy.enabled }}
101107 strategy:
102108 type: {{ .Values.deploymentStrategy.type }}
Original file line number Diff line number Diff line change @@ -1077,3 +1077,33 @@ func TestK8SServiceClusterIP(t *testing.T) {
10771077 })
10781078 }
10791079}
1080+
1081+ // Test that setting horizontalPodAutoscaler.enabled = true will cause the helm template to not render replicas
1082+ func TestK8SServiceServiceHorizontalPodAutoscalerDoesNotConfigureReplicas (t * testing.T ) {
1083+ t .Parallel ()
1084+
1085+ deployment := renderK8SServiceDeploymentWithSetValues (
1086+ t ,
1087+ map [string ]string {
1088+ "horizontalPodAutoscaler.enabled" : "true" ,
1089+ "replicaCount" : "3" ,
1090+ },
1091+ )
1092+ assert .Equal (t , (* int32 )(nil ), deployment .Spec .Replicas )
1093+ }
1094+
1095+ // Test that setting horizontalPodAutoscaler = true will not affect the canary
1096+ func TestK8SServiceServiceHorizontalPodAutoscalerDoesNotAffectCanaryConfiguration (t * testing.T ) {
1097+ t .Parallel ()
1098+ deployment := renderK8SServiceCanaryDeploymentWithSetValues (
1099+ t ,
1100+ map [string ]string {
1101+ "canary.enabled" : "true" ,
1102+ "canary.replicaCount" : "6" ,
1103+ "canary.containerImage.repository" : "nginx" ,
1104+ "canary.containerImage.tag" : "1.16.0" ,
1105+ "horizontalPodAutoscaler.enabled" : "true" ,
1106+ },
1107+ )
1108+ assert .EqualValues (t , 6 , * deployment .Spec .Replicas )
1109+ }
You can’t perform that action at this time.
0 commit comments