-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Should namePrefix apply to literally declared Namespace? #235
Comments
|
I think about this again and tend to not add nameprefix to namespace. It is expected by users that name prefix and namespace of resources are the same as declared in kustomization.yaml. Adding a prefix to the namespace name is not in alignment with this expectation. @monopole What do you think? |
Since the change is not backward compatible. We reverted it. Will add some deprecation message for current behavior in our next release (v1.0.6). This change will be added in a future release |
Just observing (for my own memory) that you added the deprecation message. Thanks! I know we're getting another release ready. |
I have a question. I have namespace resource for production is following base/namespace.yaml
And I'm using namespace overlayers/development/kustomization.yaml
This kustomization.yaml generate following namespace resource, and it make new namespace 'dev-world'. base/namespace.yaml
When namePrefix will be not apply to namespace resource, how to make different name namespace? |
@him0 I used a JSON patch for this purpose. For example, the following patch could be added to the overlay's kustomization.yaml:
in patch_namespace.yaml:
@Liujingfang1 not sure if this is idiomatic or if a more idiomatic way exists? |
I'm using
End result on doing
|
Looks like this change didn't make it out. I am using with the following patch: index 80c57462..96c6959f 100644
--- a/plugin/builtin/prefixsuffixtransformer/PrefixSuffixTransformer.go
+++ b/plugin/builtin/prefixsuffixtransformer/PrefixSuffixTransformer.go
@@ -32,6 +32,9 @@ var prefixSuffixFieldSpecsToSkip = []config.FieldSpec{
{
Gvk: gvk.Gvk{Kind: "CustomResourceDefinition"},
},
+ {
+ Gvk: gvk.Gvk{Kind: "Namespace"},
+ },
}
func (p *plugin) Config( |
same issue. I have a single namespace, and want to add a prefix/suffix to a base of resources. Turned out everything is ok except now the namespace has a prefix/suffix, and now there's a mismatch between the namespace of the @mr-karan did you manage to workaround it? |
Yes I found a workaround. The base should not have the Something like this works |
@mr-karan In my case I had to keep my base in fully working order, so i had to keep base/kustomization.yamlnamespace: my-namespace
resources:
- namespace.yaml
- ... base/namespace.yamlapiVersion: v1
kind: Namespace
metadata:
name: my-namespace overlay/my-overlay/kustomization.yamlnamespace: my-namespace
bases:
- ../../base
resources:
- ...
nameSuffix: -foo
# Workaround the fact that namePrefix / nameSuffix also adds a prefix to the base namespace. Issue: https://github.com/kubernetes-sigs/kustomize/issues/235#issuecomment-522887625. Workaround: https://github.com/kubernetes-sigs/kustomize/issues/235#issuecomment-430197657
patchesJson6902:
- target:
version: v1
kind: Namespace
name: my-namespace
path: namespace-patch.yaml overlay/my-overlay/namespace-patch.yaml- op: replace
path: /metadata/name
value: my-namespace This could really be more elegant, but at least it makes it easy to run a dozen or more very similar "stacks" all in the same namespace. At least for my use case. Hope it helps someone. |
@leojonathanoh I am using json patch workaround. @monopole Can we re-open this issue? Or do you prefer opening a new one? |
Can this be picked up again please? I am not sure why an issue which has (apparently) a working fix but is not actually fixed stays closed? This problem is a real annoyance for a lot of people and I for my part am getting tired of having to patch/fix these "strange" behaviors out of kustomize in my yamls (same goes e.g. for the commonLables problem with the selectors in netowrkpolicies...). |
Same problem here, namespace should be excluded or at least we should have an easy way to do it. |
Can this be reopened? |
Just ran into this one myself. Would be nice to have a clean way to handle this. |
I can confirm that this was released as part of v3.8.2 |
The way that actually works is this: in the base: apiVersion: v1
kind: Namespace
metadata:
# this namespace name will be prefixed with each overlay
name: ns in the overlay: namePrefix: dev-
# this namespace name is the composed name using the namePrefix "dev-" and the namespace base name "ns"
namespace: dev-ns Then all resources will have namespace |
I would like kustomize to work like it did before. How can I edit the transformer to behave like pre patch? |
There should be a way to allow applying prefix/suffix to Namespace resources. |
@KarstenSiemer @aabouzaid Have you found any workaround to add namePrefix/nameSuffix to namespace at the end? |
@KarstenSiemer @aabouzaid @winston0410 Please file a separate issue if this is a concern! |
kustomization.yaml
namespace.yaml
config.yaml
Literal Namespace name is prefixed with 'hello-' but ConfigMap namespace value isn't. I would either expect that namePrefix doesn't apply to literally declared Namespace or namespace references be tracked so that modifications done by kustomize are propagated like kustomize does with ConfigMap name hashing.
The text was updated successfully, but these errors were encountered: