This is an example of a kpt package that has a kustomize patch in it.
- Fetch the package
- View the package contents
- Configure functions
- Render the declared values
- Apply the package
Get the example package on to local using kpt pkg get
$ kpt pkg get https://github.com/GoogleContainerTools/kpt.git/package-examples/helloworld-kustomize
fetching package /package-examples/helloworld-kustomize from https://github.com/GoogleContainerTools/kpt to helloworld-kustomize
List the package contents in a tree structure.
$ kpt pkg tree helloworld-kustomize/
Package "helloworld-kustomize"
├── [Kptfile] Kptfile helloworld-kustomize
├── patches
│ └── [patch.yaml] Deployment helloworld-gke
└── resources
├── [deploy.yaml] Deployment helloworld-gke
└── [service.yaml] Service helloworld-gke
The package contains a function pipeline in the Kptfile
which has
one apply-setters
function. The apply-setters
function allows you to
set a simple value throughout the package configuration. In this case the
value of the setter goes into the patch.yaml
. You can set the target
environment variable to a value different of your choice (different
than foobar
)
pipeline:
mutators:
- image: gcr.io/kpt-fn/apply-setters:unstable
configMap:
target: foobar
Render the changes in the hydration pipeline by using kpt fn render
command:
$ kpt fn render helloworld-kustomize/
Since this is a kustomize example we will be using kubectl -k
:
$ kubectl apply -k helloworld-kustomize
service/helloworld-gke created
deployment.apps/helloworld-gke created