Skip to content
Branch: master
Find file Copy path
Find file Copy path
4 contributors

Users who have contributed to this file

@yujunz @justinsb @monopole @ibidani
132 lines (98 sloc) 3.56 KB

Remote Sources

Kustomize supports building a remote target, but the URLs are limited to common Git repository specs.

To extend the supported format, Kustomize has a plugin system that allows one to integrate third-party tools such as hashicorp/go-getter to "download things from a string URL using a variety of protocols", extract the content and generated resources as part of kustomize build.

Make a place to work

DEMO_HOME=$(mktemp -d)
mkdir -p $DEMO_HOME/base

Use a remote kustomize layer

Define a kustomization representing your local variant (aka environment).

This could involve any number of kustomizations (see other examples), but in this case just add the name prefix my- to all resources:

cat <<'EOF' >$DEMO_HOME/kustomization.yaml
namePrefix:  my-
- base/

It refer a remote base defined as below:

cat <<'EOF' >$DEMO_HOME/base/kustomization.yaml
- goGetter.yaml

The base refers to a generator configuration file called goGetter.yaml.

This file lets one specify the source URL, and other things like sub path in the package, defaulting to base directory, and command to run under the path, defaulting to kustomize build.

Create the config file goGetter.yaml, specifying the arbitrarily chosen name example:

cat <<'EOF' >$DEMO_HOME/base/goGetter.yaml
kind: GoGetter
  name: example

Because this particular YAML file is listed in the generators: stanza of a kustomization file, it is treated as the binding between a generator plugin - identified by the apiVersion and kind fields - and other fields that configure the plugin.

Download the plugin to your DEMO_HOME and make it executable:

curl -s --create-dirs -o \
"$DEMO_HOME/kustomize/$plugin" \

chmod a+x $DEMO_HOME/kustomize/$plugin

Define a helper function to run kustomize with the correct environment and flags for plugins:

function kustomizeIt {
  kustomize build --enable_alpha_plugins \

Finally, build the local variant. Notice that all resource names now have the my- prefix:


Compare local variant to remote base:

diff <(kustomizeIt) <(kustomizeIt base) | more

<   name: my-remote-cm
>   name: remote-cm

To see the unmodified but extracted sources, run kustomize on the base. Every invocation here is re-downloading and re-building the package.

kustomizeIt base

Use non-kustomize remote sources

Sometimes the remote sources does not include kustomization.yaml. To use that in the plugin, set command to override the default build.

echo "command: cat resources.yaml" >>$DEMO_HOME/base/goGetter.yaml

Finally, built it


and observe the output includes raw resources.yaml instead of building result of remote kustomization.yaml.

You can’t perform that action at this time.