Skip to content

Commit 7ce6cc8

Browse files
authored
feat: add namespace overrides (#10539)
* feat: add namespace overrides * add value in readme * fix: readme description * fix: description in value * fix: set max length and trim last "-"
1 parent b97bc81 commit 7ce6cc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+72
-57
lines changed

charts/ingress-nginx/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ As of version `1.26.0` of this chart, by simply not providing any clusterIP valu
498498
| defaultBackend.updateStrategy | object | `{}` | The update strategy to apply to the Deployment or DaemonSet # |
499499
| dhParam | string | `""` | A base64-encoded Diffie-Hellman parameter. This can be generated with: `openssl dhparam 4096 2> /dev/null | base64` # Ref: https://github.com/kubernetes/ingress-nginx/tree/main/docs/examples/customization/ssl-dh-param |
500500
| imagePullSecrets | list | `[]` | Optional array of imagePullSecrets containing private registry credentials # Ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ |
501+
| namespaceOverride | string | `""` | Override the deployment namespace; defaults to .Release.Namespace |
501502
| podSecurityPolicy.enabled | bool | `false` | |
502503
| portNamePrefix | string | `""` | Prefix for TCP and UDP ports names in ingress controller service # Some cloud providers, like Yandex Cloud may have a requirements for a port name regex to support cloud load balancer integration |
503504
| rbac.create | bool | `true` | |

charts/ingress-nginx/templates/NOTES.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ Get the application URL by running these commands:
66
{{- if (not (empty .Values.controller.service.nodePorts.http)) }}
77
export HTTP_NODE_PORT={{ .Values.controller.service.nodePorts.http }}
88
{{- else }}
9-
export HTTP_NODE_PORT=$(kubectl --namespace {{ .Release.Namespace }} get services -o jsonpath="{.spec.ports[0].nodePort}" {{ include "ingress-nginx.controller.fullname" . }})
9+
export HTTP_NODE_PORT=$(kubectl --namespace {{ include "ingress-nginx.namespace" . }} get services -o jsonpath="{.spec.ports[0].nodePort}" {{ include "ingress-nginx.controller.fullname" . }})
1010
{{- end }}
1111
{{- if (not (empty .Values.controller.service.nodePorts.https)) }}
1212
export HTTPS_NODE_PORT={{ .Values.controller.service.nodePorts.https }}
1313
{{- else }}
14-
export HTTPS_NODE_PORT=$(kubectl --namespace {{ .Release.Namespace }} get services -o jsonpath="{.spec.ports[1].nodePort}" {{ include "ingress-nginx.controller.fullname" . }})
14+
export HTTPS_NODE_PORT=$(kubectl --namespace {{ include "ingress-nginx.namespace" . }} get services -o jsonpath="{.spec.ports[1].nodePort}" {{ include "ingress-nginx.controller.fullname" . }})
1515
{{- end }}
16-
export NODE_IP=$(kubectl --namespace {{ .Release.Namespace }} get nodes -o jsonpath="{.items[0].status.addresses[1].address}")
16+
export NODE_IP=$(kubectl --namespace {{ include "ingress-nginx.namespace" . }} get nodes -o jsonpath="{.items[0].status.addresses[1].address}")
1717

1818
echo "Visit http://$NODE_IP:$HTTP_NODE_PORT to access your application via HTTP."
1919
echo "Visit https://$NODE_IP:$HTTPS_NODE_PORT to access your application via HTTPS."
2020
{{- else if contains "LoadBalancer" .Values.controller.service.type }}
2121
It may take a few minutes for the LoadBalancer IP to be available.
22-
You can watch the status by running 'kubectl --namespace {{ .Release.Namespace }} get services -o wide -w {{ include "ingress-nginx.controller.fullname" . }}'
22+
You can watch the status by running 'kubectl --namespace {{ include "ingress-nginx.namespace" . }} get services -o wide -w {{ include "ingress-nginx.controller.fullname" . }}'
2323
{{- else if contains "ClusterIP" .Values.controller.service.type }}
2424
Get the application URL by running these commands:
25-
export POD_NAME=$(kubectl --namespace {{ .Release.Namespace }} get pods -o jsonpath="{.items[0].metadata.name}" -l "app={{ template "ingress-nginx.name" . }},component={{ .Values.controller.name }},release={{ .Release.Name }}")
26-
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
25+
export POD_NAME=$(kubectl --namespace {{ include "ingress-nginx.namespace" . }} get pods -o jsonpath="{.items[0].metadata.name}" -l "app={{ template "ingress-nginx.name" . }},component={{ .Values.controller.name }},release={{ .Release.Name }}")
26+
kubectl --namespace {{ include "ingress-nginx.namespace" . }} port-forward $POD_NAME 8080:80
2727
echo "Visit http://127.0.0.1:8080 to access your application."
2828
{{- end }}
2929

charts/ingress-nginx/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
3030
{{- end -}}
3131
{{- end -}}
3232

33+
{{/*
34+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
35+
*/}}
36+
{{- define "ingress-nginx.namespace" -}}
37+
{{- if .Values.namespaceOverride -}}
38+
{{- .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
39+
{{- else -}}
40+
{{- .Release.Namespace -}}
41+
{{- end -}}
42+
{{- end -}}
43+
3344

3445
{{/*
3546
Container SecurityContext.

charts/ingress-nginx/templates/admission-webhooks/cert-manager.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apiVersion: cert-manager.io/v1
66
kind: Issuer
77
metadata:
88
name: {{ include "ingress-nginx.fullname" . }}-self-signed-issuer
9-
namespace: {{ .Release.Namespace }}
9+
namespace: {{ include "ingress-nginx.namespace" . }}
1010
spec:
1111
selfSigned: {}
1212
---
@@ -15,7 +15,7 @@ apiVersion: cert-manager.io/v1
1515
kind: Certificate
1616
metadata:
1717
name: {{ include "ingress-nginx.fullname" . }}-root-cert
18-
namespace: {{ .Release.Namespace }}
18+
namespace: {{ include "ingress-nginx.namespace" . }}
1919
spec:
2020
secretName: {{ include "ingress-nginx.fullname" . }}-root-cert
2121
duration: {{ .Values.controller.admissionWebhooks.certManager.rootCert.duration | default "43800h0m0s" | quote }}
@@ -32,7 +32,7 @@ apiVersion: cert-manager.io/v1
3232
kind: Issuer
3333
metadata:
3434
name: {{ include "ingress-nginx.fullname" . }}-root-issuer
35-
namespace: {{ .Release.Namespace }}
35+
namespace: {{ include "ingress-nginx.namespace" . }}
3636
spec:
3737
ca:
3838
secretName: {{ include "ingress-nginx.fullname" . }}-root-cert
@@ -43,7 +43,7 @@ apiVersion: cert-manager.io/v1
4343
kind: Certificate
4444
metadata:
4545
name: {{ include "ingress-nginx.fullname" . }}-admission
46-
namespace: {{ .Release.Namespace }}
46+
namespace: {{ include "ingress-nginx.namespace" . }}
4747
spec:
4848
secretName: {{ include "ingress-nginx.fullname" . }}-admission
4949
duration: {{ .Values.controller.admissionWebhooks.certManager.admissionCert.duration | default "8760h0m0s" | quote }}
@@ -55,8 +55,8 @@ spec:
5555
{{- end }}
5656
dnsNames:
5757
- {{ include "ingress-nginx.controller.fullname" . }}-admission
58-
- {{ include "ingress-nginx.controller.fullname" . }}-admission.{{ .Release.Namespace }}
59-
- {{ include "ingress-nginx.controller.fullname" . }}-admission.{{ .Release.Namespace }}.svc
58+
- {{ include "ingress-nginx.controller.fullname" . }}-admission.{{ include "ingress-nginx.namespace" . }}
59+
- {{ include "ingress-nginx.controller.fullname" . }}-admission.{{ include "ingress-nginx.namespace" . }}.svc
6060
subject:
6161
organizations:
6262
- ingress-nginx-admission

charts/ingress-nginx/templates/admission-webhooks/job-patch/clusterrolebinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ roleRef:
1919
subjects:
2020
- kind: ServiceAccount
2121
name: {{ include "ingress-nginx.fullname" . }}-admission
22-
namespace: {{ .Release.Namespace | quote }}
22+
namespace: {{ (include "ingress-nginx.namespace" .) | quote }}
2323
{{- end }}

charts/ingress-nginx/templates/admission-webhooks/job-patch/job-createSecret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: batch/v1
33
kind: Job
44
metadata:
55
name: {{ include "ingress-nginx.fullname" . }}-admission-create
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "ingress-nginx.namespace" . }}
77
annotations:
88
"helm.sh/hook": pre-install,pre-upgrade
99
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded

charts/ingress-nginx/templates/admission-webhooks/job-patch/job-patchWebhook.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: batch/v1
33
kind: Job
44
metadata:
55
name: {{ include "ingress-nginx.fullname" . }}-admission-patch
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "ingress-nginx.namespace" . }}
77
annotations:
88
"helm.sh/hook": post-install,post-upgrade
99
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded

charts/ingress-nginx/templates/admission-webhooks/job-patch/networkpolicy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: networking.k8s.io/v1
33
kind: NetworkPolicy
44
metadata:
55
name: {{ include "ingress-nginx.fullname" . }}-admission
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "ingress-nginx.namespace" . }}
77
annotations:
88
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade
99
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded

charts/ingress-nginx/templates/admission-webhooks/job-patch/role.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: Role
44
metadata:
5-
name: {{ include "ingress-nginx.fullname" . }}-admission
6-
namespace: {{ .Release.Namespace }}
5+
name: {{ include "ingress-nginx.fullname" . }}-admission
6+
namespace: {{ include "ingress-nginx.namespace" . }}
77
annotations:
88
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade
99
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded

charts/ingress-nginx/templates/admission-webhooks/job-patch/rolebinding.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
33
kind: RoleBinding
44
metadata:
55
name: {{ include "ingress-nginx.fullname" . }}-admission
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "ingress-nginx.namespace" . }}
77
annotations:
88
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade
99
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
@@ -20,5 +20,5 @@ roleRef:
2020
subjects:
2121
- kind: ServiceAccount
2222
name: {{ include "ingress-nginx.fullname" . }}-admission
23-
namespace: {{ .Release.Namespace | quote }}
23+
namespace: {{ (include "ingress-nginx.namespace" .) | quote }}
2424
{{- end }}

0 commit comments

Comments
 (0)