-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to use ReplacementTransformer for fields that need a text placeholder? #4012
Comments
@rkr-kununu: This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This is a problem we are aware of - a similar use case is described in #3978. For now we are thinking about using generators for such use cases, but it will be difficult for us to provide generators for all possible CRDs. We've written a builtin generator plugin for generating service account resources. Something you can do is write your own generator plugin (a guide is here) for your CRD. |
Thank you for the feedback - I'm relieved to know it's on the radar. However, I'm not too thrilled with the prospect of needing to write/install a custom generators for the various CRDs we want to use or expecting the kubernetes community to provide them. Especially, when great tools like crossplane exist, which create an easy way to make custom opinionated CRDs. Could we instead unify the configuration of the An example of the current apiVersion: builtin
kind: ValueAddTransformer
metadata:
name: MyNamespaceFolder
targets:
- selector:
kind: Namespace
fieldPath: metadata/annotations/my-namespace
# Replace any existing value
filePathPosition: 0 An example of the current apiVersion: builtin
kind: ReplacementTransformer
metadata:
name: notImportantHere
replacements:
- source:
kind: Deployment
fieldPath: spec.template.spec.containers.0.image
targets:
- select:
kind: Deployment
fieldPaths:
- spec.template.spec.containers.1.image ...by "unifying" I specifically mean take the apiVersion: builtin
kind: ReplacementTransformer
metadata:
name: notImportantHere
replacements:
- source:
kind: Deployment
fieldPath: spec.template.spec.containers.0.image
targets:
- selector:
kind: Deployment
fieldPath: spec.template.spec.containers.1.image
# Replace any existing value
filePathPosition: 0 Then we can modify the So, how this would relate to my use-case... Given: apiVersion: builtin
kind: ReplacementTransformer
metadata:
name: notImportantHere
replacements:
- source:
kind: Namespace
fieldPath: metadata/name
targets:
- selector:
kind: IngressRoute
fieldPath: spec.routes.*.match
# This will replace all-occurrences of NAMESPACE with the value referred in replacements/source/fieldPath (ie: test)
placeholderName: NAMESPACE
- selector:
kind: IngressRoute
fieldPath: spec.routes.*.services.*.namespace
# Replace any existing value
filePathPosition: 0 ...and the apiVersion: v1
kind: Namespace
metadata:
name: test
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: app-cms
annotations:
my-namespace: test
spec:
entryPoints:
- websecure
routes:
- match:
Host(`www-NAMESPACE.example.com`) && Path(`/test$}`)
kind: Rule
services:
- name: app-cms
namespace: IGNORED
port: 80
- match:
Host(`www-NAMESPACE.example.com`) && (PathPrefix(`/example`)
|| Path(
`/`, `/a`, `/b`, `/c`, `/d`)
)
kind: Rule
services:
- name: app-cms
namespace: IGNORED
port: 80
tls: {} Which would ultimately yield: apiVersion: v1
kind: Namespace
metadata:
name: test
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: app-cms
spec:
entryPoints:
- websecure
routes:
- match:
Host(`www-test.example.com`) && Path(`/test$}`)
kind: Rule
services:
- name: app-cms
namespace: test
port: 80
- match:
Host(`www-test.example.com`) && (PathPrefix(`/example`)
|| Path(
`/`, `/a`, `/b`, `/c`, `/d`)
)
kind: Rule
services:
- name: app-cms
namespace: test
port: 80
tls: {} |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
We had the same problem and also didn't want to write/maintain our own custom generator plugin. We created a full-blown stackoverflow Q&A - but here are the brief steps: As a workaround we can create yaml files inline in our console using the syntax
And then use the described syntax to create a
The last step is to use the
Now running
It's only a workaround, but might help to bridge the time until @rkr-kununu 's great idea might get implemented into Kustomize. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Since it's been announced that
vars
will be deprecated in favor of ReplacementTransformer, I'd like to replace our use ofvars
in our test environment.However, we're using Traefik's CRDs which is running within a dedicated namespace (with a wildcard ssl cert). This means each test environment exists within their respective namespace and share a single (public) Traefik instance to mock our public facing services.
Traefik's CRD introduces IngressRoute which has a Match section which contains an arbitrary number of rules. Because our instance of Traefik is shared, we use the Host in the request to have Traefik route the request to the proper namespace.
We've been using
vars
to extract the equivalent of the namespace. So our IngressRoute looks something like:However, from the documentation/experiments I've made it appears that
ReplacementTransformer
is pretty limited when it comes to supporting how we're usingHost()
.Is there some undocumented feature I'm missing?
The text was updated successfully, but these errors were encountered: