I've got this ingress.yaml base configuration:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
labels:
sia: aza
app: asap-ingress-internal
name: asap-ingress-internal
annotations:
kubernetes.io/ingress.class: "nginx-external"
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
- host: the-host-value
http:
paths:
- path: /asap-srv-template/(.*)
backend:
serviceName: asap-srv-template
servicePort: 8080
And want to replace the spoec.rules.host value only (and keep all http.paths as is.
So I create a env-var.yaml like this :
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: asap-ingress-internal
spec:
rules:
- host: the.real.hostname
But the result is the following:
$ kustomize build
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx-external
nginx.ingress.kubernetes.io/use-regex: "true"
labels:
app: asap-ingress-internal
env: dev
sia: aza
name: asap-ingress-internal
namespace: aza-72461-dev
spec:
rules:
- host: the.real.hostname
I have lost all http.paths configuration and I can't find out how to do.
I tried with patches: or patchesStrategicMerge in kustomization.yaml but the result is always the same.
Any help would be greatly appreciated
An overlay is a directory with a kustomization. yaml that refers to other kustomization directories as its bases . A base has no knowledge of an overlay and can be used in multiple overlays. An overlay may have multiple bases and it composes all resources from bases and may also have customization on top of them.
Open a new terminal and run kustomize -h to verify: > kustomize -h Manages declarative configuration of Kubernetes. See https://sigs.k8s.io/kustomize Usage: kustomize [command] Available Commands: build Build a kustomization target from a directory or URL.
Kustomize is a command-line configuration manager for Kubernetes objects. Integrated with kubectl since 1.14, it allows you to make declarative changes to your configurations without touching a template.
A new pathType field that can specify how Ingress paths should be matched. A new IngressClass resource that can specify how Ingresses should be implemented by controllers. Support for wildcards in hostnames.
As with all other Kubernetes resources, an Ingress needs apiVersion, kind, and metadata fields. The name of an Ingress object must be a valid DNS subdomain name . For general information about working with config files, see deploying applications , configuring containers , managing resources .
Ingress resource only supports rules for directing HTTP (S) traffic. An optional host. In this example, no host is specified, so the rule applies to all inbound HTTP traffic through the IP address specified. If a host is provided (for example, foo.bar.com), the rules apply to that host.
Currently the Ingress only supports a single TLS port, 443, and assumes TLS termination. If the TLS configuration section in an Ingress specifies different hosts, they will be multiplexed on the same port according to the hostname specified through the SNI TLS extension (provided the Ingress controller supports SNI).
Ingress rules. Each HTTP rule contains the following information: An optional host. In this example, no host is specified, so the rule applies to all inbound HTTP traffic through the IP address specified. If a host is provided (for example, foo.bar.com), the rules apply to that host.
You can use a json patch for this, below is an example.
Here is an example kustomization.yaml
. It will call out a patch in the patches
section:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/app1
patches:
- target:
kind: Ingress
name: my-ingress
path: ingress-patch.json
Here would be an example ingress-patch.json
:
[
{
"op": "replace",
"path": "/spec/rules/0/host",
"value": "the.real.hostname"
}
]
Another option is to do inline patch. It's the same approach mroma offered, but without the file. I find it simpler.
# kustomization.yaml
resources:
- ingress.yaml
patches:
- target:
kind: Ingress
name: asap-ingress-internal
patch: |-
- op: replace
path: /spec/rules/0/host
value: the.real.hostname
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With