-
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
Example of configuring builtin plugin. #1534
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: monopole The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@richardmarshall @jbrette PTAL |
0338dc1
to
13f0e19
Compare
13f0e19
to
6465b92
Compare
9a50056
to
44c0e74
Compare
docs/plugins/builtins.md
Outdated
> apiVersion: builtin | ||
> kind: ImageTagTransformer | ||
> metadata: | ||
> name: notImportantHere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually really important. In order to be able to change two images, you need to add multiple transformers. The name of the transformers have to be different, otherwise the resources accumulation will fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to "not-imporant-in-this-example" which is what i meant.
indeed, the names need to be different if using more than one.
maybe just change it to a my-image-transformer or something?
docs/plugins/builtins.md
Outdated
> kind: NamespaceTransformer | ||
> metadata: | ||
> name: notImportantHere | ||
> namespace: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax of the namespace transformer is kind of misleading. the "metadata/name" is not important but the "metadata/namespace" is. Unlike the other transformer (prefix, suffix), that field is not part of the "spec" of the Transformer but part of the metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not every plugin has the config under spec
. Even for prefix/suffix transformer, it's prefix
and suffix
instead of spec
. The transformer/generator plugin read the whole k8s styled yaml as its configuration, not only spec
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me rephrase. All the other transformers have the addditional parameters at the top level....basically the fieldSpecs level, the metadata field is actually irrelevant most of the time.
apiVersion: builtin
kind: LabelTransformer
metadata:
name: notImportantHere
labels:
app: myApp
env: production
fieldSpecs:
- path: metadata/labels
create: true
or
apiVersion: builtin
kind: PrefixSuffixTransformer
metadata:
name: notImportantHere
prefix: baked-
suffix: -pie
fieldSpecs:
- path: metadata/name
But not for the namespace transformer. The consistent way of doing, should be like this:
apiVersion: builtin
kind: NamespaceTransformer
metadata:
name: notImportantHere
namespace: test
fieldSpecs:
- path: metadata/namespace
The other issue is here. The name is actually important for ImageTransformer if you need multiple image transformations. The metadata/namespace is supposed to be completely irrelevant but is not, and the namespace transformer ends up being in a different namespace than all the other transformers. This will be an issue when we will try to apply kustomize on top of the transformer config.yaml
func (kt *KustTarget) configureExternalTransformers() ([]resmap.Transformer, error) {
ra := accumulator.MakeEmptyAccumulator()
err := kt.accumulateResources(ra, kt.kustomization.Transformers)
if err != nil {
return nil, err
}
return kt.pLdr.LoadTransformers(kt.ldr, ra.ResMap())
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbrette yes, the namespace transformer is an outlier.
see comments here: #1280
it's philosophically wrong, but in practice is works and allows for a smaller config file, fwiw.
we should probably 'fix' it if for no other reason than to avoid this kind of confusion/conversation.
Not in this PR though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this clarification, and for this comment especially: #1280 (comment)!
dc81757
to
7408c8c
Compare
OK comments addressed. sorry was doing a bunch of pushes to see how it looked since my local md renderer is busted and too lazy to fix at the moment |
7408c8c
to
74ed0b3
Compare
I'm not happy with the section headings, e.g. SecretGeneratorUsage via kustomization.yamlfield name: secretGeneratorUsage via pluginArgumentsExamplecould use some improvement, but i'd rather fix in the context of a code generator since it's so tedious to do this. |
@monopole Thank you for this work. /lgtm |
Requires #1532