Skip to content

Commit

Permalink
chart: bump k8s requirement to 1.19 (hashicorp#1049)
Browse files Browse the repository at this point in the history
* chart: bump k8s requirement to 1.19

will follow up with removal of bats test that are dependent on 1.18

* 1.19

* remove 1.19 tests for ui ingress

* remove 1.19 flags since we default to 1.19+

* missed one
  • Loading branch information
David Yu authored Feb 24, 2022
1 parent 918485c commit a5516c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 65 deletions.
2 changes: 1 addition & 1 deletion charts/consul/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: consul
version: 0.41.1
appVersion: 1.11.3
kubeVersion: ">=1.18.0-0"
kubeVersion: ">=1.19.0-0"
description: Official HashiCorp Consul Chart
home: https://www.consul.io
icon: https://raw.githubusercontent.com/hashicorp/consul-k8s/main/assets/icon.png
Expand Down
2 changes: 0 additions & 2 deletions charts/consul/templates/ui-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ metadata:
{{ tpl .Values.ui.ingress.annotations . | nindent 4 | trim }}
{{- end }}
spec:
{{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "18" ) }}
ingressClassName: {{ .Values.ui.ingress.ingressClassName }}
{{- end }}
rules:
{{ $global := .Values.global }}
{{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "19" ) }}
Expand Down
66 changes: 4 additions & 62 deletions charts/consul/test/unit/ui-ingress.bats
Original file line number Diff line number Diff line change
Expand Up @@ -59,109 +59,51 @@ load _helpers
[ "${actual}" = "foo.com" ]
}

@test "ui/Ingress: exposes single port 80 when global.tls.enabled=false when Kube version < 1.19" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=false' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.18" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[0].backend.servicePort' | tee /dev/stderr)
[ "${actual}" = "80" ]
}

@test "ui/Ingress: exposes single port 80 when global.tls.enabled=false when Kube version >= 1.19" {
@test "ui/Ingress: exposes single port 80 when global.tls.enabled=false" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=false' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.19" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[0].backend.service.port.number' | tee /dev/stderr)
[ "${actual}" = "80" ]
}

@test "ui/Ingress: exposes single port 443 when global.tls.enabled=true and global.tls.httpsOnly=true when Kube version < 1.19" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.18" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[0].backend.servicePort' | tee /dev/stderr)
[ "${actual}" = "443" ]
}

@test "ui/Ingress: exposes single port 443 when global.tls.enabled=true and global.tls.httpsOnly=true when Kube version >= 1.19" {
@test "ui/Ingress: exposes single port 443 when global.tls.enabled=true and global.tls.httpsOnly=true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.19" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[0].backend.service.port.number' | tee /dev/stderr)
[ "${actual}" = "443" ]
}

@test "ui/Ingress: exposes the port 80 when global.tls.enabled=true and global.tls.httpsOnly=false when Kube version < 1.19" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'global.tls.httpsOnly=false' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.18" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[0].backend.servicePort' | tee /dev/stderr)
[ "${actual}" = "80" ]
}

@test "ui/Ingress: exposes the port 80 when global.tls.enabled=true and global.tls.httpsOnly=false when Kube version >= 1.19" {
@test "ui/Ingress: exposes the port 80 when global.tls.enabled=true and global.tls.httpsOnly=false" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'global.tls.httpsOnly=false' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.19" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[0].backend.service.port.number' | tee /dev/stderr)
[ "${actual}" = "80" ]
}

@test "ui/Ingress: exposes the port 443 when global.tls.enabled=true and global.tls.httpsOnly=false when Kube version < 1.19" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'global.tls.httpsOnly=false' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.18" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[1].backend.servicePort' | tee /dev/stderr)
[ "${actual}" = "443" ]
}

@test "ui/Ingress: exposes the port 443 when global.tls.enabled=true and global.tls.httpsOnly=false when Kube version >= 1.19" {
@test "ui/Ingress: exposes the port 443 when global.tls.enabled=true and global.tls.httpsOnly=false" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'global.tls.httpsOnly=false' \
--set 'ui.ingress.hosts[0].host=foo.com' \
--kube-version "1.19" \
. | tee /dev/stderr |
yq -r '.spec.rules[0].http.paths[1].backend.service.port.number' | tee /dev/stderr)
[ "${actual}" = "443" ]
Expand Down

0 comments on commit a5516c9

Please sign in to comment.