Service binding trait will bind data from Kubernetes
Secret to the application container's ENV.
service-bindingtrait is hidden by default in
VelaUX, you can use it in CLI.
- Prepare a Kubernetes Secret
The secret can be manually created, or generated by other component or external system.
For example, we have a secret
db-conn-example whose data is as below:
- Bind the Secret into your component by
For example, we have a webservice component who needs to consume a database. The database connection string should be set
to Pod environments:
We can set the properties for envMappings as below. For each environment,
secret represents the secret name, and
represents the key of the secret.
Here is the complete properties for the trait.
In particular, if the environment name, like
endpoint, is same to the
key of the secret, we can omit the
So we can simplify the properties as below.
We can finally prepare an Application for the business component
binding-test-comp to consume the secret, which is a
representative of a database cloud resource.
Deploy this YAML and the Secret
db-conn-example will be binding into environment of workload.
|envMappings||The mapping of environment variables to secret||map[string]#KeySecret||true|
|key||if key is empty, we will use envMappings key instead||string||false|
|secret||Kubernetes secret name||string||true|