Skip to content

Commit

Permalink
Backport: kubernetes#8400
Browse files Browse the repository at this point in the history
Update nginx base image in one place
  • Loading branch information
bromine0x23 committed Dec 10, 2023
1 parent 98b01b9 commit 332f335
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endif

REGISTRY ?= gcr.io/k8s-staging-ingress-nginx

BASE_IMAGE ?= k8s.gcr.io/ingress-nginx/nginx:5402d35663917ccbbf77ff48a22b8c6f77097f48@sha256:ec8a104df307f5c6d68157b7ac8e5e1e2c2f0ea07ddf25bb1c6c43c67e351180
BASE_IMAGE ?= $(shell cat NGINX_BASE)

GOARCH=$(ARCH)

Expand Down
1 change: 1 addition & 0 deletions NGINX_BASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
k8s.gcr.io/ingress-nginx/nginx:5402d35663917ccbbf77ff48a22b8c6f77097f48@sha256:ec8a104df307f5c6d68157b7ac8e5e1e2c2f0ea07ddf25bb1c6c43c67e351180
4 changes: 4 additions & 0 deletions build/run-e2e-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ trap cleanup EXIT
E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS:-}
FOCUS=${FOCUS:-.*}

BASEDIR=$(dirname "$0")
NGINX_BASE_IMAGE=$(cat $BASEDIR/../NGINX_BASE)

export E2E_CHECK_LEAKS
export FOCUS

Expand All @@ -76,6 +79,7 @@ kubectl run --rm \
--env="E2E_NODES=${E2E_NODES}" \
--env="FOCUS=${FOCUS}" \
--env="E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS}" \
--env="NGINX_BASE_IMAGE=${NGINX_BASE_IMAGE}" \
--overrides='{ "apiVersion": "v1", "spec":{"serviceAccountName": "ingress-nginx-e2e"}}' \
e2e --image=nginx-ingress-controller:e2e

3 changes: 2 additions & 1 deletion images/echo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ IMAGE = $(REGISTRY)/e2e-test-echo
# required to enable buildx
export DOCKER_CLI_EXPERIMENTAL=enabled

BASE_IMAGE = $(shell cat $(DIR)/../../NGINX_BASE)
# build with buildx
PLATFORMS?=linux/amd64
OUTPUT=
Expand All @@ -36,7 +37,7 @@ build: ensure-buildx
--platform=${PLATFORMS} $(OUTPUT) \
--progress=$(PROGRESS) \
--pull \
--build-arg BASE_IMAGE=k8s.gcr.io/ingress-nginx/nginx:5402d35663917ccbbf77ff48a22b8c6f77097f48@sha256:ec8a104df307f5c6d68157b7ac8e5e1e2c2f0ea07ddf25bb1c6c43c67e351180 \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
--build-arg LUAROCKS_VERSION=3.3.1 \
--build-arg LUAROCKS_SHA=837481e408f7c06b59befe7ec194537c657687d624894bca7f79034302141a34 \
-t $(IMAGE):$(TAG) rootfs
Expand Down
2 changes: 1 addition & 1 deletion images/nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This image provides a default configuration file with no backend servers.
_Using docker_

```console
docker run -v /some/nginx.conf:/etc/nginx/nginx.conf:ro k8s.gcr.io/ingress-nginx/nginx:5402d35663917ccbbf77ff48a22b8c6f77097f48@sha256:ec8a104df307f5c6d68157b7ac8e5e1e2c2f0ea07ddf25bb1c6c43c67e351180
docker run -v /some/nginx.conf:/etc/nginx/nginx.conf:ro $(cat ../../NGINX_BASE)
```

_Creating a replication controller_
Expand Down
15 changes: 11 additions & 4 deletions test/e2e/framework/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ const SlowEchoService = "slow-echo"
// HTTPBinService name of the deployment for the httpbin app
const HTTPBinService = "httpbin"

// NginxBaseImage use for testing
const NginxBaseImage = "k8s.gcr.io/ingress-nginx/nginx:5402d35663917ccbbf77ff48a22b8c6f77097f48@sha256:ec8a104df307f5c6d68157b7ac8e5e1e2c2f0ea07ddf25bb1c6c43c67e351180"

// NewEchoDeployment creates a new single replica deployment of the echoserver image in a particular namespace
func (f *Framework) NewEchoDeployment() {
f.NewEchoDeploymentWithReplicas(1)
Expand Down Expand Up @@ -127,6 +124,16 @@ http {
f.NGINXWithConfigDeployment(SlowEchoService, cfg)
}

func (f *Framework) GetNginxBaseImage() string {
nginxBaseImage := os.Getenv("NGINX_BASE_IMAGE")

if nginxBaseImage == "" {
assert.NotEmpty(ginkgo.GinkgoT(), errors.New("NGINX_BASE_IMAGE not defined"), "NGINX_BASE_IMAGE not defined")
}

return nginxBaseImage
}

// NGINXWithConfigDeployment creates an NGINX deployment using a configmap containing the nginx.conf configuration
func (f *Framework) NGINXWithConfigDeployment(name string, cfg string) {
cfgMap := map[string]string{
Expand All @@ -142,7 +149,7 @@ func (f *Framework) NGINXWithConfigDeployment(name string, cfg string) {
}, metav1.CreateOptions{})
assert.Nil(ginkgo.GinkgoT(), err, "creating configmap")

deployment := newDeployment(name, f.Namespace, NginxBaseImage, 80, 1,
deployment := newDeployment(name, f.Namespace, f.GetNginxBaseImage(), 80, 1,
nil,
[]corev1.VolumeMount{
{
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/run-chart-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-ingress-nginx-dev}

BASEDIR=$(dirname "$0")
NGINX_BASE_IMAGE=$(cat $BASEDIR/../../NGINX_BASE)

echo "Running e2e with nginx base image ${NGINX_BASE_IMAGE}"

export NGINX_BASE_IMAGE=$NGINX_BASE_IMAGE

export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/kind-config-$KIND_CLUSTER_NAME}"

if [ "${SKIP_CLUSTER_CREATION:-false}" = "false" ]; then
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export REGISTRY=ingress-controller

export DOCKER_CLI_EXPERIMENTAL=enabled

NGINX_BASE_IMAGE=$(cat $DIR/../../NGINX_BASE)

echo "Running e2e with nginx base image ${NGINX_BASE_IMAGE}"

export NGINX_BASE_IMAGE=$NGINX_BASE_IMAGE

export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/kind-config-$KIND_CLUSTER_NAME}"

if [ "${SKIP_CLUSTER_CREATION:-false}" = "false" ]; then
Expand Down

0 comments on commit 332f335

Please sign in to comment.