-
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
Kustomize API Proposal: Add an example with components #2438
Kustomize API Proposal: Add an example with components #2438
Conversation
Hi @apyrgio. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
For those who are not aware of the on-going discussion on this subject, let me add a preface: This PR has been sent as a follow-up to a live discussion regarding composition support in Kustomize (#1251). See here for more details. Its purpose is to showcase how components would work, based on @pgpx's #2168 PR. Feel free to comment on anything that seems off with this design, or if there's a use-case that you feel is not covered. For instance, what I feel is not covered is the handling of relative paths. In this example, it's the secrets for LDAP/reCAPTCHA/etc. Since components are reusable, and probably provided by the upstream, they should be treated as read-only. So, we shouldn't store files in them so that the generators can pick them up. Instead, it may be better to resolve the file paths relative to the top-level overlay. This of course is of lesser importance to the actual issue, but I'm mentioning it here for completeness. |
Also, in case it's not clear. For those wandering if the example would work if we simply switched:
with:
the answer is:
The reason is that Kustomize processes overlays in parallel, so if two overlays point to the same base, it will create two copies of it but will not be able to merge them. |
96034d1
to
b5c3b87
Compare
Add a WIP example that showcases how components can be used.
b5c3b87
to
6063a6b
Compare
/ok-to-test |
Describe in more detail the solution with stock kustomize variants to better showcase the benefits of kustomize components. Plus, revamp certain parts of the example with minor fixes.
Rename all `KustomizationPatch` instances to `v1alpha1/KustomizationPatch`, to reflect that it's an alpha feature.
Hey there, this is an update with regard to the action item from the previous community meeting: as agreed, with @apyrgio we have worked on a second iteration of the example document that describes Κustomize components. We now provide 2 solutions to the same problem, one without and one with Kustomize components. We hope that they adequately highlight the value of the composition feature. |
@ioandr Thanks! |
examples/components.md
Outdated
mkdir -p $RECAPTCHA | ||
|
||
cat <<EOF >$RECAPTCHA/kustomization.yaml | ||
kind: v1alpha1/KustomizationPatch |
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.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
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.
Done.
|
||
cat <<EOF >$COMMUNITY/kustomization.yaml | ||
kind: Kustomization | ||
resources: |
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.
Probably makes sense to have components separate from resources.
components:
- ../../components/external_db
- ../../components/recaptcha
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.
Our approach was to stay as close as possible to the existing interface of kustomization files.
Since the bases
keyword was also absorbed by resources
quite recently we believe it is more straight forward to have the resources
keyword cover all cases, including components.
Aside, such a change might have implications in the size and complexity of #2168.
In any case, we are definitely open to iterate on this and reach a common understanding.
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.
A Component
(aka KustomizationPatch
) effectively become the parent resource of the resources that come before it in the resources
list. They could be moved to a separate components
list, which I think could then be evaluated as if it was appended to the end of the resources
list. I guess this would make things a little clearer (and maybe opportunities for checking that only the correct types are in each list), and probably wouldn't make the code that much more complicated. The disadvantage is that you wouldn't be able to add any resources to be evaluated after the components, but I can't think of any examples that would actually need that (and the examples don't), so maybe that isn't a real concern?
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.
I implemented support for a components
list on a separate branch in my fork - doesn't seem to bad, with most of the added complexity needed to limit each kind to their own list. The code definitely could do with a slightly more extensive refactor if components
is preferred, but I didn't do that now just to minimise the extent of the changes.
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.
I think this is reasonable for now. It has an alpha apiVersion so we aren't commitment to keeping the API in this form.
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.
Should I merge that in to the main PR branch? I still need to make the change so make it use alpha instead of beta.
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.
I rebased the components branch and added v1alpha1
support.
LDAP=$DEMO_HOME/components/ldap | ||
mkdir -p $LDAP | ||
|
||
cat <<EOF >$LDAP/kustomization.yaml |
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.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
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.
Done.
examples/components.md
Outdated
mkdir -p $EXT_DB | ||
|
||
cat <<EOF >$EXT_DB/kustomization.yaml | ||
kind: v1alpha1/KustomizationPatch # <-- Component notation |
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.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
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.
Done.
mkdir $BASE | ||
|
||
cat <<EOF >$BASE/kustomization.yaml | ||
resources: |
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.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Customization
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.
Done, s/Customization/Kustomization
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.
Yup, silly auto correct.
examples/components.md
Outdated
EOF | ||
``` | ||
|
||
Define a `community` overlay, that bundles the external DB and reCAPTCHA |
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.
overlay -> variant
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.
Done.
files: | ||
- ldappass.txt | ||
|
||
patchesStrategicMerge: |
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.
Maybe use a configMapGenerator in one of the components to show that it would work as well? Something like the following (or use a files:
generator):
patchesStrategicMerge: | |
configMapGenerator: | |
- name: conf | |
behavior: merge | |
literals: | |
- ldap.conf=| | |
endpoint=ldap://ldap.example.com | |
bindDN=cn=admin,dc=example,dc=com | |
pass=/var/run/secrets/ldap/ldappass.txt |
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.
Sure, let's spice this up.
Would you clarify in the doc if the ordering matters? I assume it doesn't, but would be good to clarify that |
Let's move forward with this as there have been no objections. WDYT of the following proposal:
After the above are complete, let's merge this PR so the new capabilities are documented. Consider promoting your new feature on twitter. |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apyrgio, pwittrock 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 |
@pwittrock The ordering of |
Hm, my guess is that we want components to apply to all resources in the list -- otherwise I'd expect subtle bugs. Its not clear from looking at the resource list what is a resources vs a path vs a component. Otherwise we might want a more explicit expression of what is applied and where. Perhaps components should have a protocol as part of the URI so it is more clear.
|
@pwittrock Indeed, it makes sense to spin this feature request into a separate KEP. Thanks for breaking down the process to steps, they seem pretty solid. We’ll follow them and try to have something ready by this Wednesday. |
Incorporate the suggestion of the separate "components" field, that will hold references to resources of `Component` kind. Also, add a missing reference to the base, in the Kustomization files of the variants.
/hold Currently, it's a list, not a set, and don't want to change that accidentally. |
It seems that the semantics of the I think we agree that components are a special case of overlays, that can modify the same set of resources without "cloning" them. In this example, the resources are the Now, as for how we can communicate this to the users. I think that the proposal for a separate |
Slightly alter the reCAPTCHA component to use a `configMapGenerator`, instead of patching the base `ConfigMap` as in the rest of the components, to show that this is supported as well.
I have updated the example to demonstrate how the |
/lgtm looks like fun, thanks for working on this. |
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.
/lgtm
make ux happy
Just a quick note here; I'm a bit worried that there will be people who will go through the examples of Kustomize, see this example and try to use it. However, the corresponding functionality has not yet been merged. Should we warn in the example that this is a work in progress? |
This enhancement proposal introduces components, a new kind of Kustomization that allows users to define reusable kustomizations. Main discussion: kubernetes-sigs/kustomize#1251 User story that spawned this KEP: kubernetes-sigs/kustomize#2438
This enhancement proposal introduces components, a new kind of Kustomization that allows users to define reusable kustomizations. Main discussion: kubernetes-sigs/kustomize#1251 User story that spawned this KEP: kubernetes-sigs/kustomize#2438
Me, @ioandr and @pgpx have written the requested KEP. See kubernetes/enhancements#1803 for more details. |
Add a WIP example that showcases how components can be used. This example is purposefully similar to the multibases example, to showcase what's the current shortcoming of overlays, namely that we currently can't combine overlays that point to the same common base. Also, this example uses the
KustomizationPatch
notation to define a component, as seen in #2168.For convenience, you can see the rendered example here.