Skip to content

hyorimitsu/hello-kpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Hello Kpt

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.

Description

This is a simple sample of how to configure and deploy nginx to a Kubernetes cluster using Kpt.

Directory Structure

.
└── sample
    ├── Kptfile    # <= generated by Kpt
    ├── README.md  # <= generated by Kpt
    ├── deployment.yml
    └── service.yml

Provision

1. Install

See document.

2. Initialize

Create a Kptfile in an empty directory.

kpt pkg init sample/

3. Create setter

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

4. Add template

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"}

Usage

1. Get the created package

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

2. Set values to the template

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"}

3. Apply to Kubernetes cluster

kubectl apply -R -f kpt-nginx/

4. Delete from Kubernetes cluster

kubectl delete -R -f kpt-nginx/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published