Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.

Commit 74ba882

Browse files
authored
Merge branch 'master' into dependabot/go_modules/github.com/go-logr/logr-1.2.2
2 parents d610e31 + e29cca1 commit 74ba882

23 files changed

+246
-135
lines changed

.github/workflows/ci.yml

+33-51
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- 'docs/**'
99
- 'examples/**'
1010
- '**.md'
11+
tags:
12+
- 'v[0-9]+.[0-9]+.[0-9]+'
1113
pull_request:
1214
branches:
1315
- master
@@ -19,13 +21,14 @@ on:
1921
- 'docs/**'
2022
- 'examples/**'
2123
- '**.md'
22-
create:
23-
tags:
24-
- 'v[0-9]+.[0-9]+.[0-9]+*'
2524

2625
env:
2726
DOCKER_BUILDKIT: 1
2827

28+
concurrency:
29+
group: ${{ github.ref_name }}-ci
30+
cancel-in-progress: true
31+
2932
jobs:
3033

3134
vars:
@@ -34,21 +37,15 @@ jobs:
3437
outputs:
3538
sha_short: ${{ steps.vars.outputs.sha }}
3639
go_version: ${{ steps.vars.outputs.go_version }}
37-
git_tag: ${{ steps.vars.outputs.git_tag }}
3840
repo_name: ${{ steps.vars.outputs.repo }}
3941
steps:
40-
- name: Cancel Previous Runs
41-
uses: styfle/[email protected]
42-
with:
43-
access_token: ${{ secrets.GITHUB_TOKEN }}
4442
- name: Checkout Repository
4543
uses: actions/checkout@v2
4644
- name: Output Variables
4745
id: vars
4846
run: |
4947
echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
5048
echo "::set-output name=go_version::$(grep "go 1." go.mod | cut -d " " -f 2)"
51-
echo "::set-output name=git_tag::$(echo ${GITHUB_REF/refs\/tags\//} | tr -d v)"
5249
echo "::set-output name=repo::$(echo ${GITHUB_REPOSITORY} | cut -d '/' -f 2)"
5350
5451
binary:
@@ -96,23 +93,43 @@ jobs:
9693
with:
9794
path: ${{ github.workspace }}/bin/manager
9895
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
96+
- name: DockerHub Login
97+
uses: docker/login-action@v1
98+
with:
99+
username: ${{ secrets.DOCKER_USERNAME }}
100+
password: ${{ secrets.DOCKER_PASSWORD }}
101+
if: github.event_name != 'pull_request'
99102
- name: Docker Buildx
100103
uses: docker/setup-buildx-action@v1
104+
- name: Docker meta
105+
id: meta
106+
uses: docker/metadata-action@v3
107+
with:
108+
images: |
109+
nginx/nginx-ingress-operator
110+
tags: |
111+
type=edge
112+
type=ref,event=pr
113+
type=semver,pattern={{version}}
114+
labels: |
115+
org.opencontainers.image.documentation=https://docs.nginx.com/nginx-ingress-controller
116+
org.opencontainers.image.vendor=NGINX Inc <[email protected]>
101117
- name: Build Image
102118
uses: docker/build-push-action@v2
103119
with:
104120
context: '.'
105121
cache-from: type=gha
106122
cache-to: type=gha,mode=max
107-
tags: nginx/nginx-ingress-operator:${{ github.sha }}
108-
push: false
123+
tags: ${{ steps.meta.outputs.tags }}
124+
labels: ${{ steps.meta.outputs.labels }}
125+
load: ${{ github.event_name == 'pull_request' }}
126+
push: ${{ github.event_name != 'pull_request' }}
109127
pull: true
110-
load: true
111128
- name: Run Trivy vulnerability scanner
112-
uses: aquasecurity/[email protected].0
129+
uses: aquasecurity/[email protected].1
113130
continue-on-error: true
114131
with:
115-
image-ref: nginx/nginx-ingress-operator:${{ github.sha }}
132+
image-ref: nginx/nginx-ingress-operator:${{ steps.meta.outputs.version }}
116133
format: 'template'
117134
template: '@/contrib/sarif.tpl'
118135
output: 'trivy-results.sarif'
@@ -121,7 +138,7 @@ jobs:
121138
uses: github/codeql-action/upload-sarif@v1
122139
continue-on-error: true
123140
with:
124-
sarif_file: 'trivy-result.sarif'
141+
sarif_file: 'trivy-results.sarif'
125142
- name: Upload Scan Results
126143
uses: actions/upload-artifact@v2
127144
continue-on-error: true
@@ -130,46 +147,11 @@ jobs:
130147
path: 'trivy-results.sarif'
131148
if: always()
132149

