Skip to content

Commit

Permalink
docs: update examples to reflect kusion modules (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffforest authored Mar 28, 2024
1 parent e8671c4 commit a6e8836
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 78 deletions.
3 changes: 2 additions & 1 deletion example/nginx/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "nginx"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }

[profile]
entries = ["main.k"]
Expand Down
26 changes: 15 additions & 11 deletions example/nginx/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,7 +1,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
import catalog.models.schema.v1.workload.network as n
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import network as n

nginx: ac.AppConfiguration {
workload: wl.Service {
Expand All @@ -15,12 +15,16 @@ nginx: ac.AppConfiguration {
}
}
replicas: 1
ports: [
n.Port {
port: 80
protocol: "TCP"
public: True
}
]
}
accessories: {
"network": n.Network {
ports: [
n.Port {
port: 80
protocol: "TCP"
public: True
}
]
}
}
}
22 changes: 13 additions & 9 deletions example/service-multi-stack/base/base.k
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import catalog.models.schema.v1 as ac
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
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import network as n

echoserver: ac.AppConfiguration {
workload: wl.Service {
Expand All @@ -15,10 +15,14 @@ echoserver: ac.AppConfiguration {
}
}
replicas: 1
ports: [
n.Port {
port: 80
}
]
}
accessories: {
"network": n.Network {
ports: [
n.Port {
port: 80
}
]
}
}
}
3 changes: 2 additions & 1 deletion example/service-multi-stack/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "service-multi-stack-dev"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }

[profile]
entries = ["../base/base.k", "main.k"]
Expand Down
2 changes: 1 addition & 1 deletion example/service-multi-stack/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import catalog.models.schema.v1 as ac
import kam.v1.app_configuration as ac

# main.k declares customized configurations for dev stack.
echoserver: ac.AppConfiguration {
Expand Down
4 changes: 3 additions & 1 deletion example/service-multi-stack/prod/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name = "service-multi-stack-prod"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }

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

2 changes: 1 addition & 1 deletion example/service-multi-stack/prod/main.k
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import catalog.models.schema.v1 as ac
import kam.v1.app_configuration as ac

# main.k declares customized configurations for prod stack.
echoserver: ac.AppConfiguration {
Expand Down
3 changes: 2 additions & 1 deletion example/simple-job/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "simple-job"
version = "0.1.0"

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

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

6 changes: 3 additions & 3 deletions example/simple-job/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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 kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c

helloworld: ac.AppConfiguration {
workload: wl.Job {
Expand Down
5 changes: 4 additions & 1 deletion example/simple-service/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ name = "simple-service"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }
opsrule = { oci = "oci://ghcr.io/kusionstack/opsrule", tag = "0.1.0" }
monitoring = { oci = "oci://ghcr.io/kusionstack/monitoring", tag = "0.1.0" }

[profile]
entries = ["main.k"]
Expand Down
43 changes: 22 additions & 21 deletions example/simple-service/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import kam.v1.workload.container.probe as p
import monitoring as m
import opsrule as o
import network as n

helloworld: ac.AppConfiguration {
workload: wl.Service {
Expand All @@ -29,20 +29,21 @@ helloworld: ac.AppConfiguration {
}
}
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"
accessories: {
"network": n.Network {
ports: [
n.Port {
port: 8080
targetPort: 80
}
]
}
"monitoring": m.Prometheus {
path: "/metrics"
}
"opsRule": o.OpsRule {
maxUnavailable: "30%"
}
}
}
4 changes: 3 additions & 1 deletion example/wordpress-cloud-rds/prod/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name = "wordpress-cloud-rds"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }
mysql = { oci = "oci://ghcr.io/kusionstack/mysql", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }

[profile]
entries = ["main.k"]
Expand Down
26 changes: 14 additions & 12 deletions example/wordpress-cloud-rds/prod/main.k
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import network as n
import mysql as m

# main.k declares customized configurations for prod stacks.
wordpress: ac.AppConfiguration {
Expand All @@ -23,14 +23,16 @@ wordpress: ac.AppConfiguration {
}
}
replicas: 1
ports: [
n.Port {
port: 80
}
]
}
database: {
wordpress: mysql.MySQL {
accessories: {
"network": n.Network {
ports: [
n.Port {
port: 80
}
]
}
"mysql": m.MySQL {
type: "cloud"
version: "8.0"
}
Expand Down
4 changes: 3 additions & 1 deletion example/wordpress-local-db/prod/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name = "wordpress-local-db"
version = "0.1.0"

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag = "0.1.2" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }
mysql = { oci = "oci://ghcr.io/kusionstack/mysql", tag = "0.1.0" }

[profile]
entries = ["main.k"]
Expand Down
28 changes: 15 additions & 13 deletions example/wordpress-local-db/prod/main.k
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import network as n
import mysql as m

# main.k declares customized configurations for prod stack.
wordpress: ac.AppConfiguration {
Expand All @@ -19,15 +19,17 @@ wordpress: ac.AppConfiguration {
}
}
replicas: 1
ports: [
n.Port {
port: 80
}
]
}
database: {
wordpress: mysql.MySQL {
type: "local"
accessories: {
"network": n.Network {
ports: [
n.Port {
port: 80
}
]
}
"mysql": m.MySQL {
type: "local"
version: "8.0"
}
}
Expand Down

0 comments on commit a6e8836

Please sign in to comment.