Skip to content

Commit

Permalink
Fix IngressClass logic for newer releases (#7341)
Browse files Browse the repository at this point in the history
* Fix IngressClass logic for newer releases

Signed-off-by: Ricardo Pchevuzinske Katz <[email protected]>

* Change e2e tests for the new IngressClass presence

* Fix chart and admission tests

Signed-off-by: Ricardo Pchevuzinske Katz <[email protected]>

* Fix helm chart test

Signed-off-by: Ricardo Pchevuzinske Katz <[email protected]>

* Fix reviews

* Remove ingressclass code from admission
  • Loading branch information
rikatz authored Jul 28, 2021
1 parent 0d57e87 commit cef147a
Show file tree
Hide file tree
Showing 68 changed files with 1,406 additions and 593 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ jobs:
name: Build
runs-on: ubuntu-latest
needs: changes
if: |
(needs.changes.outputs.go == 'true')

steps:

Expand Down Expand Up @@ -116,13 +114,19 @@ jobs:
runs-on: ubuntu-latest
needs:
- changes
- build
if: |
(needs.changes.outputs.charts == 'true')
steps:

- name: Checkout
uses: actions/checkout@v2

- name: cache
uses: actions/download-artifact@v2
with:
name: docker.tar.gz

- name: Lint
run: |
Expand All @@ -139,11 +143,22 @@ jobs:
with:
version: v0.11.1
image: kindest/node:v1.21.1

- uses: geekyeggo/delete-artifact@v1
with:
name: docker.tar.gz
failOnError: false

- name: Load images from cache
run: |
echo "loading docker images..."
pigz -dc docker.tar.gz | docker load
- name: Test
env:
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-chart-tests
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-customconfig-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
kind: DaemonSet
admissionWebhooks:
enabled: false
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-customnodeport-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false

Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-headers-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
addHeaders:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-internal-lb-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-nodeport-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-podannotations-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
metrics:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-tcp-udp-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/daemonset-tcp-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deamonset-default-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deamonset-metrics-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
metrics:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deamonset-psp-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deamonset-webhook-and-psp-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: true
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deamonset-webhook-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: true
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-autoscaling-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
autoscaling:
enabled: true
admissionWebhooks:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-customconfig-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
config:
use-proxy-protocol: "true"
admissionWebhooks:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-customnodeport-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-default-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Left blank to test default values
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
service:
type: ClusterIP
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-headers-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
addHeaders:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-internal-lb-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-metrics-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
metrics:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-nodeport-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-podannotations-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
metrics:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-psp-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
service:
type: ClusterIP

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-tcp-udp-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-tcp-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
service:
type: ClusterIP

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: true
service:
Expand Down
4 changes: 4 additions & 0 deletions charts/ingress-nginx/ci/deployment-webhook-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: true
service:
Expand Down
8 changes: 3 additions & 5 deletions charts/ingress-nginx/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ rules:
- list
- watch
- apiGroups:
- extensions
- "networking.k8s.io" # k8s 1.14+
- networking.k8s.io
resources:
- ingresses
verbs:
Expand All @@ -58,14 +57,13 @@ rules:
- create
- patch
- apiGroups:
- extensions
- "networking.k8s.io" # k8s 1.14+
- networking.k8s.io
resources:
- ingresses/status
verbs:
- update
- apiGroups:
- "networking.k8s.io" # k8s 1.14+
- networking.k8s.io
resources:
- ingressclasses
verbs:
Expand Down
2 changes: 1 addition & 1 deletion charts/ingress-nginx/templates/controller-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spec:
- --publish-service={{ template "ingress-nginx.controller.publishServicePath" . }}
{{- end }}
- --election-id={{ .Values.controller.electionID }}
- --ingress-class={{ .Values.controller.ingressClass }}
- --controller-class={{ .Values.controller.ingressClassResource.controllerValue }}
- --configmap={{ default "$(POD_NAMESPACE)" .Values.controller.configMapNamespace }}/{{ include "ingress-nginx.controller.fullname" . }}
{{- if .Values.tcp }}
- --tcp-services-configmap={{ default "$(POD_NAMESPACE)" .Values.controller.tcp.configMapNamespace }}/{{ include "ingress-nginx.fullname" . }}-tcp
Expand Down
2 changes: 1 addition & 1 deletion charts/ingress-nginx/templates/controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ spec:
- --publish-service={{ template "ingress-nginx.controller.publishServicePath" . }}
{{- end }}
- --election-id={{ .Values.controller.electionID }}
- --ingress-class={{ .Values.controller.ingressClass }}
- --controller-class={{ .Values.controller.ingressClassResource.controllerValue }}
- --configmap={{ default "$(POD_NAMESPACE)" .Values.controller.configMapNamespace }}/{{ include "ingress-nginx.controller.fullname" . }}
{{- if .Values.tcp }}
- --tcp-services-configmap={{ default "$(POD_NAMESPACE)" .Values.controller.tcp.configMapNamespace }}/{{ include "ingress-nginx.fullname" . }}-tcp
Expand Down
12 changes: 5 additions & 7 deletions charts/ingress-nginx/templates/controller-ingressclass.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{{- if and (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) (.Values.controller.ingressClassResource.enabled) -}}
{{- if and (semverCompare "=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
{{- if .Values.controller.ingressClassResource.enabled -}}
# We don't support namespaced ingressClass yet
# So a ClusterRole and a ClusterRoleBinding is required
apiVersion: networking.k8s.io/v1
{{- end }}
kind: IngressClass
metadata:
labels:
Expand All @@ -12,12 +10,12 @@ metadata:
{{- with .Values.controller.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Values.controller.ingressClass }}
name: {{ .Values.controller.ingressClassResource.name }}
{{- if .Values.controller.ingressClassResource.default }}
annotations:
ingressclass.kubernetes.io/is-default-class: "true"
{{- end }}
spec:
controller: k8s.io/ingress-nginx
controller: {{ .Values.controller.ingressClassResource.controllerValue }}
{{ template "ingressClass.parameters" . }}
{{- end }}
Loading

0 comments on commit cef147a

Please sign in to comment.