Created
November 25, 2022 18:30
-
-
Save gazab/bb31f879c927394d3f3f88d9272b7652 to your computer and use it in GitHub Desktop.
Dynamic Kubernetes Ingress host with Kustomize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.k8s.io/v1 | |
kind: Ingress | |
metadata: | |
name: ingress-resource | |
annotations: | |
kubernetes.io/ingress.class: "nginx" | |
spec: | |
rules: | |
- host: foo.example.com | |
http: | |
paths: | |
- path: / | |
pathType: Prefix | |
backend: | |
service: | |
name: webapp-service | |
port: | |
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: kustomize.config.k8s.io/v1beta1 | |
kind: Kustomization | |
commonLabels: | |
pull-request: this_will_be_the_new_url | |
resources: | |
- ingress.yaml | |
replacements: | |
- source: | |
kind: Ingress | |
fieldPath: metadata.labels.pull-request | |
targets: | |
- select: | |
kind: Ingress | |
fieldPaths: | |
- spec.rules.0.host | |
options: | |
delimiter: "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❯ kubectl kustomize . | |
apiVersion: networking.k8s.io/v1 | |
kind: Ingress | |
metadata: | |
annotations: | |
kubernetes.io/ingress.class: nginx | |
labels: | |
pull-request: this_will_be_the_new_url | |
name: ingress-resource | |
spec: | |
rules: | |
- host: this_will_be_the_new_url.example.com | |
http: | |
paths: | |
- backend: | |
service: | |
name: webapp-service | |
port: | |
number: 80 | |
path: / | |
pathType: Prefix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment