Skip to content

Commit 118488e

Browse files
authored
Test Chart installation for Plus and remote images (#2060)
Problem: We're not testing the Helm Chart installation with NGINX Plus and with pre-built images Solution: Add installation steps for both
1 parent c8bbcde commit 118488e

File tree

6 files changed

+203
-113
lines changed

6 files changed

+203
-113
lines changed

.github/workflows/ci.yml

+28-93
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,33 @@ jobs:
3131
outputs:
3232
go_path: ${{ steps.vars.outputs.go_path }}
3333
min_k8s_version: ${{ steps.vars.outputs.min_k8s_version }}
34+
k8s_latest: ${{ steps.vars.outputs.k8s_latest }}
35+
helm_changes: ${{ steps.filter.outputs.charts }}
3436
steps:
3537
- name: Checkout Repository
3638
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
39+
with:
40+
fetch-depth: 0
3741

3842
- name: Setup Golang Environment
3943
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
4044
with:
4145
go-version: stable
4246

47+
- name: Check for changes
48+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
49+
id: filter
50+
with:
51+
filters: |
52+
charts:
53+
- charts/nginx-gateway-fabric/**/*
54+
4355
- name: Output Variables
4456
id: vars
4557
run: |
4658
echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
47-
echo "min_k8s_version=1.25.16" >> $GITHUB_OUTPUT
59+
echo "min_k8s_version=v1.25.16" >> $GITHUB_OUTPUT
60+
echo "k8s_latest=$(grep -m1 'FROM kindest/node' <tests/Dockerfile | awk -F'[:]' '{print $2}')" >> $GITHUB_OUTPUT
4861
4962
- name: Check if go.mod and go.sum are up to date
5063
run: go mod tidy && git diff --exit-code -- go.mod go.sum
@@ -211,7 +224,7 @@ jobs:
211224
fail-fast: false
212225
matrix:
213226
image: [nginx, plus]
214-
k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "latest"]
227+
k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "${{ needs.vars.outputs.k8s_latest }}"]
215228
uses: ./.github/workflows/functional.yml
216229
with:
217230
image: ${{ matrix.image }}
@@ -226,7 +239,7 @@ jobs:
226239
fail-fast: false
227240
matrix:
228241
image: [nginx, plus]
229-
k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "latest"]
242+
k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "${{ needs.vars.outputs.k8s_latest }}"]
230243
enable-experimental: [true, false]
231244
uses: ./.github/workflows/conformance.yml
232245
with:
@@ -238,96 +251,18 @@ jobs:
238251

