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

chore: update simple-service and simple-job example #144

Closed
Closed
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
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
11 changes: 11 additions & 0 deletions example/nginx/dev/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "public-service"
edition = "0.5.0"
version = "0.1.0"

[dependencies]
# should update the tag!
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.0" }

[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
10 changes: 10 additions & 0 deletions example/nginx/dev/workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
modules:
port:
default:
type: alicloud
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-spec: slb.s1.small

runtimes:
kubernetes:
kubeconfig: /etc/kubeconfig.yaml # Replace with your own kubeconfig file path
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[package]
name = "sample-job"
name = "simple-job"
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"]

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
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# The stack basic info
name: prod
name: dev
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
Expand Up @@ -4,7 +4,7 @@ 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"
}
}
2 changes: 2 additions & 0 deletions example/simple-service/dev/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The stack basic info
name: dev
Loading