133-
release-docker:
134-
name: Release Image
135-
runs-on: ubuntu-20.04
136-
needs: [vars, build, unit-tests]
137-
if:
138-
github.repository == 'nginxinc/nginx-ingress-operator' &&
139-
github.event_name == 'create' &&
140-
contains(github.ref, 'refs/tags/')
141-
steps:
142-
- name: Checkout Repository
143-
uses: actions/checkout@v2
144-
- name: Fetch Cached Artifacts
145-
uses: actions/cache@v2
146-
with:
147-
path: ${{ github.workspace }}/build/_output/bin/nginx-ingress-operator
148-
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
149-
- name: Docker Buildx
150-
uses: docker/setup-buildx-action@v1
151-
- name: DockerHub Login
152-
uses: docker/login-action@v1
153-
with:
154-
username: ${{ secrets.DOCKER_USERNAME }}
155-
password: ${{ secrets.DOCKER_PASSWORD }}
156-
- name: Push to Dockerhub
157-
uses: docker/build-push-action@v2
158-
with:
159-
file: Dockerfile
160-
context: '.'
161-
cache-from: type=gha
162-
cache-to: type=gha,mode=max
163-
tags: |
164-
nginx/nginx-ingress-operator:latest
165-
nginx/nginx-ingress-operator:${{ needs.vars.outputs.git_tag }}
166-
push: true
167-
pull: true
168150

169151
notify:
170152
name: Notify
171153
runs-on: ubuntu-20.04
172-
needs: [vars, release-docker]
154+
needs: [vars, build]
173155
if: always() && github.ref == 'refs/heads/master'
174156
steps:
175157
- name: Workflow Status

.github/workflows/codeql-analysis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
schedule:
1010
- cron: '45 2 * * 4'
1111

12+
concurrency:
13+
group: ${{ github.ref_name }}-codeql
14+
cancel-in-progress: true
15+
1216
jobs:
1317
analyze:
1418
name: Analyze
@@ -23,10 +27,6 @@ jobs:
2327
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
2428

2529
steps:
26-
- name: Cancel Previous Runs
27-
uses: styfle/[email protected]
28-
with:
29-
access_token: ${{ secrets.GITHUB_TOKEN }}
3030
- name: Checkout repository
3131
uses: actions/checkout@v2
3232

.github/workflows/dockerhub-description.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ on:
66
paths:
77
- README.md
88
- .github/workflows/dockerhub-description.yml
9+
10+
concurrency:
11+
group: ${{ github.ref_name }}-dockerhub-description
12+
cancel-in-progress: true
13+
914
jobs:
1015
dockerHubDescription:
1116
runs-on: ubuntu-20.04
1217
steps:
13-
- name: Cancel Previous Runs
14-
uses: styfle/[email protected]
15-
with:
16-
access_token: ${{ secrets.GITHUB_TOKEN }}
1718
- uses: actions/checkout@v2
1819

1920
- name: Modify readme for DockerHub

.github/workflows/fossa.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ on:
88
- '**.md'
99
- 'LICENSE'
1010

11+
concurrency:
12+
group: ${{ github.ref_name }}-fossa
13+
cancel-in-progress: true
14+
1115
jobs:
1216

1317
scan:
1418
name: Fossa
1519
runs-on: ubuntu-20.04
1620
steps:
17-
- name: Cancel Previous Runs
18-
uses: styfle/[email protected]
19-
with:
20-
access_token: ${{ secrets.GITHUB_TOKEN }}
2121
- name: Checkout Repository
2222
uses: actions/checkout@v2
2323
- name: Scan

.github/workflows/lint.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ defaults:
1717
run:
1818
shell: bash
1919

20+
concurrency:
21+
group: ${{ github.ref_name }}-lint
22+
cancel-in-progress: true
23+
2024
env:
2125
GOLANGCI_TIMEOUT: 10m0s
2226

@@ -26,10 +30,6 @@ jobs:
2630
name: Lint
2731
runs-on: ubuntu-20.04
2832
steps:
29-
- name: Cancel Previous Runs
30-
uses: styfle/[email protected]
31-
with:
32-
access_token: ${{ secrets.GITHUB_TOKEN }}
3333
- name: Checkout Repository
3434
uses: actions/checkout@v2
3535
- name: Lint Code

Dockerfile

+13-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ COPY controllers/ controllers/
1818
# Build
1919
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -a -o manager main.go
2020

21-
# Use distroless as minimal base image to package the manager binary
22-
# Refer to https://github.com/GoogleContainerTools/distroless for more details
23-
FROM gcr.io/distroless/static:nonroot
21+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
22+
ARG VERSION
2423
WORKDIR /
25-
COPY --from=builder --chown=65532:65532 /workspace/manager .
24+
COPY --from=builder /workspace/manager .
2625
COPY config/crd/kic ./config/crd/kic
27-
USER 65532:65532
26+
COPY LICENSE /licenses/
27+
28+
LABEL name="NGINX Ingress Operator" \
29+
vendor="NGINX Inc <[email protected]" \
30+
version="v${VERSION}" \
31+
release="1" \
32+
summary="The NGINX Ingress Operator is a Kubernetes/OpenShift component which deploys and manages one or more NGINX/NGINX Plus Ingress Controllers" \
33+
description="The NGINX Ingress Operator is a Kubernetes/OpenShift component which deploys and manages one or more NGINX/NGINX Plus Ingress Controllers"
2834

2935
ENTRYPOINT ["/manager"]
36+
37+
USER 1001

Makefile

-7
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
4141
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
4242
ENVTEST_K8S_VERSION = 1.22
4343

44-
# Change DOCKERFILE tp openshift.Dockerfile to build Openshift image
4544
DOCKERFILE ?= Dockerfile
46-
RH_RBAC_IMAGE ?= registry.redhat.io/openshift4/ose-kube-rbac-proxy:v4.7
4745

4846
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
4947
ifeq (,$(shell go env GOBIN))
@@ -125,11 +123,6 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
125123
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
126124
$(KUSTOMIZE) build config/default | kubectl apply -f -
127125

128-
openshift-deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
129-
VAL="${RH_RBAC_IMAGE}" yq e '.spec.template.spec.containers[0].image = strenv(VAL)' -i config/default/manager_auth_proxy_patch.yaml
130-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
131-
$(KUSTOMIZE) build config/default | kubectl apply -f -
132-
133126
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
134127
$(KUSTOMIZE) build config/default | kubectl delete -f -
135128

api/v1alpha1/nginxingresscontroller_types.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ type NginxIngressControllerSpec struct {
154154
// +nullable
155155
// +operator-sdk:csv:customresourcedefinitions:type=spec
156156
AppProtect *AppProtect `json:"appProtect"`
157+
// App Protect Dos support configuration.
158+
// Requires enableCRDs set to true.
159+
// +kubebuilder:validation:Optional
160+
// +nullable
161+
// +operator-sdk:csv:customresourcedefinitions:type=spec
162+
AppProtectDos *AppProtectDos `json:"appProtectDos"`
157163
// Timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start.
158164
// +kubebuilder:validation:Optional
159165
// +operator-sdk:csv:customresourcedefinitions:type=spec
@@ -268,15 +274,32 @@ type Prometheus struct {
268274

269275
// AppProtect support configuration.
270276
type AppProtect struct {
271-
// Enable App Protect.
277+
// Enable App Protect WAF.
272278
Enable bool `json:"enable"`
273279
}
274280

281+
// AppProtectDos support configuration.
282+
type AppProtectDos struct {
283+
// Enable App Protect Dos.
284+
Enable bool `json:"enable"`
285+
// Enable debug mode.
286+
Debug bool `json:"debug"`
287+
// Max number of ADMD instances.
288+
MaxDaemons int `json:"maxDaemons"`
289+
// Max number of nginx processes to support.
290+
MaxWorkers int `json:"maxWorkers"`
291+
// RAM memory size in MB.
292+
Memory int `json:"memory"`
293+
}
294+
275295
// Service defines the Service for the Ingress Controller.
276296
type Service struct {
277297
// Specifies extra labels of the service.
278298
// +kubebuilder:validation:Optional
279299
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
300+
// Specifies extra annotations of the service.
301+
// +kubebuilder:validation:Optional
302+
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty"`
280303
}
281304

282305
func init() {

api/v1alpha1/zz_generated.deepcopy.go

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/k8s.nginx.org_nginxingresscontrollers.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ spec:
246246
type: string
247247
description: Specifies extra labels of the service.
248248
type: object
249+
extraAnnotations:
250+
additionalProperties:
251+
type: string
252+
description: Specifies extra annotations of the service.
253+
type: object
249254
type: object
250255
serviceType:
251256
description: 'The type of the Service for the Ingress Controller.

0 commit comments

Comments
 (0)