Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: merge develop-0.10.0 into main #153

Merged
merged 14 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/main.yml → .github/workflows/deploy/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: "Deploy"

on:
pull_request:
branches:
- main
push:
branches:
- main
Expand All @@ -18,6 +17,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Pytest Html
run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- name: Git Diff
id: git-diff
uses: technote-space/get-diff-action@v6
Expand Down Expand Up @@ -77,6 +78,7 @@ jobs:
- name: Test Correctness
env:
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
WORKSPACE_FILE_DIR: workspaces
run: python3 -m pytest -v hack/test_correctness.py --junitxml ./hack/report/test-correctness.xml --html ./hack/report/test-correctness.html
- name: Upload Report
if: always()
Expand All @@ -101,12 +103,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Pytest Html
run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- name: Setup K3d&K3s
uses: nolar/setup-k3d-k3s@v1
- name: Preview
id: preview
env:
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
WORKSPACE_FILE_DIR: workspaces
run: |
#edit the profile in the post step does not work, source kusion env file manually
source "$HOME/.kusion/.env"
Expand All @@ -132,12 +137,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Pytest Html
run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- name: Setup K3d&K3s
uses: nolar/setup-k3d-k3s@v1
- name: Apply
id: apply
env:
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
WORKSPACE_FILE_DIR: workspaces
run: |
#edit the profile in the post step does not work, source kusion env file manually
source "$HOME/.kusion/.env"
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ kusion_state.json

changed_list.txt

*.lock
*#.lock

