-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update database accessory and related samples (#43)
<!-- Thank you for contributing to Catalog! Note: 1. With pull requests: - Open your pull request against "mainb - Your pull request should have no more than three commits, if not you should squash them. - It should pass all tests in the available continuous integration systems such as GitHub Actions. - You should add/modify tests to cover your proposed code changes. - If your pull request contains a new feature, please document it on the README. 2. Please create an issue first to describe the problem. We recommend that link the issue with the PR in the following question. For more info, check https://kusionstack.io/docs/governance/contribute/ --> ## What type of PR is this? <!-- Add one of the following kinds: /kind bug /kind cleanup /kind documentation /kind feature /kind chore --> /kind feature ## What this PR does / why we need it: This PR refactors the database accessory model and updates related samples. ## Which issue(s) this PR fixes: <!-- *Automatically closes linked issue when PR is merged. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_* --> Fixes # ## Special notes for your reviewer: ### Does this PR introduce a user-facing change? <!-- If no, just write "NONE" in the release-note block below. If yes, a release note is required: Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". --> ```release-note ``` ### Additional documentation e.g., design docs, usage docs, etc.: <!-- Please use the following format for linking documentation: - [Design]: <link> - [Usage]: <link> - [Other doc]: <link> --> ```docs ```
- Loading branch information
Showing
11 changed files
with
172 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import models.schema.v1 as ac | ||
import models.schema.v1.workload as wl | ||
import models.schema.v1.workload.container as c | ||
import models.schema.v1.workload.network as n | ||
import models.schema.v1.accessories.postgres | ||
import models.schema.v1.workload.secret as sec | ||
|
||
# base.k declares reusable configurations for all stacks. | ||
pgadmin: ac.AppConfiguration { | ||
workload: wl.Service { | ||
containers: { | ||
pgadmin: c.Container { | ||
image: "dpage/pgadmin4:latest" | ||
env: { | ||
"PGADMIN_DEFAULT_EMAIL": "[email protected]" | ||
"PGADMIN_DEFAULT_PASSWORD": "secret://pgadmin-secret/pgadmin-default-password" | ||
"PGADMIN_PORT": "80" | ||
} | ||
resources = { | ||
"cpu": "500m" | ||
"memory": "512Mi" | ||
} | ||
} | ||
} | ||
secrets: { | ||
"pgadmin-secret": sec.Secret { | ||
type: "opaque" | ||
data: { | ||
"pgadmin-default-password": "*******" | ||
} | ||
} | ||
} | ||
replicas: 1 | ||
ports: [ | ||
n.Port { | ||
port: 80 | ||
} | ||
] | ||
} | ||
database: { | ||
pgadmin: postgres.PostgreSQL { | ||
type: "cloud" | ||
version: "14.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kcl_cli_configs: | ||
file: | ||
- ../base/base.k | ||
- ./main.k | ||
disable_none: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import models.schema.v1 as ac | ||
|
||
# main.k declares customized configurations for prod stack. | ||
|
||
pgadmin: ac.AppConfiguration { | ||
workload.containers.pgadmin: { | ||
# prod stack has different image | ||
image = "dpage/pgadmin4:8.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name: prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: pgadmin | ||
generator: | ||
type: AppConfiguration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
import models.schema.v1 as ac | ||
import models.schema.v1.workload as wl | ||
import models.schema.v1.workload.container as c | ||
import models.schema.v1.workload.network as n | ||
import models.schema.v1.accessories.mysql | ||
|
||
# main.k declares customized configurations for prod stack. | ||
|
||
wordpress: ac.AppConfiguration { | ||
workload.containers.wordpress: { | ||
# prod stack has different image | ||
image = "wordpress:4.8-apache" | ||
workload: wl.Service { | ||
containers: { | ||
wordpress: c.Container { | ||
image = "wordpress:6.3" | ||
env = { | ||
"WORDPRESS_DB_HOST": "$(KUSION_DB_HOST_WORDPRESS)" | ||
"WORDPRESS_DB_USER": "$(KUSION_DB_USERNAME_WORDPRESS)" | ||
"WORDPRESS_DB_PASSWORD": "$(KUSION_DB_PASSWORD_WORDPRESS)" | ||
"WORDPRESS_DB_NAME": "mysql" | ||
} | ||
resources = { | ||
"cpu": "500m" | ||
"memory": "512Mi" | ||
} | ||
} | ||
} | ||
replicas = 1 | ||
ports = [ | ||
n.Port { | ||
port: 80 | ||
} | ||
] | ||
} | ||
database = { | ||
wordpress: mysql.MySQL { | ||
type: "cloud" | ||
version: "8.0" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
schema MySQL: | ||
""" MySQL describes the attributes to locally deploy or create a cloud provider | ||
managed mysql database instance for the workload. | ||
|
||
Attributes | ||
---------- | ||
type: "local" | "cloud", defaults to Undefined, required. | ||
Type defines whether the mysql database is deployed locally or provided by | ||
cloud vendor. | ||
version: str, defaults to Undefined, required. | ||
Version defines the mysql version to use. | ||
|
||
Examples | ||
-------- | ||
Instantiate a local mysql database with version of 5.7. | ||
|
||
import models.schema.v1.accessories.mysql | ||
|
||
mysql: mysql.MySQL { | ||
type: "local" | ||
version: "5.7" | ||
} | ||
""" | ||
|
||
# The deployment mode of the mysql database. | ||
type: "local" | "cloud" | ||
|
||
# The mysql database version to use. | ||
version: str | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
schema PostgreSQL: | ||
""" PostgreSQL describes the attributes to locally deploy or create a cloud provider | ||
managed postgresql database instance for the workload. | ||
|
||
Attributes | ||
---------- | ||
type: "local" | "cloud", defaults to Undefined, required. | ||
Type defines whether the postgresql database is deployed locally or provided by | ||
cloud vendor. | ||
version: str, defaults to Undefined, required. | ||
Version defines the mysql version to use. | ||
|
||
Examples | ||
-------- | ||
Instantiate a local postgresql database with image version of 14.0. | ||
|
||
import models.schema.v1.accessories.postgres | ||
|
||
postgres: postgres.PostgreSQL { | ||
type: "local" | ||
version: "14.0" | ||
} | ||
""" | ||
|
||
# The deployment mode of the postgresql database. | ||
type: "local" | "cloud" | ||
|
||
# The postgresql database version to use. | ||
version: str | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters