|
| 1 | +suite: ingress-nginx requires an ingress-nginx worker pool (Phase 2 guard) |
| 2 | + |
| 3 | +# The ingress-nginx controller DaemonSet pins itself (nodeSelector) to nodes |
| 4 | +# labelled node-role.kubernetes.io/ingress-nginx. Since Phase 2 moved worker |
| 5 | +# pools into the kubernetes-nodes chart, that label comes only from a |
| 6 | +# KubernetesNodes pool with roles: [ingress-nginx]. The chart fails render when |
| 7 | +# this cluster already has pools but none carries the ingress role, so the |
| 8 | +# operator gets an actionable error instead of a DaemonSet that schedules |
| 9 | +# nothing. The lookup is empty during plain render (helm template / lint / |
| 10 | +# unittest without a mocked provider), so the guard never fires there. |
| 11 | + |
| 12 | +templates: |
| 13 | + - templates/helmreleases/ingress-nginx.yaml |
| 14 | + |
| 15 | +values: |
| 16 | + - values/common.yaml |
| 17 | + |
| 18 | +release: |
| 19 | + name: test-k8s |
| 20 | + namespace: tenant-test |
| 21 | + |
| 22 | +tests: |
| 23 | + - it: renders the ingress-nginx HelmRelease when enabled and no pools are visible (empty lookup, no fail) |
| 24 | + set: |
| 25 | + addons.ingressNginx.enabled: true |
| 26 | + asserts: |
| 27 | + - hasDocuments: |
| 28 | + count: 1 |
| 29 | + - isKind: |
| 30 | + of: HelmRelease |
| 31 | + - equal: |
| 32 | + path: metadata.name |
| 33 | + value: test-k8s-ingress-nginx |
| 34 | + |
| 35 | + - it: does not render when the addon is disabled |
| 36 | + set: |
| 37 | + addons.ingressNginx.enabled: false |
| 38 | + asserts: |
| 39 | + - hasDocuments: |
| 40 | + count: 0 |
| 41 | + |
| 42 | + - it: fails when a worker pool exists for this cluster but none has the ingress-nginx role |
| 43 | + set: |
| 44 | + addons.ingressNginx.enabled: true |
| 45 | + kubernetesProvider: |
| 46 | + scheme: |
| 47 | + "cluster.x-k8s.io/v1beta1/MachineDeployment": |
| 48 | + gvr: |
| 49 | + group: cluster.x-k8s.io |
| 50 | + version: v1beta1 |
| 51 | + resource: machinedeployments |
| 52 | + namespaced: true |
| 53 | + objects: |
| 54 | + - apiVersion: cluster.x-k8s.io/v1beta1 |
| 55 | + kind: MachineDeployment |
| 56 | + metadata: |
| 57 | + name: test-k8s-md0 |
| 58 | + namespace: tenant-test |
| 59 | + spec: |
| 60 | + clusterName: test-k8s |
| 61 | + template: |
| 62 | + metadata: |
| 63 | + labels: |
| 64 | + node-role.kubernetes.io/worker: "" |
| 65 | + asserts: |
| 66 | + - failedTemplate: |
| 67 | + errorPattern: "no KubernetesNodes pool for this cluster has roles" |
| 68 | + |
| 69 | + - it: renders when a worker pool with the ingress-nginx role exists |
| 70 | + set: |
| 71 | + addons.ingressNginx.enabled: true |
| 72 | + kubernetesProvider: |
| 73 | + scheme: |
| 74 | + "cluster.x-k8s.io/v1beta1/MachineDeployment": |
| 75 | + gvr: |
| 76 | + group: cluster.x-k8s.io |
| 77 | + version: v1beta1 |
| 78 | + resource: machinedeployments |
| 79 | + namespaced: true |
| 80 | + objects: |
| 81 | + - apiVersion: cluster.x-k8s.io/v1beta1 |
| 82 | + kind: MachineDeployment |
| 83 | + metadata: |
| 84 | + name: test-k8s-ingress |
| 85 | + namespace: tenant-test |
| 86 | + spec: |
| 87 | + clusterName: test-k8s |
| 88 | + template: |
| 89 | + metadata: |
| 90 | + labels: |
| 91 | + node-role.kubernetes.io/ingress-nginx: "" |
| 92 | + asserts: |
| 93 | + - hasDocuments: |
| 94 | + count: 1 |
| 95 | + - isKind: |
| 96 | + of: HelmRelease |
0 commit comments