Version: v1.0

Crossplane

In this documentation, we will use Alibaba Cloud’s RDS (Relational Database Service), and Alibaba Cloud’s OSS (Object Storage System) as examples to show how to enable cloud services as part of the application deployment.

These cloud services are provided by Crossplane.

Prepare Crossplane

Please Refer to [Installation](https://github.com/crossplane/provider-alibaba/releases/tag/v0.5.0) to install Crossplane Alibaba provider v0.5.0.

If you’d like to configure any other Crossplane providers, please refer to Crossplane Select a Getting Started Configuration.

  1. $ kubectl crossplane install provider crossplane/provider-alibaba:v0.5.0
  2. # Note the xxx and yyy here is your own AccessKey and SecretKey to the cloud resources.
  3. $ kubectl create secret generic alibaba-account-creds -n crossplane-system --from-literal=accessKeyId=xxx --from-literal=accessKeySecret=yyy
  4. $ kubectl apply -f provider.yaml

provider.yaml is as below.

  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: crossplane-system
  5. ---
  6. apiVersion: alibaba.crossplane.io/v1alpha1
  7. kind: ProviderConfig
  8. metadata:
  9. name: default
  10. spec:
  11. credentials:
  12. source: Secret
  13. secretRef:
  14. namespace: crossplane-system
  15. name: alibaba-account-creds
  16. key: credentials
  17. region: cn-beijing

Register alibaba-rds Component

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: ComponentDefinition
  3. metadata:
  4. name: alibaba-rds
  5. namespace: vela-system
  6. annotations:
  7. definition.oam.dev/description: "Alibaba Cloud RDS Resource"
  8. spec:
  9. workload:
  10. definition:
  11. apiVersion: database.alibaba.crossplane.io/v1alpha1
  12. kind: RDSInstance
  13. schematic:
  14. cue:
  15. template: |
  16. output: {
  17. apiVersion: "database.alibaba.crossplane.io/v1alpha1"
  18. kind: "RDSInstance"
  19. spec: {
  20. forProvider: {
  21. engine: parameter.engine
  22. engineVersion: parameter.engineVersion
  23. dbInstanceClass: parameter.instanceClass
  24. dbInstanceStorageInGB: 20
  25. securityIPList: "0.0.0.0/0"
  26. masterUsername: parameter.username
  27. }
  28. writeConnectionSecretToRef: {
  29. namespace: context.namespace
  30. name: parameter.secretName
  31. }
  32. providerConfigRef: {
  33. name: "default"
  34. }
  35. deletionPolicy: "Delete"
  36. }
  37. }
  38. parameter: {
  39. // +usage=RDS engine
  40. engine: *"mysql" | string
  41. // +usage=The version of RDS engine
  42. engineVersion: *"8.0" | string
  43. // +usage=The instance class for the RDS
  44. instanceClass: *"rds.mysql.c1.large" | string
  45. // +usage=RDS username
  46. username: string
  47. // +usage=Secret name which RDS connection will write to
  48. secretName: string
  49. }

Register alibaba-oss Component

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: ComponentDefinition
  3. metadata:
  4. name: alibaba-oss
  5. namespace: vela-system
  6. annotations:
  7. definition.oam.dev/description: "Alibaba Cloud RDS Resource"
  8. spec:
  9. workload:
  10. definition:
  11. apiVersion: oss.alibaba.crossplane.io/v1alpha1
  12. kind: Bucket
  13. schematic:
  14. cue:
  15. template: |
  16. output: {
  17. apiVersion: "oss.alibaba.crossplane.io/v1alpha1"
  18. kind: "Bucket"
  19. spec: {
  20. name: parameter.name
  21. acl: parameter.acl
  22. storageClass: parameter.storageClass
  23. dataRedundancyType: parameter.dataRedundancyType
  24. writeConnectionSecretToRef: {
  25. namespace: context.namespace
  26. name: parameter.secretName
  27. }
  28. providerConfigRef: {
  29. name: "default"
  30. }
  31. deletionPolicy: "Delete"
  32. }
  33. }
  34. parameter: {
  35. // +usage=OSS bucket name
  36. name: string
  37. // +usage=The access control list of the OSS bucket
  38. acl: *"private" | string
  39. // +usage=The storage type of OSS bucket
  40. storageClass: *"Standard" | string
  41. // +usage=The data Redundancy type of OSS bucket
  42. dataRedundancyType: *"LRS" | string
  43. // +usage=Secret name which RDS connection will write to
  44. secretName: string
  45. }