NOTE: The usage of Kpt described in this repository is outdated. Please refer to the official documentation for the latest information.
This is a sample of Kpt, a tool for packaging, customizing, validating, and applying Kubernetes resources.
This is a simple sample of how to configure and deploy nginx to a Kubernetes cluster using Kpt.
.
└── sample
├── Kptfile # <= generated by Kpt
├── README.md # <= generated by Kpt
├── deployment.yml
└── service.yml
See document.
Create a Kptfile
in an empty directory.
kpt pkg init sample/
Create a key-value pair setter as a data item to change the settings for each environment.
When the command is executed, the setter is added to the Kptfile
.
kpt cfg create-setter sample/ name xxx
kpt cfg create-setter sample/ image xxx
(created setter example)
openAPI:
definitions:
io.k8s.cli.setters.name:
x-k8s-cli:
setter:
name: name
value: xxx
You can change the settings for each environment by specifying them as comments in the resource file as follows.
(example)
name: xxx # {"$ref":"#/definitions/io.k8s.cli.setters.name"}
Get the Kpt package from the git repository by specifying the output folder.
kpt pkg get https://github.com/hyorimitsu/hello-kpt.git/sample@master kpt-nginx
Set the value to the template by specifying a key-value pair.
kpt cfg set kpt-nginx/ name kpt-nginx-test
kpt cfg set kpt-nginx/ image nginx:1.14
If you look at the resource file here, you will see that you can set the values as follows.
name: kpt-nginx-test # {"$ref":"#/definitions/io.k8s.cli.setters.name"}
kubectl apply -R -f kpt-nginx/
kubectl delete -R -f kpt-nginx/