Service Binding
Service binding trait will bind data from Kubernetes Secret
to the application container's ENV.
Note:
service-binding
trait is hidden by default inVelaUX
, you can use it in CLI.
#
How to use- 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
service-binding
trait
For example, we have a webservice component who needs to consume a database. The database connection string should be set
to Pod environments: endpoint
, username
and DB_PASSWORD
.
We can set the properties for envMappings as below. For each environment, secret
represents the secret name, and key
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 key
.
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.
#
Specification#
PropertiesName | Description | Type | Required | Default |
---|---|---|---|---|
envMappings | The mapping of environment variables to secret | map[string]#KeySecret | true |
#
KeySecretName | Description | Type | Required | Default |
---|---|---|---|---|
key | if key is empty, we will use envMappings key instead | string | false | |
secret | Kubernetes secret name | string | true |