Skip to content

Commit

Permalink
feat: update base example applications
Browse files Browse the repository at this point in the history
  • Loading branch information
adohe committed Dec 5, 2023
1 parent 0796266 commit 0e74448
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 154 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ report/

kusion_state.json

changed_list.txt
changed_list.txt

*.lock
18 changes: 0 additions & 18 deletions README-zh.md

This file was deleted.

12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Konfig
# konfig
[![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)

[English](README.md) | [Chinese](README-zh.md)

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.
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).

## Getting Started

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.
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.

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/).
All guided tutorials use applications in this repository, located in the `example` directory.

## Deploying Examples

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.
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.
45 changes: 0 additions & 45 deletions example/multi-stack/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions example/multi-stack/dev/kcl.mod.lock

This file was deleted.

14 changes: 0 additions & 14 deletions example/multi-stack/dev/main.k

This file was deleted.

8 changes: 0 additions & 8 deletions example/multi-stack/prod/kcl.mod.lock

This file was deleted.

14 changes: 0 additions & 14 deletions example/multi-stack/prod/main.k

This file was deleted.

8 changes: 0 additions & 8 deletions example/nginx/dev/kcl.mod.lock

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "nginx"
name = "samplejob"
edition = "0.1.0"
version = "0.1.0"

Expand Down
16 changes: 16 additions & 0 deletions example/samplejob/prod/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import catalog.models.schema.v1 as ac
import catalog.models.schema.v1.workload as wl
import catalog.models.schema.v1.workload.container as c

samplejob: ac.AppConfiguration {
workload: wl.Job {
containers: {
"busybox": c.Container {
# The target image
image: "busybox:1.28"
# Run the following command as defined
command: ["/bin/sh", "-c", "echo hello"]
}
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The project basic info
name: nginx
name: samplejob
generator:
type: AppConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import catalog.models.schema.v1.workload as wl
import catalog.models.schema.v1.workload.network as n
import catalog.models.schema.v1.workload.container as c

helloworld: ac.AppConfiguration {
echoserver: ac.AppConfiguration {
workload: wl.Service {
containers: {
"helloworld": c.Container {
"server": c.Container {
image = "<no value>"
resources: {
"cpu": "500m"
"memory": "512Mi"
"cpu": "250m"
"memory": "256Mi"
}
}
}
replicas: 1
ports: [
n.Port {
port: 8080
port: 80
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "multi-stack"
name = "service-multistack"
edition = "0.5.0"
version = "0.1.0"

Expand Down
9 changes: 9 additions & 0 deletions example/service-multistack/dev/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import catalog.models.schema.v1 as ac

# main.k declares customized configurations for dev stack.
echoserver: ac.AppConfiguration {
workload.containers.server: {
# dev stack use latest echoserver image
image = "cilium/echoserver"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "multi-stack"
name = "service-multistack"
edition = "0.5.0"
version = "0.1.0"

Expand Down
16 changes: 16 additions & 0 deletions example/service-multistack/prod/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import catalog.models.schema.v1 as ac

# main.k declares customized configurations for prod stack.
helloworld: ac.AppConfiguration {
# replicas is 2 for prod
workload.replicas = 2
workload.containers.server: {
# prod stack use older stable echoserver image
image = "cilium/echoserver:1.10.3"
# also prod stack require more resources
resources = {
"cpu": "500m"
"memory": "512Mi"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# The stack basic info
name: dev
name: prod
4 changes: 4 additions & 0 deletions example/service-multistack/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The project basic info
name: service-multistack
generator:
type: AppConfiguration
10 changes: 10 additions & 0 deletions example/simpleservice/prod/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "simpleservice"
edition = "0.1.0"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.1" }
[profile]
entries = ["main.k"]

16 changes: 5 additions & 11 deletions example/nginx/dev/main.k → example/simpleservice/prod/main.k
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import catalog.models.schema.v1 as ac
import catalog.models.schema.v1.workload as wl
import catalog.models.schema.v1.workload.container as c
import catalog.models.schema.v1.workload.network as n

nginx: ac.AppConfiguration {
# main.k declares desired configurations for prod stack.
simplesvc: ac.AppConfiguration {
workload: wl.Service {
containers: {
nginx: c.Container {
"nginx": c.Container {
# use nginx:1.25.2 as target image
image = "nginx:1.25.2"
# resource requirements for nginx container
resources: {
"cpu": "500m"
"memory": "512Mi"
}
}
}
replicas: 1
ports: [
n.Port {
type: "aliyun"
port: 80
protocol: "TCP"
public: True
}
]
}
}
2 changes: 2 additions & 0 deletions example/simpleservice/prod/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The stack basic info
name: prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The project basic info
name: multi-stack
name: simpleservice
generator:
type: AppConfiguration
8 changes: 0 additions & 8 deletions example/wordpress/dev/kcl.mod.lock

This file was deleted.

2 changes: 2 additions & 0 deletions example/wordpress/dev/main.k
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import catalog.models.schema.v1.accessories.database as db

# main.k declares reusable configurations for all stacks.
wordpress: ac.AppConfiguration {
# the main workload configurations
workload: wl.Service {
containers: {
wordpress: c.Container {
Expand All @@ -31,6 +32,7 @@ wordpress: ac.AppConfiguration {
}
]
}
# database accessory configurations
database: db.Database {
type: "alicloud"
engine: "MySQL"
Expand Down
1 change: 1 addition & 0 deletions hack/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
NAME = "name"
KUSION_CMD = "kusion"
COMPILE_CMD = "compile"
BUILD_CMD = "build"
PREVIEW_CMD = "preview"
APPLY_CMD = "apply"
NO_STYLE_FLAG = "--no-style"
Expand Down
2 changes: 1 addition & 1 deletion hack/test_correctness.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_correctness(stack_dir):
print(f"Ignore stack {stack_dir}.")
return
print(f"Test correctness of stack {stack_dir}...")
cmd = [KUSION_CMD, COMPILE_CMD]
cmd = [KUSION_CMD, BUILD_CMD]
process = subprocess.run(
cmd, capture_output=True, cwd=Path(stack_dir), env=dict(os.environ)
)
Expand Down

0 comments on commit 0e74448

Please sign in to comment.