Skip to content

Commit

Permalink
feat: add KubernetesMetadata extensions and reorg schema directory
Browse files Browse the repository at this point in the history
  • Loading branch information
adohe committed Apr 17, 2024
1 parent c56fa27 commit dbefd74
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 355 deletions.
26 changes: 10 additions & 16 deletions v1/app_configuration.k → core/v1/app_configuration.k
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import v1.workload as wl
import extensions.v1 as extv1

schema AppConfiguration:
""" AppConfiguration is a developer-centric definition that describes how to run an Application.
Expand All @@ -7,28 +7,24 @@ schema AppConfiguration:

Attributes
----------
workload: wl.Service | wl.Job, default is Undefined, required.
workload: Service | Job, default is Undefined, required.
Workload defines how to run your application code. Currently supported workload profile
includes Service and Job.
accessories: {str:any}, default is Undefined, optional.
Accessories defines a collection of accessories that will be attached to the workload.
labels: {str:str}, default is Undefined, optional.
extensions: [extv1.KubernetesMetadata], default is Undefined, optional.
Labels can be used to attach arbitrary metadata as key-value pairs to resources.
annotations: {str:str}, default is Undefined, optional.
Annotations are key/value pairs that attach arbitrary non-identifying metadata to resources.

Examples
--------
# Instantiate an App with a long-running service and its image is "nginx:v1"

import kam as ac
import kam.workload as wl
import kam.workload.container as c
import kam.core.v1 as v1

helloworld : ac.AppConfiguration {
workload: wl.Service {
helloworld : v1.AppConfiguration {
workload: v1.Service {
containers: {
"nginx": c.Container {
"nginx": v1.Container {
image: "nginx:v1"
}
}
Expand All @@ -37,12 +33,10 @@ schema AppConfiguration:
"""

# Workload defines how to run your application code.
workload: wl.Service | wl.Job
workload: Service | Job

# Accessories defines a collection of accessories that will be attached to the workload.
accessories?: {str:any}
accessories?: {str:any}

###### Other metadata info
# Labels and annotations can be used to attach arbitrary metadata as key-value pairs to resources.
labels?: {str:str}
annotations?: {str:str}
extensions?: [extv1.KubernetesMetadata]
18 changes: 8 additions & 10 deletions v1/workload/common.k → core/v1/common.k
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import v1.workload.container as c
import v1.workload.secret as sec

schema WorkloadBase:
""" WorkloadBase defines set of attributes shared by different workload profile, e.g Service
and Job. You can inherit this Schema to reuse these common attributes.
Expand All @@ -15,21 +12,22 @@ schema WorkloadBase:
replicas: int, optional.
Number of container replicas based on this configuration that should be ran.
labels: {str:str}, default is Undefined, optional.
Labels are key/value pairs that are attached to the workload.
The labels to set on target Kubernetes Workload resource.
annotations: {str:str}, default is Undefined, optional.
Annotations are key/value pairs that attach arbitrary non-identifying metadata to the workload.
The annotations to set on target Kubernetes Workload resource.
"""

# The templates of containers to be ran.
containers: {str:c.Container}
containers: {str:Container}

# Secrets store small amount of sensitive data e.g. a password, a token, or a key.
secrets?: {str:sec.Secret}
secrets?: {str:Secret}

# The number of containers that should be ran.
replicas?: int
replicas?: int

###### Other metadata info
# Labels and annotations can be used to attach arbitrary metadata as key-value pairs to resources.
# The labels to set on target Kubernetes Workload resource.
labels?: {str:str}

# The annotations to set on target Kubernetes Workload resource.
annotations?: {str:str}
Loading

0 comments on commit dbefd74

Please sign in to comment.