Version: v1.0
Cloud Services
KubeVela allows you to declare cloud services your application needs in consistent API. Currently, we support both Terraform and Crossplane.
Please check the platform team guide for cloud services if you are interested in how these capabilities are maintained in KubeVela.
The cloud services will be consumed by the application via Service Binding Trait.
Terraform
⚠️ This section assumes Terraform related capabilities have been installed in your platform.
Check the parameters of cloud resource components and trait.
$ kubectl vela show alibaba-rds# Properties+----------------------------+-------------------------------------------------------------------------+-----------------------------------------------------------+----------+---------+| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |+----------------------------+-------------------------------------------------------------------------+-----------------------------------------------------------+----------+---------+| bucket | OSS bucket name | string | true | || acl | OSS bucket ACL, supported 'private', 'public-read', 'public-read-write' | string | true | || writeConnectionSecretToRef | The secret which the cloud resource connection will be written to | [writeConnectionSecretToRef](#writeConnectionSecretToRef) | false | |+----------------------------+-------------------------------------------------------------------------+-----------------------------------------------------------+----------+---------+## writeConnectionSecretToRef+-----------+-----------------------------------------------------------------------------+--------+----------+---------+| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |+-----------+-----------------------------------------------------------------------------+--------+----------+---------+| name | The secret name which the cloud resource connection will be written to | string | true | || namespace | The secret namespace which the cloud resource connection will be written to | string | false | |+-----------+-----------------------------------------------------------------------------+--------+----------+---------+$ kubectl vela show service-binding# Properties+-------------+------------------------------------------------+------------------+----------+---------+| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |+-------------+------------------------------------------------+------------------+----------+---------+| envMappings | The mapping of environment variables to secret | map[string]{...} | true | |+-------------+------------------------------------------------+------------------+----------+---------+
Alibaba Cloud RDS and OSS
A sample application is as below.
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: webappspec:components:- name: express-servertype: webserviceproperties:image: zzxwill/flask-web-application:v0.3.1-crossplaneports: 80traits:- type: service-bindingproperties:envMappings:# environments refer to db-conn secretDB_PASSWORD:secret: db-conn # 1) If the env name is the same as the secret key, secret key can be omitted.endpoint:secret: db-connkey: DB_HOST # 2) If the env name is different from secret key, secret key has to be set.username:secret: db-connkey: DB_USER# environments refer to oss-conn secretBUCKET_NAME:secret: oss-conn- name: sample-dbtype: alibaba-rdsproperties:instance_name: sample-dbaccount_name: oamtestpassword: U34rfwefwefffakedwriteConnectionSecretToRef:name: db-conn- name: sample-osstype: alibaba-ossproperties:bucket: vela-websiteacl: privatewriteConnectionSecretToRef:name: oss-conn
Crossplane
⚠️ This section assumes Crossplane related capabilities have been installed in your platform.
Alibaba Cloud RDS and OSS
Check the parameters of cloud service component:
$ kubectl vela show alibaba-rds# Properties+---------------+------------------------------------------------+--------+----------+--------------------+| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |+---------------+------------------------------------------------+--------+----------+--------------------+| engine | RDS engine | string | true | mysql || engineVersion | The version of RDS engine | string | true | 8.0 || instanceClass | The instance class for the RDS | string | true | rds.mysql.c1.large || username | RDS username | string | true | || secretName | Secret name which RDS connection will write to | string | true | |+---------------+------------------------------------------------+--------+----------+--------------------+
A sample application is as below.
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: webappspec:components:- name: express-servertype: webserviceproperties:image: zzxwill/flask-web-application:v0.3.1-crossplaneports: 80traits:- type: service-bindingproperties:envMappings:# environments refer to db-conn secretDB_PASSWORD:secret: db-connkey: password # 1) If the env name is different from secret key, secret key has to be set.endpoint:secret: db-conn # 2) If the env name is the same as the secret key, secret key can be omitted.username:secret: db-conn# environments refer to oss-conn secretBUCKET_NAME:secret: oss-connkey: Bucket- name: sample-dbtype: alibaba-rdsproperties:name: sample-dbengine: mysqlengineVersion: "8.0"instanceClass: rds.mysql.c1.largeusername: oamtestsecretName: db-conn- name: sample-osstype: alibaba-ossproperties:name: velawebsecretName: oss-conn
Verify
Deploy and verify the application (by either provider is OK).
$ kubectl get applicationNAME AGEwebapp 46m$ kubectl port-forward deployment/express-server 80:80Forwarding from 127.0.0.1:80 -> 80Forwarding from [::1]:80 -> 80Handling connection for 80Handling connection for 80
