some examples to show how to use kustomize as library. Examples are like applying a patch, applying a name reference substitution
Does kustomize support usage as a library? I'm very interested in this for configuration in sigs.k8s.io/kind
@BenTheElder Yes, it does. If you want to apply kustomize build to a directory, you can try
kt, _:= target.NewKustTarget(rootLoader, fSys, "")
allResources, err := kt.MakeCustomizedResMap()
if err != nil {
return err
}
// Output the objects.
res, err := allResources.EncodeAsYaml()
if err != nil {
return err
}
if o.outputPath != "" {
return fSys.WriteFile(o.outputPath, res)
}
// Write output to file
_, err = out.Write(res)
It is the same function calls as in kustomize build https://github.com/kubernetes-sigs/kustomize/blob/master/pkg/commands/build.go#L117
I've got something wrapping the build cobra command now for anyone else wanting to embed kustomize build as a library: https://github.com/kubernetes-sigs/kind/pull/77
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle rotten
I think what I actually need is just some unstructured patching code, currently these types (kubeadm config) aren't known as structured types to kustomize anyhow.
It would be nice if this logic could be re-used and had documentation :sweat_smile:
I also did some work on this here. It eschews the need for the external kustomize command, and even supports virtual patches.
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
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.
Most helpful comment
@BenTheElder Yes, it does. If you want to apply kustomize build to a directory, you can try
It is the same function calls as in
kustomize buildhttps://github.com/kubernetes-sigs/kustomize/blob/master/pkg/commands/build.go#L117