Skip to content

Commit ad9b416

Browse files
authored
feat: update base example applications (#140)
1 parent 0796266 commit ad9b416

File tree

29 files changed

+87
-154
lines changed

29 files changed

+87
-154
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ report/
2020

2121
kusion_state.json
2222

23-
changed_list.txt
23+
changed_list.txt
24+
25+
*.lock

README-zh.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# Konfig
1+
# konfig
22
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=488867056&machine=standardLinux32gb&devcontainer_path=.devcontainer.json)
33

4-
[English](README.md) | [Chinese](README-zh.md)
5-
6-
This is a example repository for [Kusion](https://github.com/KusionStack/kusion), where you can use the examples provided to quickly learn how to use Kusion.
4+
konfig repository contains various example applications code, you can use these example applications to quickly try out and learn how to use [Kusion](https://github.com/KusionStack/kusion).
75

86
## Getting Started
97

10-
If you are new to Kusion, please visit [Getting Started](https://kusionstack.io/docs/user_docs/getting-started/) to learn about Kusion. It includes installation instructions, quick start guide, and some basic concepts.
8+
If you're new to Kusion, start by reviewing the [Getting Started](https://www.kusionstack.io/docs/user_docs/getting-started/) page, which includes quickstart installation, guided tutorials and deployment instructions.
119

12-
All the examples are located in the `example`` directory, and you can find corresponding tutorials in the [User Guide](https://kusionstack.io/docs/user_docs/guides/).
10+
All guided tutorials use applications in this repository, located in the `example` directory.
1311

1412
## Deploying Examples
1513

16-
You can execute the `kusion apply` command in different example directories to deploy different examples. Some examples have prerequisites, such as an accessible Kubernetes cluster or an account of a specific cloud provider. Please refer to the tutorials in the [User Guide](https://kusionstack.io/docs/user_docs/guides/) for specific prerequisites.
14+
You can experiment with the different examples by entering each directory and running `kusion apply`. Some examples have prerequisites, e.g. accessible Kubernetes cluster or account for cloud provider. Please refer to guided tutorials in the [User Guide](https://www.kusionstack.io/docs/user_docs/guides/) for specific prerequisites.

example/multi-stack/README.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

example/multi-stack/dev/kcl.mod.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

example/multi-stack/dev/main.k

Lines changed: 0 additions & 14 deletions
This file was deleted.

example/multi-stack/prod/kcl.mod.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

example/multi-stack/prod/main.k

Lines changed: 0 additions & 14 deletions
This file was deleted.

example/nginx/dev/kcl.mod.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

example/nginx/dev/kcl.mod renamed to example/samplejob/prod/kcl.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "nginx"
2+
name = "samplejob"
33
edition = "0.1.0"
44
version = "0.1.0"
55

example/samplejob/prod/main.k

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import catalog.models.schema.v1 as ac
2+
import catalog.models.schema.v1.workload as wl
3+
import catalog.models.schema.v1.workload.container as c
4+
5+
samplejob: ac.AppConfiguration {
6+
workload: wl.Job {
7+
containers: {
8+
"busybox": c.Container {
9+
# The target image
10+
image: "busybox:1.28"
11+
# Run the following command as defined
12+
command: ["/bin/sh", "-c", "echo hello"]
13+
}
14+
}
15+
# Run every hour.
16+
schedule: "0 * * * *"
17+
}
18+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# The project basic info
2-
name: nginx
2+
name: samplejob
33
generator:
44
type: AppConfiguration

example/multi-stack/base/base.k renamed to example/service-multistack/base/base.k

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ import catalog.models.schema.v1.workload as wl
33
import catalog.models.schema.v1.workload.network as n
44
import catalog.models.schema.v1.workload.container as c
55

6-
helloworld: ac.AppConfiguration {
6+
echoserver: ac.AppConfiguration {
77
workload: wl.Service {
88
containers: {
9-
"helloworld": c.Container {
9+
"server": c.Container {
1010
image = "<no value>"
1111
resources: {
12-
"cpu": "500m"
13-
"memory": "512Mi"
12+
"cpu": "250m"
13+
"memory": "256Mi"
1414
}
1515
}
1616
}
1717
replicas: 1
1818
ports: [
1919
n.Port {
20-
port: 8080
20+
port: 80
2121
}
2222
]
2323
}

example/multi-stack/prod/kcl.mod renamed to example/service-multistack/dev/kcl.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "multi-stack"
2+
name = "service-multistack"
33
edition = "0.5.0"
44
version = "0.1.0"
55

example/service-multistack/dev/main.k

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import catalog.models.schema.v1 as ac
2+
3+
# main.k declares customized configurations for dev stack.
4+
echoserver: ac.AppConfiguration {
5+
workload.containers.server: {
6+
# dev stack use latest echoserver image
7+
image = "cilium/echoserver"
8+
}
9+
}

example/multi-stack/dev/kcl.mod renamed to example/service-multistack/prod/kcl.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "multi-stack"
2+
name = "service-multistack"
33
edition = "0.5.0"
44
version = "0.1.0"
55

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import catalog.models.schema.v1 as ac
2+
3+
# main.k declares customized configurations for prod stack.
4+
echoserver: ac.AppConfiguration {
5+
# replicas is 2 for prod
6+
workload.replicas = 2
7+
workload.containers.server: {
8+
# prod stack use older stable echoserver image
9+
image = "cilium/echoserver:1.10.3"
10+
# also prod stack require more resources
11+
resources = {
12+
"cpu": "500m"
13+
"memory": "512Mi"
14+
}
15+
}
16+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# The stack basic info
2-
name: dev
2+
name: prod
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# The project basic info
2+
name: service-multistack
3+
generator:
4+
type: AppConfiguration

example/simpleservice/prod/kcl.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "simpleservice"
3+
edition = "0.1.0"
4+
version = "0.1.0"
5+
6+
[dependencies]
7+
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.1" }
8+
[profile]
9+
entries = ["main.k"]
10+
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
import catalog.models.schema.v1 as ac
22
import catalog.models.schema.v1.workload as wl
33
import catalog.models.schema.v1.workload.container as c
4-
import catalog.models.schema.v1.workload.network as n
54

6-
nginx: ac.AppConfiguration {
5+
# main.k declares desired configurations for prod stack.
6+
simplesvc: ac.AppConfiguration {
77
workload: wl.Service {
88
containers: {
9-
nginx: c.Container {
9+
"nginx": c.Container {
10+
# use nginx:1.25.2 as target image
1011
image = "nginx:1.25.2"
12+
# resource requirements for nginx container
1113
resources: {
1214
"cpu": "500m"
1315
"memory": "512Mi"
1416
}
1517
}
1618
}
1719
replicas: 1
18-
ports: [
19-
n.Port {
20-
type: "aliyun"
21-
port: 80
22-
protocol: "TCP"
23-
public: True
24-
}
25-
]
2620
}
2721
}

example/simpleservice/prod/stack.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# The stack basic info
2+
name: prod
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# The project basic info
2-
name: multi-stack
2+
name: simpleservice
33
generator:
44
type: AppConfiguration

example/wordpress/dev/kcl.mod.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

example/wordpress/dev/main.k

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import catalog.models.schema.v1.accessories.database as db
1010

1111
# main.k declares reusable configurations for all stacks.
1212
wordpress: ac.AppConfiguration {
13+
# the main workload configurations
1314
workload: wl.Service {
1415
containers: {
1516
wordpress: c.Container {
@@ -31,6 +32,7 @@ wordpress: ac.AppConfiguration {
3132
}
3233
]
3334
}
35+
# database accessory configurations
3436
database: db.Database {
3537
type: "alicloud"
3638
engine: "MySQL"

hack/lib/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
NAME = "name"
1616
KUSION_CMD = "kusion"
1717
COMPILE_CMD = "compile"
18+
BUILD_CMD = "build"
1819
PREVIEW_CMD = "preview"
1920
APPLY_CMD = "apply"
2021
NO_STYLE_FLAG = "--no-style"

hack/test_correctness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_correctness(stack_dir):
1414
print(f"Ignore stack {stack_dir}.")
1515
return
1616
print(f"Test correctness of stack {stack_dir}...")
17-
cmd = [KUSION_CMD, COMPILE_CMD]
17+
cmd = [KUSION_CMD, BUILD_CMD]
1818
process = subprocess.run(
1919
cmd, capture_output=True, cwd=Path(stack_dir), env=dict(os.environ)
2020
)

0 commit comments

Comments
 (0)