Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET-6812 Allow meshGateway.enabled when resource-apis experiment is enabled #3285

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions charts/consul/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,6 @@ Usage: {{ template "consul.validateResourceAPIs" . }}
{{- if (and (mustHas "resource-apis" .Values.global.experiments) .Values.syncCatalog.enabled ) }}
{{fail "When the value global.experiments.resourceAPIs is set, syncCatalog.enabled is currently unsupported."}}
{{- end }}
{{- if (and (mustHas "resource-apis" .Values.global.experiments) .Values.meshGateway.enabled ) }}
{{fail "When the value global.experiments.resourceAPIs is set, meshGateway.enabled is currently unsupported."}}
{{- end }}
{{- if (and (mustHas "resource-apis" .Values.global.experiments) .Values.ingressGateways.enabled ) }}
{{fail "When the value global.experiments.resourceAPIs is set, ingressGateways.enabled is currently unsupported."}}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/gateway-resources-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
resources.json: |
{{ toJson .Values.connectInject.apiGateway.managedGatewayClass.resources }}
{{- end }}
{{- if (mustHas "resource-apis" .Values.global.experiments) }}
{{- if and (mustHas "resource-apis" .Values.global.experiments) .Values.meshGateway.enabled }}
config.yaml: |
gatewayClassConfigs:
- apiVersion: mesh.consul.hashicorp.com/v2beta1
Expand Down
2 changes: 2 additions & 0 deletions charts/consul/templates/mesh-gateway-clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.meshGateway.enabled }}
{{- if not (mustHas "resource-apis" .Values.global.experiments) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down Expand Up @@ -32,3 +33,4 @@ rules:
rules: []
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.meshGateway.enabled }}
{{- if not (mustHas "resource-apis" .Values.global.experiments) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand All @@ -18,3 +19,4 @@ subjects:
name: {{ template "consul.fullname" . }}-mesh-gateway
namespace: {{ .Release.Namespace }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/consul/templates/mesh-gateway-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.meshGateway.enabled }}
{{- if not (mustHas "resource-apis" .Values.global.experiments) }}
{{- if not .Values.connectInject.enabled }}{{ fail "connectInject.enabled must be true" }}{{ end -}}
{{- if and .Values.global.acls.manageSystemACLs (ne .Values.meshGateway.consulServiceName "") (ne .Values.meshGateway.consulServiceName "mesh-gateway") }}{{ fail "if global.acls.manageSystemACLs is true, meshGateway.consulServiceName cannot be set" }}{{ end -}}
{{- if .Values.meshGateway.globalMode }}{{ fail "meshGateway.globalMode is no longer supported; instead, you must migrate to CRDs (see www.consul.io/docs/k8s/crds/upgrade-to-crds)" }}{{ end -}}
Expand Down Expand Up @@ -309,3 +310,4 @@ spec:
{{ tpl .Values.meshGateway.nodeSelector . | indent 8 | trim }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/consul/templates/mesh-gateway-podsecuritypolicy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if and .Values.global.enablePodSecurityPolicies .Values.meshGateway.enabled }}
{{- if not (mustHas "resource-apis" .Values.global.experiments) }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
Expand Down Expand Up @@ -52,3 +53,4 @@ spec:
rule: 'RunAsAny'
readOnlyRootFilesystem: false
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/consul/templates/mesh-gateway-service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if and .Values.meshGateway.enabled }}
{{- if not (mustHas "resource-apis" .Values.global.experiments) }}
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -31,3 +32,4 @@ spec:
{{ tpl .Values.meshGateway.service.additionalSpec . | nindent 2 | trim }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/consul/templates/mesh-gateway-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.meshGateway.enabled }}
{{- if not (mustHas "resource-apis" .Values.global.experiments) }}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand All @@ -21,3 +22,4 @@ imagePullSecrets:
{{- end }}
{{- end }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/consul/test/unit/gateway-resources-configmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ load _helpers
local resources=$(helm template \
-s templates/gateway-resources-configmap.yaml \
--set 'connectInject.enabled=true' \
--set 'meshGateway.enabled=true' \
--set 'global.experiments[0]=resource-apis' \
--set 'ui.enabled=false' \
. | tee /dev/stderr |
Expand Down
12 changes: 0 additions & 12 deletions charts/consul/test/unit/helpers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -431,18 +431,6 @@ load _helpers
[[ "$output" =~ "When the value global.experiments.resourceAPIs is set, syncCatalog.enabled is currently unsupported." ]]
}

@test "connectInject/Deployment: fails if resource-apis is set and meshGateway is enabled" {
cd `chart_dir`
run helm template \
-s templates/tests/test-runner.yaml \
--set 'connectInject.enabled=true' \
--set 'global.experiments[0]=resource-apis' \
--set 'ui.enabled=false' \
--set 'meshGateway.enabled=true' .
[ "$status" -eq 1 ]
[[ "$output" =~ "When the value global.experiments.resourceAPIs is set, meshGateway.enabled is currently unsupported." ]]
}

@test "connectInject/Deployment: fails if resource-apis is set and ingressGateways is enabled" {
cd `chart_dir`
run helm template \
Expand Down