# kusion state
kusion_state.yaml
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# 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)

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).
konfig 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're new to Kusion, it's a good idea to start by [Getting Started](https://www.kusionstack.io/docs/kusion/getting-started/install-kusion), which includes quickstart installation, guided tutorials and deployment instructions. Then you can go to [User Guides](https://www.kusionstack.io/docs) to find more Kusion practical application scenarios, and konfig holds the corresponding examples of the user guides.

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.
## konfig examples

All guided tutorials use applications in this repository, located in the `example` directory.

## Deploying Examples

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.
| name | description |user guide|
|----------------------------------------------------|--------------------------------------------------------------------------------|----------|
| [nginx](example/nginx) | An exposing nginx service. |[Expose Application Service Deployed on CSP Kubernetes](https://www.kusionstack.io/docs/kusion/user-guides/cloud-resources/expose-service)|
| [simple-job](example/simple-job) | An one-off or recurring execution task. |[Schedule a Job](https://www.kusionstack.io/docs/kusion/user-guides/working-with-k8s/job)|
| [service-multi-stack](example/service-multi-stack) | A project which contains multiple stacks. |[Deploy Application Securely and Efficiently via GitHub Actions](https://www.kusionstack.io/docs/kusion/user-guides/github-actions/deploy-application-via-github-actions)|
| [simple-service](example/simple-service) | A simple service only contains workload resources. |[Deploy Application](https://www.kusionstack.io/docs/kusion/user-guides/working-with-k8s/deploy-application)|
| [wordpress-cloud-rds](example/wordpress-cloud-rds) | The wordpress application which contains workload and cloud database resource. |[Deliver the WordPress Application with Cloud RDS](https://www.kusionstack.io/docs/next/kusion/user-guides/cloud-resources/database)|
| [wordpress-local-db](example/wordpress-lcoal-db) | The wordpress application which contains workload and local database resource. |[Deliver the WordPress Application on Kubernetes](https://www.kusionstack.io/docs/kusion/getting-started/deliver-wordpress)|
6 changes: 3 additions & 3 deletions example/sample-job/prod/kcl.mod → example/nginx/dev/kcl.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "sample-job"
edition = "0.1.0"
name = "nginx"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.1" }
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }

[profile]
entries = ["main.k"]

15 changes: 10 additions & 5 deletions example/simple-service/prod/main.k → example/nginx/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
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

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

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.0" }
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }

[profile]
entries = ["../base/base.k", "main.k"]

5 changes: 2 additions & 3 deletions example/service-multi-stack/prod/kcl.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[package]
name = "service-multi-stack"
edition = "0.5.0"
name = "service-multi-stack-prod"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.0" }
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }

[profile]
entries = ["../base/base.k", "main.k"]
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[package]
name = "wordpress"
edition = "0.5.0"
name = "simple-job"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.0" }
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }

[profile]
entries = ["main.k","platform.k"]
entries = ["main.k"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 {
helloworld: ac.AppConfiguration {
workload: wl.Job {
containers: {
"busybox": c.Container {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The project basic info
name: sample-job
name: simple-job
generator:
type: AppConfiguration
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "simple-service"
edition = "0.1.0"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.1" }
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }

[profile]
entries = ["main.k"]

48 changes: 48 additions & 0 deletions example/simple-service/dev/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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.container.probe as p
import catalog.models.schema.v1.workload.network as n
import catalog.models.schema.v1.monitoring as m
import catalog.models.schema.v1.trait as t

helloworld: ac.AppConfiguration {
workload: wl.Service {
containers: {
"helloworld": c.Container {
image: "gcr.io/google-samples/gb-frontend:v4"
env: {
"env1": "VALUE"
"env2": "VALUE2"
}
resources: {
"cpu": "500m"
"memory": "512M"
}
# Configure an HTTP readiness probe
readinessProbe: p.Probe {
probeHandler: p.Http {
url: "http://localhost:80"
}
initialDelaySeconds: 10
}
}
}
replicas: 2
# Comment the following block to un-expose service
ports: [
n.Port {
port: 8080
targetPort: 80
}
]
}
# Comment the following block to remove opsRule
opsRule: t.OpsRule {
maxUnavailable: "30%"
}
# Comment the following block to disable monitoring
monitoring: m.Prometheus{
path: "/metrics"
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# The stack basic info
name: prod
name: dev
10 changes: 10 additions & 0 deletions example/wordpress-cloud-rds/prod/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "wordpress-cloud-rds"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }

[profile]
entries = ["main.k"]

38 changes: 38 additions & 0 deletions example/wordpress-cloud-rds/prod/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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
import catalog.models.schema.v1.accessories.mysql

# main.k declares customized configurations for prod stacks.
wordpress: ac.AppConfiguration {
workload: wl.Service {
containers: {
wordpress: c.Container {
image: "wordpress:6.3"
env: {
"WORDPRESS_DB_HOST": "$(KUSION_DB_HOST_WORDPRESS_MYSQL)"
"WORDPRESS_DB_USER": "$(KUSION_DB_USERNAME_WORDPRESS_MYSQL)"
"WORDPRESS_DB_PASSWORD": "$(KUSION_DB_PASSWORD_WORDPRESS_MYSQL)"
"WORDPRESS_DB_NAME": "mysql"
}
resources: {
"cpu": "500m"
"memory": "512Mi"
}
}
}
replicas: 1
ports: [
n.Port {
port: 80
}
]
}
database: {
wordpress: mysql.MySQL {
type: "cloud"
version: "8.0"
}
}
}
2 changes: 2 additions & 0 deletions example/wordpress-cloud-rds/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: wordpress
name: wordpress-cloud-rds
generator:
type: AppConfiguration
10 changes: 10 additions & 0 deletions example/wordpress-local-db/prod/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "wordpress-local-db"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }

[profile]
entries = ["main.k"]

34 changes: 34 additions & 0 deletions example/wordpress-local-db/prod/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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
import catalog.models.schema.v1.accessories.mysql

# main.k declares customized configurations for prod stack.
wordpress: ac.AppConfiguration {
workload: wl.Service {
containers: {
wordpress: c.Container {
image: "wordpress:6.3"
env: {
"WORDPRESS_DB_HOST": "$(KUSION_DB_HOST_WORDPRESS_MYSQL)"
"WORDPRESS_DB_USER": "$(KUSION_DB_USERNAME_WORDPRESS_MYSQL)"
"WORDPRESS_DB_PASSWORD": "$(KUSION_DB_PASSWORD_WORDPRESS_MYSQL)"
"WORDPRESS_DB_NAME": "mysql"
}
}
}
replicas: 1
ports: [
n.Port {
port: 80
}
]
}
database: {
wordpress: mysql.MySQL {
type: "local"
version: "8.0"
}
}
}
2 changes: 2 additions & 0 deletions example/wordpress-local-db/prod/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The stack basic info
name: prod
4 changes: 4 additions & 0 deletions example/wordpress-local-db/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The project basic info
name: wordpress-local-db
generator:
type: AppConfiguration
Loading