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.

  1. $ kubectl vela show alibaba-rds
  2. # Properties
  3. +----------------------------+-------------------------------------------------------------------------+-----------------------------------------------------------+----------+---------+
  4. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  5. +----------------------------+-------------------------------------------------------------------------+-----------------------------------------------------------+----------+---------+
  6. | bucket | OSS bucket name | string | true | |
  7. | acl | OSS bucket ACL, supported 'private', 'public-read', 'public-read-write' | string | true | |
  8. | writeConnectionSecretToRef | The secret which the cloud resource connection will be written to | [writeConnectionSecretToRef](#writeConnectionSecretToRef) | false | |
  9. +----------------------------+-------------------------------------------------------------------------+-----------------------------------------------------------+----------+---------+
  10. ## writeConnectionSecretToRef
  11. +-----------+-----------------------------------------------------------------------------+--------+----------+---------+
  12. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  13. +-----------+-----------------------------------------------------------------------------+--------+----------+---------+
  14. | name | The secret name which the cloud resource connection will be written to | string | true | |
  15. | namespace | The secret namespace which the cloud resource connection will be written to | string | false | |
  16. +-----------+-----------------------------------------------------------------------------+--------+----------+---------+
  17. $ kubectl vela show service-binding
  18. # Properties
  19. +-------------+------------------------------------------------+------------------+----------+---------+
  20. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  21. +-------------+------------------------------------------------+------------------+----------+---------+
  22. | envMappings | The mapping of environment variables to secret | map[string]{...} | true | |
  23. +-------------+------------------------------------------------+------------------+----------+---------+

Alibaba Cloud RDS and OSS

A sample application is as below.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: webapp
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: zzxwill/flask-web-application:v0.3.1-crossplane
  11. ports: 80
  12. traits:
  13. - type: service-binding
  14. properties:
  15. envMappings:
  16. # environments refer to db-conn secret
  17. DB_PASSWORD:
  18. secret: db-conn # 1) If the env name is the same as the secret key, secret key can be omitted.
  19. endpoint:
  20. secret: db-conn
  21. key: DB_HOST # 2) If the env name is different from secret key, secret key has to be set.
  22. username:
  23. secret: db-conn
  24. key: DB_USER
  25. # environments refer to oss-conn secret
  26. BUCKET_NAME:
  27. secret: oss-conn
  28. - name: sample-db
  29. type: alibaba-rds
  30. properties:
  31. instance_name: sample-db
  32. account_name: oamtest
  33. password: U34rfwefwefffaked
  34. writeConnectionSecretToRef:
  35. name: db-conn
  36. - name: sample-oss
  37. type: alibaba-oss
  38. properties:
  39. bucket: vela-website
  40. acl: private
  41. writeConnectionSecretToRef:
  42. 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:

  1. $ kubectl vela show alibaba-rds
  2. # Properties
  3. +---------------+------------------------------------------------+--------+----------+--------------------+
  4. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  5. +---------------+------------------------------------------------+--------+----------+--------------------+
  6. | engine | RDS engine | string | true | mysql |
  7. | engineVersion | The version of RDS engine | string | true | 8.0 |
  8. | instanceClass | The instance class for the RDS | string | true | rds.mysql.c1.large |
  9. | username | RDS username | string | true | |
  10. | secretName | Secret name which RDS connection will write to | string | true | |
  11. +---------------+------------------------------------------------+--------+----------+--------------------+

A sample application is as below.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: webapp
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: zzxwill/flask-web-application:v0.3.1-crossplane
  11. ports: 80
  12. traits:
  13. - type: service-binding
  14. properties:
  15. envMappings:
  16. # environments refer to db-conn secret
  17. DB_PASSWORD:
  18. secret: db-conn
  19. key: password # 1) If the env name is different from secret key, secret key has to be set.
  20. endpoint:
  21. secret: db-conn # 2) If the env name is the same as the secret key, secret key can be omitted.
  22. username:
  23. secret: db-conn
  24. # environments refer to oss-conn secret
  25. BUCKET_NAME:
  26. secret: oss-conn
  27. key: Bucket
  28. - name: sample-db
  29. type: alibaba-rds
  30. properties:
  31. name: sample-db
  32. engine: mysql
  33. engineVersion: "8.0"
  34. instanceClass: rds.mysql.c1.large
  35. username: oamtest
  36. secretName: db-conn
  37. - name: sample-oss
  38. type: alibaba-oss
  39. properties:
  40. name: velaweb
  41. secretName: oss-conn

Verify

Deploy and verify the application (by either provider is OK).

  1. $ kubectl get application
  2. NAME AGE
  3. webapp 46m
  4. $ kubectl port-forward deployment/express-server 80:80
  5. Forwarding from 127.0.0.1:80 -> 80
  6. Forwarding from [::1]:80 -> 80
  7. Handling connection for 80
  8. Handling connection for 80

Cloud Services - 图1