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: more example and docs #23

Merged
merged 2 commits into from
Sep 11, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__pycache__
__kclcache__
.kclvm

kcl.mod.lock

# test report
report/
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Konfig
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig?ref=badge_shield)

> Note: Sync from the [modules](https://github.com/kcl-lang/modules/tree/main/konfig) code repo.

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig?ref=badge_shield)

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

Expand Down Expand Up @@ -55,9 +57,13 @@ Install [KCL](https://kcl-lang.io/docs/user_docs/getting-started/install)

See [here](https://kcl-lang.io/docs/user_docs/guides/working-with-konfig/guide)

## Resources

- More examples can be found [here](https://github.com/kcl-lang/konfig/blob/main/examples/README.md)
- Konfig schema reference document can be found [here](https://github.com/kcl-lang/konfig/blob/main/docs/konfig.md)

## License

Apache License Version 2.0


[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig?ref=badge_large)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkcl-lang%2Fkonfig?ref=badge_large)
25 changes: 25 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Examples

```
.
├── README.md
├── appops # Some real and simple application examples
│ ├── guestbook
│ ├── http-echo
│ └── nginx-example
├── job # How to use the job schema to render Kubernetes specific resources
│ └── app_main_container
└── server # How to use the server schema to render Kubernetes specific resources
├── app_config_map
├── app_label_selector
├── app_main_container
├── app_need_namespace
├── app_rbac
├── app_scheduling_strategy
├── app_secret
├── app_service
├── app_sidecar
├── app_stateful_set
├── app_volume
└── extra_resources
```
13 changes: 0 additions & 13 deletions examples/appops/extra-resources-example/dev/kcl.mod.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/appops/extra-resources-example/kcl.mod.lock

This file was deleted.

4 changes: 2 additions & 2 deletions examples/appops/nginx-example/dev/kcl.mod.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
oci_tag = "1.28"
[dependencies.konfig]
name = "konfig"
full_name = "konfig_0.6.0"
version = "0.6.0"
full_name = "konfig_0.7.0"
version = "0.7.0"
4 changes: 2 additions & 2 deletions examples/appops/nginx-example/kcl.mod.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
oci_tag = "1.28"
[dependencies.konfig]
name = "konfig"
full_name = "konfig_0.6.0"
version = "0.6.0"
full_name = "konfig_0.7.0"
version = "0.7.0"
16 changes: 16 additions & 0 deletions examples/job/app_main_container/base/base.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import konfig.models.kube.frontend
import konfig.models.kube.frontend.container

# Application Configuration
appConfiguration: frontend.Job {
# Main Container Configuration
mainContainer = container.Main {
ports = [
{containerPort = 80}
]
env.MY_ENV: {
value = "MY_VALUE"
}
}
image = "nginx:1.7.8"
}
10 changes: 10 additions & 0 deletions examples/job/app_main_container/dev/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "app_main_container_dev"
version = "0.0.1"

[dependencies]
konfig = { path = "../../../../../konfig" }
k8s = "1.28"
[profile]
entries = ["../base/base.k", "main.k", "${konfig:KCL_MOD}/models/kube/render/render.k"]

8 changes: 8 additions & 0 deletions examples/job/app_main_container/dev/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import konfig.models.kube.frontend
import konfig.models.kube.templates.resource as res_tpl

# The application configuration in stack will overwrite
# the configuration with the same attribute in base.
appConfiguration: frontend.Job {
schedulingStrategy.resource = res_tpl.tiny
}
7 changes: 7 additions & 0 deletions examples/job/app_main_container/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "app_main_container"
version = "0.0.1"

[dependencies]
konfig = { path = "../../../../konfig" }
k8s = "1.28"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "nginx-example-dev"
name = "extra_resources_dev"
version = "0.0.1"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "nginx-example"
name = "extra_resources"
version = "0.0.1"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion kcl.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "konfig"
version = "0.7.0"
version = "0.8.0"

[dependencies]
k8s = "1.28"
7 changes: 7 additions & 0 deletions models/kube/frontend/job.k
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ schema Job:

Attributes
----------
name: str, default is Undefined, optional.
The name of the workload and service.
If not defined, a generated name ("{__META_APP_NAME}-{__META_ENV_TYPE_NAME}") will be used.
The value of metadata.__META_APP_NAME will be extracted from the value of the "name" defined through option("app"),
and the value of __META_ENV_TYPE_NAME will be extracted from the value of the "name" defined through option("env").
activeDeadlineSeconds: int, default is Undefined, optional.
Specifies the duration in seconds relative to the startTime that the job may be active
before the system tries to terminate it; value must be positive integer
Expand Down Expand Up @@ -80,6 +85,8 @@ schema Job:
}
"""

# job name
name?: str
# subset of batchv1.JobSpec
activeDeadlineSeconds?: int
backoffLimit?: int = 6
Expand Down
4 changes: 2 additions & 2 deletions models/kube/frontend/server.k
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ schema Server:
name: str, default is Undefined, optional.
The name of the workload and service.
If not defined, a generated name ("{__META_APP_NAME}-{__META_ENV_TYPE_NAME}") will be used.
The value of __META_APP_NAME will be extracted from the value of the "name" defined in project.yaml,
and the value of __META_ENV_TYPE_NAME will be extracted from the value of the "name" defined in stack.yaml.
The value of metadata.__META_APP_NAME will be extracted from the value of the "name" defined through option("app"),
and the value of __META_ENV_TYPE_NAME will be extracted from the value of the "name" defined through option("env").
workloadType: "Deployment" | "StatefulSet", default is "Deployment", required.
Application workload type, default to 'Deployment'
renderType: "Server" | "KubeVelaApplication", default is "Server", optional.
Expand Down
Loading