Open Yingrjimsch opened 6 months ago
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 triage/accepted
label.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
@Yingrjimsch Hi, I'm so sorry that I can't reply to you with your feature request for around 4 months. Until recently, I couldn't take time to do big work due to having health issues for around half of a year.
I can start to discuss this now. /assign
First, I am Sorry to do this after you opened a PR, but I think we can't accept the current interface.
I think what you really need is the "multiple delimiter", and enddelimiter
is not a suitable word because it really shows that second delimiter
field.
I believe someone will soon open a PR that requires adding the "third delimiter" field if I accept your current PR.
First, I am Sorry to do this after you opened a PR, but I think we can't accept the current interface. I think what you really need is the "multiple delimiter", and
enddelimiter
is not a suitable word because it really shows that seconddelimiter
field.I believe someone will soon open a PR that requires adding the "third delimiter" field if I accept your current PR.
Thank you for the response. So in your opinion it should be able to make more than two delimiter? The reason for enddelimiter was to have a better capability (regex, full text replaxe) without breaking the current delimiter function. In my opinion there is the possibility to change delimiter completely to something more flexible but this leads to a breaking change. As we have experienced to fully reach its potential a single delimiter is not enough, do you think different about this?
FYI: a third delimiter wouldn't make sense im my opinion because with regex you can do more complex find and replace functions
@Yingrjimsch Hi, I'm so sorry that I can't reply to you with your feature request for around 4 months. Until recently, I couldn't take time to do big work due to having health issues for around half of a year.
I can start to discuss this now. /assign
No problem I hopebyou are feeling better now. If we can work something out that works for me and you approve it I'd appreciate it greatly
@Yingrjimsch
FYI: a third delimiter wouldn't make sense im my opinion because with regex you can do more complex find and replace functions
Hmm.....
If you don't need more complex operations that use more delimiters, I feel that using the technique of multiple replacements
and temporary values can achieve what you want in the current kustomize.
For example, https://github.com/koba1t/kustomize-demo/tree/bce00590ad987efe42cbafe71d288adeb9af1d65/replace_complex_domain
In my memory, the former kustomize maintainer preferred to use this.
@Yingrjimsch
FYI: a third delimiter wouldn't make sense im my opinion because with regex you can do more complex find and replace functions
Hmm..... If you don't need more complex operations that use more delimiters, I feel that using the technique of multiple
replacements
and temporary values can achieve what you want in the current kustomize.For example, https://github.com/koba1t/kustomize-demo/tree/bce00590ad987efe42cbafe71d288adeb9af1d65/replace_complex_domain
In my memory, the former kustomize maintainer preferred to use this.
So how would you go on and replace the example I made in the first comment of the pull request http://loki-backend.$(ENVIRONMENT)-myapp-observability.svc.cluster.local:3100$request_uri;
Here I want to replace the $(ENVIRONMENT)
or how would you be able to use a source value that is not necessary inside of a configmap? Or another example would be if you have a specific prefix and suffix but you don't want to replace everything in between but everything including prefix and suffix? These things can all be done by my extension but are missing in the current implementation of replacements.
@Yingrjimsch
So how would you go on and replace the example I made in the first comment of the pull request http://loki-backend.$(ENVIRONMENT)-myapp-observability.svc.cluster.local:3100$request_uri;
First, make configMap, which contains "$(ENVIRONMENT)-myapp-observability" at value.
Second, execute replacements
that replace $(ENVIRONMENT)
in the above value. (use delimiter: "-"
)
Then, that configMap contains an intermediate result that you want, like "develop-myapp-observability", and you can use this value for the next replacements
. (use delimiter: "."
)
@koba1t thanks for your answer. I can see how this would work, in my opinion, it is unnecessary complicated but I feel I can't convince you... if you decide there is a use for my pull request I'd be happy to assist.
@koba1t I'm not sure if your approach is sufficiently flexible to deal with all kinds of replacement that the inbetween replacement is trying to solve. For example, how would this multiple replacement strategy work for this:
iam.gke.io/gcp-service-account: CLUSTER_NAME-go2k-sa@PROJECT_NAME.iam.gserviceaccount.com
Replacing CLUSTER_NAME
is easy, replacing PROJECT_NAME
is not. With the inbetween, it could be done like this:
options:
delimiter: '@'
endDelimiter: '.'
index: 0
@koba1t I'm not sure if your approach is sufficiently flexible to deal with all kinds of replacement that the inbetween replacement is trying to solve. For example, how would this multiple replacement strategy work for this:
iam.gke.io/gcp-service-account: CLUSTER_NAME-go2k-sa@PROJECT_NAME.iam.gserviceaccount.com
Replacing
CLUSTER_NAME
is easy, replacingPROJECT_NAME
is not. With the inbetween, it could be done like this:options: delimiter: '@' endDelimiter: '.' index: 0
I agree thanks for the great example even CLUSTER_NAME
seems to be not quite easy to replace with the berween replacement you could do
options:
delimiter: ' '
endDelimiter: '-'
index: 0
out if curiosity how would you do it without?
CLUSTER_NAME
can be replaced using delimiter
set to -
and picking index 0.
Replacing the other part can't be done at the moment, so our workaround is to replace the whole line with the desired value, which introduces a lot of 'redundant' configuration.
@koba1t hi kobalt any don't you think this is still relevant? If not, I've got another issue with the replacements, I want to get labelSelector:env=this|that as written here this should be possible, the label selector should be implemented this way https://github.com/kubernetes-sigs/kustomize/blob/master/api/types/selector.go#L21 can you tell me how I can achieve that?
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
@Yingrjimsch Sorry, I didn't completely understand what you want.
replacements
didn't support the label selector use because replacements replaced any value from one resource to another. That doesn't support any selector
that may be multiple resources returned.
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/replacements/
Eschewed features
What would you like to have added?
To replace inbetween to substrings or chars would be very benificial. The replacement by delimiter with an index works pretty good but in some cases it is not enough because the part to replace is between two different chars.
Why is this needed?
If for example I want to replace the major version of
nginx:1.7.9
tonginx:2.7.9
there is no right delimiter for me to use to achieve the task. We have this problem in multiple yaml replacements, where the delimiter replacement is not enough.The following issue tries to achieve something similar: https://github.com/kubernetes-sigs/kustomize/issues/4555 Another example is we have a URL:
http://loki-backend.$(ENVIRONMENT)-myapp-observability.svc.cluster.local:3100$request_uri;
where we want to replace dynamically the$(ENVIRONMENT)
with sta, pre, pro or other environment abbreviations. For now it is not possible to replace this correctly because it is between the char.
and the char-
Can you accomplish the motivating task without this feature, and if so, how?
For now the example cannot be solved because it is between the char
.
and the char-
What other solutions have you considered?
My suggested solution is to have an additional
enddelimiter
property inreplacement.options
which can specify the second char / substring for replacement purpose. This can be done in source and target to be consistent and would have no affect on the current functionallity and a minimal code changeAnything else we should know?
I have created a branch on my fork with an implemented version, due to being new to golang I'm open for clean code or performance optimization suggestion. I also included two basic tests in the
replacement_test.go
which are calledpartial string replacement with enddelimiter in target - replace
andpartial string replacement with enddelimiter in source - replace
Feature ownership