kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
11.05k stars 2.25k forks source link

Inject Host into Ingress #347

Open lswith opened 6 years ago

lswith commented 6 years ago

I think a reasonably common use case is to swap an ingress's host value:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: helloworld
spec:
  rules:
# This value should be editable
  - host: example.com
    http:
      paths:
      - backend:
          serviceName: helloworld
          servicePort: 80

Can we get a feature to set this?

cprivitere commented 1 year ago

/remove-lifecycle stale

k8s-triage-robot commented 1 year ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

kragniz commented 1 year ago

/remove-lifecycle stale

SGStino commented 1 year ago

I guess this should be something similar to the images, which are, in some way, also URIs, you define your ingress with a placeholder host service1.myproject.local and then have a kustomization with:

Prod:

hosts:
  - name: service1.myproject.local
    newName: myservice1.company.com
  - name: service2.myproject.local
    newName: myservice2.company.com

Test:

hosts:
  - name: service1.myproject.local
    newName: myservice1.test.local
  - name: service2.myproject.local
    newName: myservice2.test.local

this should update all host references, not just ingress routes, but also gateway apis, and preferrably also the tls hosts

this is certainly more stable than having a json patch replace the xth, yth and zth element of an array.

And if there really needs to be an update to something else, like a crd, the images transformer implementation already has a mechanism for that with configurations (https://github.com/kubernetes-sigs/kustomize/blob/master/examples/transformerconfigs/images/kustomization.yaml)

It could even be that #3492/#3737 is enough, but that it's adoption is hindered by the lack of documentation?

This is where i'm getting stuck at being able to use the replacements transformer for ingress hosts:

replacements:
  - source: 
      kind: Ingress
      fieldPaths:
      - spec.rules.*.host
      - spec.tls.*.hosts.*
      # what goes here to specify which host I want to replace?
    target:
      # what goes here to set a specific value?

If a ReplacementTransformer won't do as-is, shouldn't we propose a modification to it, instead of going forward with an entire new transformer for now?

k8s-triage-robot commented 9 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

kragniz commented 9 months ago

/remove-lifecycle stale

xhanin commented 9 months ago

Kyverno seems to provide a solution for that: https://kyverno.io/policies/other/replace-ingress-hosts/replace-ingress-hosts/

That may be a good workaround to the lack of support in kustomize

k8s-triage-robot commented 6 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

kragniz commented 5 months ago

/remove-lifecycle stale

pfyod commented 5 months ago

What about just adding a new directive that allows one to override arbitrary merge keys, something like:

Base:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: placeholder

Patch:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - $mergeKey: placeholder
    host: example.com
SGStino commented 5 months ago

i believed it should be possible with the replacements, but i never got to figure out how they worked exactly. Maybe it wasn't really designed for it and it's still lacking a simple tweak?

I wrote this from what i could find in the ReplaceTransformer issues, but couldn't find how to tell it what to replacE.

replacements:
  - source: 
      kind: Ingress
      fieldPaths:
      - spec.rules.*.host
      - spec.tls.*.hosts.*
      # what goes here to specify which host I want to replace?
    target:
      # what goes here to set a specific value?
k8s-triage-robot commented 2 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

kragniz commented 2 months ago

/remove-lifecycle stale