Skip to content

Commit

Permalink
feat: add database accessory and update helloworld sample
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-hm19 committed Aug 4, 2023
1 parent efe1e4a commit 04a24f0
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
8 changes: 8 additions & 0 deletions models/samples/helloworld/base/base.k
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import models.schema.v1 as ac
import models.schema.v1.component as cmp
import models.schema.v1.component.container as c
import models.schema.v1.accessories.database as db

# base.k declares reuseable configurations for all stacks.

Expand All @@ -25,6 +26,13 @@ appConfiguration: ac.AppConfiguration {
workingDir: "/tmp"
}
}
database: db.Database {
type: "aws"
engine: "mysql"
version: "5.7"
instanceType: "db.t3.micro"
accessInternet: True
}
}
}
}
67 changes: 67 additions & 0 deletions models/schema/v1/accessories/database.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
schema Database:
""" Database defines the delivery artifact of relational database service
(rds) provided by a specified cloud vendor for the application.

Attributes
----------
type: str, default is Undefined, required.
Type defines the specific cloud vendor that provides the rds.
engine: str, default is Undefined, required.
Engine defines the database engine to use.
version: str, default is Undefined, required.
Version defines the database engine version to use.
instanceType: str, default is Undefined, required.
InstanceType defines the type of the rds instance.
size: int, default is 10, optional.
Size defines the allocated storage size of the rds instance in GB.
category: str, default is "Basic", optional.
Category defines the edition of the rds instance.
username: str, default is "root", optional.
Username defines the operation account for the rds instance.
securityIPs: [str], default is ["0.0.0.0/0"], optional.
SecurityIPs defines the list of IP addresses allowed to access the
rds instance.
accessInternet: bool, default is False, optional.
AccessInternet defines whether the rds instance is publicly accessible.

Examples
--------
Instantiate a publicly accessible aws rds with mysql 5.7.

import models.schema.v1.accessories.database as db

database: db.Database {
type: "aws"
engine: "mysql"
version: "5.7"
instanceType: "db.t3.micro"
accessInternet: True
}
"""

# The specific cloud vendor that provides the rds.
$type: str

# The database engine to use.
engine: str

# The database engine version to use.
version: str

# The type of the rds instance.
instanceType: str

# The allocated storage size of the rds instance in GB.
size?: int = 10

# The edition of the rds instance.
category?: str = "Basic"

# The operation account for the rds instance.
username?: str = "root"

# The list of IP addresses allowed to access the rds instance.
securityIPs?: [str] = ["0.0.0.0/0"]

# Whether the rds instance is publicly accessible.
accessInternet?: bool = False
2 changes: 2 additions & 0 deletions models/schema/v1/app_configuration.k
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ schema AppConfiguration:
}
"""

__settings__: {str:str} = {"output_type" = "STANDALONE"}

# Component defines the delivery artifact of one application.
# Each application can be composed by multiple components.
components?: {str:c.Component}
6 changes: 6 additions & 0 deletions models/schema/v1/component/component.k
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import models.schema.v1.component.container as c
import models.schema.v1.accessories.database as db

schema Component:
""" Component defines the delivery artifact of one application. Each component
Expand All @@ -11,6 +12,8 @@ schema Component:
More info: https://kubernetes.io/docs/concepts/containers
replicas: int, default is 2, required.
Number of container replicas that should be ran.
database: db.Database, default is Undefined, optional.
Database defines the relational database service provided by a specified cloud vendor.
labels: {str:str}, default is Undefined, optional.
Labels are key/value pairs that are attached to the component.
annotations: {str:str}, default is Undefined, optional.
Expand Down Expand Up @@ -41,6 +44,9 @@ schema Component:
replicas: int = 2

###### Other metadata info
# The relatioinal database service provided by a specified cloud vendor.
database?: db.Database

# Labels and annotations can be used to attach arbitrary metadata as key-value pairs to resources.
labels?: {str:str}
annotations?: {str:str}

0 comments on commit 04a24f0

Please sign in to comment.