-
Notifications
You must be signed in to change notification settings - Fork 70
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: add an example about the global-variables policy #95
Draft
barnettZQG
wants to merge
1
commit into
kubevela:master
Choose a base branch
from
barnettZQG:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,57 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: wordpress-config | ||
type: Opaque | ||
stringData: | ||
DB_DATABASE: wordpress | ||
DB_USER: wordpress | ||
DB_PASSWORD: wordpress-password | ||
DB_HOST: wordpress-db | ||
DB_PORT: 3306 | ||
WORDPRESS_USER: admin | ||
WORDPRESS_PASSWORD: admin-password | ||
--- | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: Application | ||
metadata: | ||
name: wordpress | ||
spec: | ||
policies: | ||
- type: global-variables | ||
properties: | ||
discover: | ||
secret: | ||
name: wordpress-config | ||
components: | ||
- name: wordpress-db | ||
type: helm | ||
properties: | ||
repoType: "helm" | ||
url: https://charts.bitnami.com/bitnami | ||
chart: mysql | ||
version: 9.2.0 | ||
values: | ||
auth: | ||
username: context.variables.DB_USER | ||
database: context.variables.DB_DATABASE | ||
password: context.variables.DB_PASSWORD | ||
- name: wordpress-server | ||
type: helm | ||
dependsOn: ["wordpress-db"] | ||
properties: | ||
repoType: "helm" | ||
url: "https://charts.bitnami.com/bitnami" | ||
chart: "wordpress" | ||
version: "1.0.0" | ||
values: | ||
wordpressUsername: context.variables.WORDPRESS_USER | ||
wordpressPassword: context.variables.WORDPRESS_PASSWORD | ||
externalDatabase: | ||
host: context.variables.DB_HOST | ||
port: context.variables.DB_PORT | ||
user: context.variables.DB_USER | ||
password: context.variables.DB_PASSWORD | ||
database: context.variables.DB_DATABASE | ||
|
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,59 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: wordpress-config | ||
type: Opaque | ||
stringData: | ||
DB_INSTANCE: wordpress | ||
DB_DATABASE: wordpress | ||
DB_USER: wordpress | ||
DB_PASSWORD: wordpress-password | ||
DB_PORT: 3306 | ||
WORDPRESS_USER: admin | ||
WORDPRESS_PASSWORD: admin-password | ||
--- | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: Application | ||
metadata: | ||
name: wordpress | ||
spec: | ||
policies: | ||
- type: global-variables | ||
properties: | ||
discover: | ||
secret: | ||
name: wordpress-config | ||
components: | ||
- name: wordpress-db | ||
type: alibaba-rds | ||
properties: | ||
instanceName: context.variables.DB_INSTANCE | ||
databaseName: context.variables.DB_DATABASE | ||
accountName: context.variables.DB_USER | ||
password: context.variables.DB_PASSWORD | ||
outputs: | ||
- name: wordpress-rds-address | ||
# We should copy the outputs info from the Configure to the Application status | ||
valueFrom: context.status.outputs.DB_HOST | ||
- name: wordpress-server | ||
type: helm | ||
dependsOn: ["wordpress-db"] | ||
inputs: | ||
- from: wordpress-rds-address | ||
parameterKey: properties.values.externalDatabase.host | ||
properties: | ||
repoType: "helm" | ||
url: "https://charts.bitnami.com/bitnami" | ||
chart: "wordpress" | ||
version: "1.0.0" | ||
values: | ||
wordpressUsername: context.variables.WORDPRESS_USER | ||
wordpressPassword: context.variables.WORDPRESS_PASSWORD | ||
externalDatabase: | ||
host: context.variables.DB_HOST | ||
port: context.variables.DB_PORT | ||
user: context.variables.DB_USER | ||
password: context.variables.DB_PASSWORD | ||
database: context.variables.DB_DATABASE | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个方案的核心问题是会把我们从 IaD 变成 IaC。 每个 value 都加入了 magic,需要计算一下,再render。
现在我们的 Application 是 IaD 的,每个数据都是固定的 data,不需要计算。 唯一需要计算的可能就是 output 里加入了一个 valueFrom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果要保留之前的机制,那就是通过 valueFrom 来设置参数获取和赋值。但是感觉写起来有点多余。因为不得不为 每个字段先写一个默认值。