239252
helm-tests:
240253
name: Helm Tests
241-
runs-on: ubuntu-22.04
242-
needs: [vars, build-oss]
243-
steps:
244-
- name: Checkout Repository
245-
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
246-
247-
- name: Fetch Cached Artifacts
248-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
249-
with:
250-
path: ${{ github.workspace }}/dist
251-
key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }}
252-
253-
- name: Docker Buildx
254-
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
255-
256-
- name: NGF Docker meta
257-
id: ngf-meta
258-
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
259-
with:
260-
images: |
261-
name=ghcr.io/nginxinc/nginx-gateway-fabric
262-
tags: |
263-
type=semver,pattern={{version}}
264-
type=edge
265-
type=ref,event=pr
266-
type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }}
267-
268-
- name: NGINX Docker meta
269-
id: nginx-meta
270-
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
271-
with:
272-
images: |
273-
name=ghcr.io/nginxinc/nginx-gateway-fabric/nginx
274-
tags: |
275-
type=semver,pattern={{version}}
276-
type=edge
277-
type=ref,event=pr
278-
type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }}
279-
280-
- name: Build NGF Docker Image
281-
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
282-
with:
283-
file: build/Dockerfile
284-
tags: ${{ steps.ngf-meta.outputs.tags }}
285-
context: "."
286-
target: goreleaser
287-
load: true
288-
cache-from: type=gha,scope=ngf
289-
pull: true
290-
291-
- name: Build NGINX Docker Image
292-
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
293-
with:
294-
file: build/Dockerfile.nginx
295-
tags: ${{ steps.nginx-meta.outputs.tags }}
296-
context: "."
297-
load: true
298-
cache-from: type=gha,scope=nginx
299-
pull: true
300-
build-args: |
301-
NJS_DIR=internal/mode/static/nginx/modules/src
302-
NGINX_CONF_DIR=internal/mode/static/nginx/conf
303-
BUILD_AGENT=gha
304-
305-
- name: Deploy Kubernetes
306-
id: k8s
307-
run: |
308-
kube_config=${{ github.workspace }}/kube-${{ github.run_id }}-helm
309-
make create-kind-cluster KIND_KUBE_CONFIG=${kube_config}
310-
echo "KUBECONFIG=${kube_config}" >> "$GITHUB_ENV"
311-
kind load docker-image ghcr.io/nginxinc/nginx-gateway-fabric:${{ steps.ngf-meta.outputs.version }} ghcr.io/nginxinc/nginx-gateway-fabric/nginx:${{ steps.nginx-meta.outputs.version }}
312-
kubectl kustomize config/crd/gateway-api/standard | kubectl apply -f -
313-
314-
- name: Install Chart
315-
run: >
316-
helm install
317-
helm-$(echo ${{ steps.ngf-meta.outputs.version }} | tr '.' '-')
318-
.
319-
--wait
320-
--create-namespace
321-
--set nginxGateway.image.repository=ghcr.io/nginxinc/nginx-gateway-fabric
322-
--set nginxGateway.image.tag=${{ steps.ngf-meta.outputs.version }}
323-
--set nginxGateway.image.pullPolicy=Never
324-
--set nginxGateway.productTelemetry.enable=false
325-
--set nginx.image.repository=ghcr.io/nginxinc/nginx-gateway-fabric/nginx
326-
--set nginx.image.tag=${{ steps.nginx-meta.outputs.version }}
327-
--set nginx.image.pullPolicy=Never
328-
--set service.type=NodePort
329-
-n nginx-gateway
330-
working-directory: ${{ github.workspace }}/charts/nginx-gateway-fabric
254+
needs: [vars, build-oss, build-plus]
255+
strategy:
256+
fail-fast: false
257+
matrix:
258+
image: [nginx, plus]
259+
k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "${{ needs.vars.outputs.k8s_latest }}"]
260+
uses: ./.github/workflows/helm.yml
261+
with:
262+
image: ${{ matrix.image }}
263+
k8s-version: ${{ matrix.k8s-version }}
264+
secrets: inherit
265+
if: ${{ needs.vars.outputs.helm_changes == 'true' || github.event_name == 'schedule' }}
331266

332267
publish-helm:
333268
name: Package and Publish Helm Chart

.github/workflows/conformance.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,22 @@ jobs:
129129
- name: Deploy Kubernetes
130130
id: k8s
131131
run: |
132-
k8s_version=${{ inputs.k8s-version }}
133-
make create-kind-cluster KIND_KUBE_CONFIG=${{ github.workspace }}/kube-${{ github.run_id }} ${{ ! contains(inputs.k8s-version, 'latest') && 'KIND_IMAGE=kindest/node:v${k8s_version}' || '' }}
134-
echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV"
135-
working-directory: ./tests
132+
kind create cluster --name ${{ github.run_id }} --image=kindest/node:${{ inputs.k8s-version }}
133+
kind load docker-image ${{ join(fromJSON(steps.ngf-meta.outputs.json).tags, ' ') }} ${{ join(fromJSON(steps.nginx-meta.outputs.json).tags, ' ') }} --name ${{ github.run_id }}
136134
137135
- name: Setup conformance tests
138136
run: |
139137
ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric
140138
ngf_tag=${{ steps.ngf-meta.outputs.version }}
141139
if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi
142140
if [ ${{ inputs.enable-experimental }} == "true" ]; then export ENABLE_EXPERIMENTAL=true; fi
143-
make install-ngf-local-no-build${{ inputs.image == 'plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag}
141+
make helm-install-local${{ inputs.image == 'plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag}
142+
make deploy-updated-provisioner PREFIX=${ngf_prefix} TAG=${ngf_tag}
144143
working-directory: ./tests
145144

146145
- name: Run conformance tests
147146
run: |
148-
make run-conformance-tests CONFORMANCE_TAG=${{ github.sha }} NGF_VERSION=${{ github.ref_name }}
147+
make run-conformance-tests CONFORMANCE_TAG=${{ github.sha }} NGF_VERSION=${{ github.ref_name }} CLUSTER_NAME=${{ github.run_id }}
149148
core_result=$(cat conformance-profile.yaml | yq '.profiles[0].core.result')
150149
extended_result=$(cat conformance-profile.yaml | yq '.profiles[0].extended.result')
151150
if [ "${core_result}" == "failure" ] || [ "${extended_result}" == "failure" ]; then echo "Conformance test failed, see above for details." && exit 2; fi

.github/workflows/functional.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,8 @@ jobs:
101101
- name: Deploy Kubernetes
102102
id: k8s
103103
run: |
104-
k8s_version=${{ inputs.k8s-version }}
105-
make create-kind-cluster KIND_KUBE_CONFIG=${{ github.workspace }}/kube-${{ github.run_id }} ${{ ! contains(inputs.k8s-version, 'latest') && 'KIND_IMAGE=kindest/node:v${k8s_version}' || '' }}
106-
echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV"
107-
108-
- name: Setup functional tests
109-
id: setup
110-
run: |
111-
ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric
112-
ngf_tag=${{ steps.ngf-meta.outputs.version }}
113-
make load-images${{ inputs.image == 'plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag}
114-
working-directory: ./tests
104+
kind create cluster --name ${{ github.run_id }} --image=kindest/node:${{ inputs.k8s-version }}
105+
kind load docker-image ${{ join(fromJSON(steps.ngf-meta.outputs.json).tags, ' ') }} ${{ join(fromJSON(steps.nginx-meta.outputs.json).tags, ' ') }} --name ${{ github.run_id }}
115106
116107
- name: Run functional telemetry tests
117108
run: |

.github/workflows/helm.yml

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Helm Testing
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image:
7+
required: true
8+
type: string
9+
k8s-version:
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
helm-tests-local:
18+
name: Helm Tests Local
19+
runs-on: ubuntu-22.04
20+
if: ${{ github.event_name != 'schedule' }}
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Fetch Cached Artifacts
28+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
29+
with:
30+
path: ${{ github.workspace }}/dist
31+
key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }}
32+
33+
- name: Docker Buildx
34+
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
35+
36+
- name: NGF Docker meta
37+
id: ngf-meta
38+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
39+
with:
40+
images: |
41+
name=ghcr.io/nginxinc/nginx-gateway-fabric
42+
tags: |
43+
type=semver,pattern={{version}}
44+
type=edge
45+
type=schedule
46+
type=ref,event=pr
47+
type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }}
48+
49+
- name: NGINX Docker meta
50+
id: nginx-meta
51+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
52+
with:
53+
images: |
54+
name=ghcr.io/nginxinc/nginx-gateway-fabric/${{ inputs.image == 'plus' && 'nginx-plus' || inputs.image }}
55+
tags: |
56+
type=semver,pattern={{version}}
57+
type=edge
58+
type=schedule
59+
type=ref,event=pr
60+
type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }}
61+
62+
- name: Build NGF Docker Image
63+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
64+
with:
65+
file: build/Dockerfile
66+
tags: ${{ steps.ngf-meta.outputs.tags }}
67+
context: "."
68+
target: goreleaser
69+
load: true
70+
cache-from: type=gha,scope=ngf
71+
pull: true
72+
73+
- name: Build NGINX Docker Image
74+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
75+
with:
76+
file: build/Dockerfile${{ inputs.image == 'nginx' && '.nginx' || '' }}${{ inputs.image == 'plus' && '.nginxplus' || ''}}
77+
tags: ${{ steps.nginx-meta.outputs.tags }}
78+
context: "."
79+
load: true
80+
cache-from: type=gha,scope=${{ inputs.image }}
81+
pull: true
82+
build-args: |
83+
NJS_DIR=internal/mode/static/nginx/modules/src
84+
NGINX_CONF_DIR=internal/mode/static/nginx/conf
85+
BUILD_AGENT=gha
86+
87+
- name: Install cloud-provider-kind
88+
run: |
89+
curl -fsSL -O https://github.com/kubernetes-sigs/cloud-provider-kind/releases/download/v0.2.0/cloud-provider-kind_0.2.0_linux_amd64.tar.gz
90+
tar -xvf cloud-provider-kind_0.2.0_linux_amd64.tar.gz
91+
92+
- name: Run cloud-provider-kind
93+
run: ./cloud-provider-kind & > cloud-provider-kind.log 2>&1
94+
95+
- name: Deploy Kubernetes
96+
id: k8s
97+
run: |
98+
kind create cluster --name ${{ github.run_id }} --image=kindest/node:${{ inputs.k8s-version }}
99+
kind load docker-image ${{ join(fromJSON(steps.ngf-meta.outputs.json).tags, ' ') }} ${{ join(fromJSON(steps.nginx-meta.outputs.json).tags, ' ') }} --name ${{ github.run_id }}
100+
kubectl kustomize config/crd/gateway-api/standard | kubectl apply -f -
101+
102+
- name: Set up Python
103+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
104+
with:
105+
python-version: "3.x"
106+
check-latest: true
107+
108+
- name: Set up chart-testing
109+
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
110+
111+
- name: Install Chart
112+
run: |
113+
ct install --config .ct.yaml --helm-extra-set-args="--set=nginxGateway.image.tag=${{ steps.ngf-meta.outputs.version }} \
114+
--set=nginx.image.repository=ghcr.io/nginxinc/nginx-gateway-fabric/nginx${{ inputs.image == 'plus' && '-plus' || ''}} \
115+
--set=nginx.plus=${{ inputs.image == 'plus' }} \
116+
--set=nginx.image.tag=${{ steps.nginx-meta.outputs.version }} \
117+
--set=nginxGateway.image.pullPolicy=Never \
118+
--set=nginx.image.pullPolicy=Never \
119+
--set=nginxGateway.productTelemetry.enable=false"
120+
121+
helm-test-remote:
122+
name: Helm Tests Remote
123+
runs-on: ubuntu-22.04
124+
if: ${{ github.event_name == 'schedule' }}
125+
steps:
126+
- name: Checkout Repository
127+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
128+
with:
129+
fetch-depth: 0
130+
131+
- name: Install cloud-provider-kind
132+
run: |
133+
curl -fsSL -O https://github.com/kubernetes-sigs/cloud-provider-kind/releases/download/v0.2.0/cloud-provider-kind_0.2.0_linux_amd64.tar.gz
134+
tar -xvf cloud-provider-kind_0.2.0_linux_amd64.tar.gz
135+
136+
- name: Run cloud-provider-kind
137+
run: ./cloud-provider-kind & > cloud-provider-kind.log 2>&1
138+
139+
- name: Deploy Kubernetes
140+
id: k8s
141+
run: |
142+
kind create cluster --name ${{ github.run_id }} --image=kindest/node:${{ inputs.k8s-version }}
143+
kubectl kustomize config/crd/gateway-api/standard | kubectl apply -f -
144+
kubectl create namespace nginx-gateway
145+
146+
- name: Create k8s secret
147+
if: ${{ inputs.image == 'plus' }}
148+
run: |
149+
kubectl create secret docker-registry nginx-plus-registry-secret --docker-server=private-registry.nginx.com --docker-username=${{ secrets.JWT_PLUS_REGISTRY }} --docker-password=none -n nginx-gateway
150+
151+
- name: Set up Python
152+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
153+
with:
154+
python-version: "3.x"
155+
check-latest: true
156+
157+
- name: Set up chart-testing
158+
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
159+
160+
- name: Install Chart
161+
run: |
162+
ct install --config .ct.yaml --all --namespace nginx-gateway --helm-extra-set-args="--set=nginxGateway.image.tag=nightly \
163+
--set=nginx.plus=${{ inputs.image == 'plus' }} \
164+
--set=nginx.image.tag=nightly \
165+
--set=nginxGateway.productTelemetry.enable=false \
166+
${{ inputs.image == 'plus' && '--set=serviceAccount.imagePullSecret=nginx-plus-registry-secret --set=nginx.image.repository=private-registry.nginx.com/nginx-gateway-fabric/nginx-plus' || '' }}"

Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ NGINX_PREFIX ?= $(PREFIX)/nginx## The name of the nginx image. For example: ngin
3131
NGINX_PLUS_PREFIX ?= $(PREFIX)/nginx-plus## The name of the nginx plus image. For example: nginx-gateway-fabric/nginx-plus
3232
TAG ?= $(VERSION:v%=%)## The tag of the image. For example, 1.1.0
3333
TARGET ?= local## The target of the build. Possible values: local and container
34-
KIND_KUBE_CONFIG=$${HOME}/.kube/kind/config## The location of the kind kubeconfig
3534
OUT_DIR ?= build/out## The folder where the binary will be stored
3635
GOARCH ?= amd64## The architecture of the image and/or binary. For example: amd64 or arm64
3736
GOOS ?= linux## The OS of the image and/or binary. For example: linux or darwin
@@ -149,7 +148,6 @@ deps: ## Add missing and remove unused modules, verify deps and download them to
149148
create-kind-cluster: ## Create a kind cluster
150149
$(eval KIND_IMAGE=$(shell grep -m1 'FROM kindest/node' <$(SELF_DIR)tests/Dockerfile | awk -F'[ ]' '{print $$2}'))
151150
kind create cluster --image $(KIND_IMAGE)
152-
kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG)
153151

154152
.PHONY: delete-kind-cluster
155153
delete-kind-cluster: ## Delete kind cluster

0 commit comments

Comments
 (0)