diff --git a/Makefile b/Makefile index f05400c6d..d55355573 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,10 @@ misspell: check-go-version ## Check for spelling errors. kind-e2e-test: check-go-version ## Run e2e tests using kind. @test/e2e/run.sh +.PHONY: kind-e2e-chart-tests +kind-e2e-chart-tests: ## Run helm chart e2e tests + @test/e2e/run-chart-test.sh + .PHONY: run-ingress-controller run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection. @build/run-ingress-controller.sh diff --git a/charts/ingress-nginx/ci/daemonset-customconfig-values.yaml b/charts/ingress-nginx/ci/daemonset-customconfig-values.yaml index f12eac3f9..e12b53421 100644 --- a/charts/ingress-nginx/ci/daemonset-customconfig-values.yaml +++ b/charts/ingress-nginx/ci/daemonset-customconfig-values.yaml @@ -1,4 +1,9 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false + service: + type: ClusterIP + config: use-proxy-protocol: "true" diff --git a/charts/ingress-nginx/ci/daemonset-customnodeport-values.yaml b/charts/ingress-nginx/ci/daemonset-customnodeport-values.yaml index 382bc50e2..cfc545f69 100644 --- a/charts/ingress-nginx/ci/daemonset-customnodeport-values.yaml +++ b/charts/ingress-nginx/ci/daemonset-customnodeport-values.yaml @@ -1,5 +1,8 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false + service: type: NodePort nodePorts: diff --git a/charts/ingress-nginx/ci/daemonset-headers-values.yaml b/charts/ingress-nginx/ci/daemonset-headers-values.yaml index a29690f1b..ff82cd9c7 100644 --- a/charts/ingress-nginx/ci/daemonset-headers-values.yaml +++ b/charts/ingress-nginx/ci/daemonset-headers-values.yaml @@ -1,6 +1,10 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false addHeaders: X-Frame-Options: deny proxySetHeaders: X-Forwarded-Proto: https + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/daemonset-nodeport-values.yaml b/charts/ingress-nginx/ci/daemonset-nodeport-values.yaml index ebc8f1020..6d6605f0e 100644 --- a/charts/ingress-nginx/ci/daemonset-nodeport-values.yaml +++ b/charts/ingress-nginx/ci/daemonset-nodeport-values.yaml @@ -1,4 +1,6 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false service: type: NodePort diff --git a/charts/ingress-nginx/ci/daemonset-tcp-udp-configMapNamespace-values.yaml b/charts/ingress-nginx/ci/daemonset-tcp-udp-configMapNamespace-values.yaml index 3484704f8..afb5487c5 100644 --- a/charts/ingress-nginx/ci/daemonset-tcp-udp-configMapNamespace-values.yaml +++ b/charts/ingress-nginx/ci/daemonset-tcp-udp-configMapNamespace-values.yaml @@ -1,5 +1,7 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false service: type: ClusterIP tcp: diff --git a/charts/ingress-nginx/ci/daemonset-tcp-udp-values.yaml b/charts/ingress-nginx/ci/daemonset-tcp-udp-values.yaml index e6866d7ca..7b4d7cbe7 100644 --- a/charts/ingress-nginx/ci/daemonset-tcp-udp-values.yaml +++ b/charts/ingress-nginx/ci/daemonset-tcp-udp-values.yaml @@ -1,5 +1,7 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false service: type: ClusterIP diff --git a/charts/ingress-nginx/ci/daemonset-tcp-values.yaml b/charts/ingress-nginx/ci/daemonset-tcp-values.yaml index f0a606087..a359a6a40 100644 --- a/charts/ingress-nginx/ci/daemonset-tcp-values.yaml +++ b/charts/ingress-nginx/ci/daemonset-tcp-values.yaml @@ -1,5 +1,9 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false + service: + type: ClusterIP tcp: 9000: "default/test:8080" diff --git a/charts/ingress-nginx/ci/deamonset-default-values.yaml b/charts/ingress-nginx/ci/deamonset-default-values.yaml index ddb25623a..e63a7f5db 100644 --- a/charts/ingress-nginx/ci/deamonset-default-values.yaml +++ b/charts/ingress-nginx/ci/deamonset-default-values.yaml @@ -1,2 +1,6 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deamonset-metrics-values.yaml b/charts/ingress-nginx/ci/deamonset-metrics-values.yaml index 5ce435d53..1e5190afc 100644 --- a/charts/ingress-nginx/ci/deamonset-metrics-values.yaml +++ b/charts/ingress-nginx/ci/deamonset-metrics-values.yaml @@ -1,4 +1,8 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false metrics: enabled: true + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deamonset-psp-values.yaml b/charts/ingress-nginx/ci/deamonset-psp-values.yaml index b441c1ad8..017b60a9c 100644 --- a/charts/ingress-nginx/ci/deamonset-psp-values.yaml +++ b/charts/ingress-nginx/ci/deamonset-psp-values.yaml @@ -1,5 +1,9 @@ controller: kind: DaemonSet + admissionWebhooks: + enabled: false + service: + type: ClusterIP podSecurityPolicy: enabled: true diff --git a/charts/ingress-nginx/ci/deamonset-webhook-and-psp-values.yaml b/charts/ingress-nginx/ci/deamonset-webhook-and-psp-values.yaml index 2cf9d6fd1..88aafc66f 100644 --- a/charts/ingress-nginx/ci/deamonset-webhook-and-psp-values.yaml +++ b/charts/ingress-nginx/ci/deamonset-webhook-and-psp-values.yaml @@ -2,6 +2,8 @@ controller: kind: DaemonSet admissionWebhooks: enabled: true + service: + type: ClusterIP podSecurityPolicy: enabled: true diff --git a/charts/ingress-nginx/ci/deamonset-webhook-values.yaml b/charts/ingress-nginx/ci/deamonset-webhook-values.yaml index 2d2cb4793..6e3b371da 100644 --- a/charts/ingress-nginx/ci/deamonset-webhook-values.yaml +++ b/charts/ingress-nginx/ci/deamonset-webhook-values.yaml @@ -2,3 +2,5 @@ controller: kind: DaemonSet admissionWebhooks: enabled: true + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deployment-autoscaling-values.yaml b/charts/ingress-nginx/ci/deployment-autoscaling-values.yaml index e9701daa7..5314cecb3 100644 --- a/charts/ingress-nginx/ci/deployment-autoscaling-values.yaml +++ b/charts/ingress-nginx/ci/deployment-autoscaling-values.yaml @@ -1,3 +1,7 @@ controller: autoscaling: enabled: true + admissionWebhooks: + enabled: false + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deployment-customconfig-values.yaml b/charts/ingress-nginx/ci/deployment-customconfig-values.yaml index 401aea422..f232531ac 100644 --- a/charts/ingress-nginx/ci/deployment-customconfig-values.yaml +++ b/charts/ingress-nginx/ci/deployment-customconfig-values.yaml @@ -1,3 +1,7 @@ controller: config: use-proxy-protocol: "true" + admissionWebhooks: + enabled: false + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deployment-customnodeport-values.yaml b/charts/ingress-nginx/ci/deployment-customnodeport-values.yaml index 6958eaac6..9eda282b1 100644 --- a/charts/ingress-nginx/ci/deployment-customnodeport-values.yaml +++ b/charts/ingress-nginx/ci/deployment-customnodeport-values.yaml @@ -1,4 +1,6 @@ controller: + admissionWebhooks: + enabled: false service: type: NodePort nodePorts: diff --git a/charts/ingress-nginx/ci/deployment-default-values.yaml b/charts/ingress-nginx/ci/deployment-default-values.yaml index b15f0e415..93a393c97 100644 --- a/charts/ingress-nginx/ci/deployment-default-values.yaml +++ b/charts/ingress-nginx/ci/deployment-default-values.yaml @@ -1 +1,4 @@ # Left blank to test default values +controller: + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deployment-headers-values.yaml b/charts/ingress-nginx/ci/deployment-headers-values.yaml index f3873af06..665fd48d3 100644 --- a/charts/ingress-nginx/ci/deployment-headers-values.yaml +++ b/charts/ingress-nginx/ci/deployment-headers-values.yaml @@ -1,5 +1,9 @@ controller: + admissionWebhooks: + enabled: false addHeaders: X-Frame-Options: deny proxySetHeaders: X-Forwarded-Proto: https + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deployment-metrics-values.yaml b/charts/ingress-nginx/ci/deployment-metrics-values.yaml index 9a93fa526..887ed0f62 100644 --- a/charts/ingress-nginx/ci/deployment-metrics-values.yaml +++ b/charts/ingress-nginx/ci/deployment-metrics-values.yaml @@ -1,3 +1,7 @@ controller: + admissionWebhooks: + enabled: false metrics: enabled: true + service: + type: ClusterIP diff --git a/charts/ingress-nginx/ci/deployment-nodeport-values.yaml b/charts/ingress-nginx/ci/deployment-nodeport-values.yaml index ffdc47b2d..84f1f7582 100644 --- a/charts/ingress-nginx/ci/deployment-nodeport-values.yaml +++ b/charts/ingress-nginx/ci/deployment-nodeport-values.yaml @@ -1,3 +1,5 @@ controller: + admissionWebhooks: + enabled: false service: type: NodePort diff --git a/charts/ingress-nginx/ci/deployment-psp-values.yaml b/charts/ingress-nginx/ci/deployment-psp-values.yaml index 7aae8605d..e339c69c3 100644 --- a/charts/ingress-nginx/ci/deployment-psp-values.yaml +++ b/charts/ingress-nginx/ci/deployment-psp-values.yaml @@ -1,2 +1,6 @@ +controller: + service: + type: ClusterIP + podSecurityPolicy: enabled: true diff --git a/charts/ingress-nginx/ci/deployment-tcp-udp-configMapNamespace-values.yaml b/charts/ingress-nginx/ci/deployment-tcp-udp-configMapNamespace-values.yaml index 7b06c1eb6..141e06b68 100644 --- a/charts/ingress-nginx/ci/deployment-tcp-udp-configMapNamespace-values.yaml +++ b/charts/ingress-nginx/ci/deployment-tcp-udp-configMapNamespace-values.yaml @@ -1,4 +1,6 @@ controller: + admissionWebhooks: + enabled: false service: type: ClusterIP tcp: diff --git a/charts/ingress-nginx/ci/deployment-tcp-udp-values.yaml b/charts/ingress-nginx/ci/deployment-tcp-udp-values.yaml index 7c55d4479..bc29abeba 100644 --- a/charts/ingress-nginx/ci/deployment-tcp-udp-values.yaml +++ b/charts/ingress-nginx/ci/deployment-tcp-udp-values.yaml @@ -1,4 +1,6 @@ controller: + admissionWebhooks: + enabled: false service: type: ClusterIP diff --git a/charts/ingress-nginx/ci/deployment-tcp-values.yaml b/charts/ingress-nginx/ci/deployment-tcp-values.yaml index c8bc20494..b7f54c09f 100644 --- a/charts/ingress-nginx/ci/deployment-tcp-values.yaml +++ b/charts/ingress-nginx/ci/deployment-tcp-values.yaml @@ -1,3 +1,7 @@ +controller: + service: + type: ClusterIP + tcp: 9000: "default/test:8080" 9001: "default/test:8080" diff --git a/charts/ingress-nginx/ci/deployment-webhook-and-psp-values.yaml b/charts/ingress-nginx/ci/deployment-webhook-and-psp-values.yaml index 0590d7c9f..a829c3614 100644 --- a/charts/ingress-nginx/ci/deployment-webhook-and-psp-values.yaml +++ b/charts/ingress-nginx/ci/deployment-webhook-and-psp-values.yaml @@ -1,6 +1,8 @@ controller: admissionWebhooks: enabled: true + service: + type: ClusterIP podSecurityPolicy: enabled: true diff --git a/charts/ingress-nginx/ci/deployment-webhook-values.yaml b/charts/ingress-nginx/ci/deployment-webhook-values.yaml index 07e1a925b..4f18a70b9 100644 --- a/charts/ingress-nginx/ci/deployment-webhook-values.yaml +++ b/charts/ingress-nginx/ci/deployment-webhook-values.yaml @@ -1,3 +1,5 @@ controller: admissionWebhooks: enabled: true + service: + type: ClusterIP diff --git a/test/e2e/kind.yaml b/test/e2e/kind.yaml index a59746fd3..a0bf30765 100644 --- a/test/e2e/kind.yaml +++ b/test/e2e/kind.yaml @@ -1,6 +1,14 @@ kind: Cluster -apiVersion: kind.sigs.k8s.io/v1alpha3 +apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane - role: worker - role: worker +kubeadmConfigPatches: +- | + kind: ClusterConfiguration + metadata: + name: config + controllerManager: + extraArgs: + namespace-sync-period: 10s diff --git a/test/e2e/run-chart-test.sh b/test/e2e/run-chart-test.sh new file mode 100755 index 000000000..b86b86255 --- /dev/null +++ b/test/e2e/run-chart-test.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +cleanup() { + if [[ "${KUBETEST_IN_DOCKER:-}" == "true" ]]; then + kind "export" logs --name ${KIND_CLUSTER_NAME} "${ARTIFACTS}/logs" || true + fi + + kind delete cluster \ + --name ${KIND_CLUSTER_NAME} +} + +trap cleanup EXIT + +if ! command -v kind --version &> /dev/null; then + echo "kind is not installed. Use the package manager or visit the official site https://kind.sigs.k8s.io/" + exit 1 +fi + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +export K8S_VERSION=${K8S_VERSION:-v1.18.0@sha256:0e20578828edd939d25eb98496a685c76c98d54084932f76069f886ec315d694} + +KIND_CLUSTER_NAME="ingress-nginx-dev" + +echo "[dev-env] creating Kubernetes cluster with kind" +export KUBECONFIG="${HOME}/.kube/kind-config-${KIND_CLUSTER_NAME}" +kind create cluster \ + --name ${KIND_CLUSTER_NAME} \ + --config "${DIR}/kind.yaml" \ + --retain \ + --image "kindest/node:${K8S_VERSION}" + +echo "Kubernetes cluster:" +kubectl get nodes -o wide + +echo "[dev-env] running helm chart e2e tests..." +docker run --rm --interactive --network host \ + --name ct \ + --volume $KUBECONFIG:/root/.kube/config \ + --volume "${DIR}/../../":/workdir \ + --workdir /workdir \ + quay.io/helmpack/chart-testing:v3.0.0-rc.1 ct install \ + --charts charts/ingress-nginx \ + --helm-extra-args "--timeout 120s"