Skip to main content

Use Cases

This tutorial will demonstrate how to deliver an App with a Loadbalancer in one Kusion command.


Init Project

Let's init this tutorial project with kusion init --online

➜  examples git:(main) ✗ kusion init --online
? Please choose a template: [Use arrows to move, type to filter]
> code-city Code City metaphor for visualizing Go source code in 3D.
deployment-multi-stack A minimal kusion project of multi stacks
deployment-single-stack A minimal kusion project of single stack

Select code-city and press Enter. After that we will see hints below and use the default value to config this project and stack.

The whole file hierarchy is shown below. More details about the directory structure can be found in Konfig.

➜  examples git:(main)cd code-city
➜ code-city git:(main) ✗ tree
├── base
│   └── base.k
├── dev
│   ├── ci-test
│   │   └── settings.yaml
│   ├── kcl.yaml
│   ├── main.k
│   └── stack.yaml
└── project.yaml

3 directories, 6 files

Review Config Files

# main.k
import .pkg

app = pkg.App {
image = "yuanhao1223/gocity:latest"

main.k only contains 5 lines (include an empty line). Line 1 imports a pkg that contains the model App which is an abstract model represents the App we will deliver later. This model hides the complexity of Kubernetes Deployment and Service and onely one field image is needed to make this App ready to use.

More details about Konfig Models can be found in Konfig


Deliver this App into a Kubernetes cluster with one command kusion apply

Check Deploy status.

➜  examples git:(main) ✗ kubectl get deploy
gocity 1/1 1 1 1m

Port-forward our App

➜  examples git:(main) ✗ kubectl port-forward svc/gocity 4000:4000
Forwarding from -> 4000
Forwarding from [::1]:4000 -> 4000

Visit http://localhost:4000/#/ in your browser and enjoy.