Built-in Trait Type
This documentation will walk through the built-in traits.
#
gatewayThe gateway
trait exposes a component to public Internet via a valid domain.
#
Apply To Component Types- all component types
#
ParametersNAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
---|---|---|---|---|
http | Specify the mapping relationship between the http path and the workload port | map[string]int | true | |
class | Specify the class of ingress to use | string | true | nginx |
classInSpec | Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation. | bool | false | false |
domain | Specify the domain you want to expose | string | true |
#
Examples#
rolloutRollout Trait performs a rolling update on Component.
#
Apply To Component Types- webservice
- worker
- clonset
#
ParametersName | Description | Type | Required | Default |
---|---|---|---|---|
targetRevision | The target ComponentRevision | string | No | If this field is empty, it will always point to the latest revision |
targetSize | Number of target Workload's replicas | int | Yes | Nil |
rolloutBatches | Strategy of rolling update | []rolloutBatch | Yes | Nil |
batchPartition | Partition of rolloutBatches | int | No | Nil, if this field is empty, all batches will be updated |
Configurations of rolloutBatch
Name | Description | Type | Required | Default |
---|---|---|---|---|
replicas | number of replicas in one batch | int | Yes | Nil |
#
Examples#
ScalerThe scaler
trait allows you to change the replicas for the component.
#
Apply To Component Types- webservice
- worker
- task
#
Parameters#
Examples#
AutoScalerautoscaler
trait use K8s HPA to control the replica of component.
Note:
autoscaler
trait is hidden by default inVelaUX
, you can use it in CLI.
#
Apply To Component Types- All component based on
deployments.apps
#
ParametersNAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
---|---|---|---|---|
min | Specify the minimal number of replicas to which the autoscaler can scale down | int | true | 1 |
max | Specify the maximum number of of replicas to which the autoscaler can scale up | int | true | 10 |
cpuUtil | Specify the average cpu utilization, for example, 50 means the CPU usage is 50% | int | true | 50 |
#
Examples#
StorageThe storage
trait allows you to manage storages for the component.
storage
can help us create and bind storages like pvc
, emptyDir
, secret
, or configMap
for our component. For secret
and configMap
type storage, we can also bind it to the env
.
If you don't want to create the storages automatically, you can set
mountOnly
to true.
#
Apply To Component Types- All component based on
deployments.apps
#
Parameters#
Examples#
Labelslabels
trait allow us to mark labels on Pod for workload.
Note:
labels
trait are hidden by default inVelaUX
, you can use them in CLI.
#
Apply To Component Types- all component types
#
ParametersThey're all string Key-Value pairs.
#
Examples#
Annotationsannotations
trait allow us to mark annotations on Pod for workload.
Note:
annotations
trait are hidden by default inVelaUX
, you can use them in CLI.
#
Apply To Component Types- all component types
#
ParametersThey're all string Key-Value pairs.
#
Examples#
kustomize-patchTrait kustomize-patch
will patch on the Kustomize component.
Note: To use
kustomize
trait, you must enablefluxcd
addon first.
#
Apply To Component Types- kustomize
#
Parameters#
ExamplesIn this example, the kustomize-patch
will patch the content for all Pods with label app=podinfo
.
#
kustomize-json-patchYou could use this trait in JSON6902 format to patch for the kustomize component.
#
Apply To Component Types- kustomize
#
Parameters#
Examples#
kustomize-strategy-mergekustomize-strategy-merge trait provide strategy merge patch for kustomize component.
#
Apply To Component Types- kustomize
#
Parameters#
Examples#
service-bindingService binding trait will bind data from Kubernetes Secret
to the application container's ENV.
#
Apply To Component Types- webservice
- worker
- task
- cron-task
#
ParametersName | 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 |
#
Examples- 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.
#
sidecarThe sidecar
trait allows you to attach a sidecar container to the component.
#
Apply To Component Types- webservice
- worker
- task
- cron-task