
Crossplane is a cloud-native framework that offers an extensible backend for provisioning and managing infrastructure resources across cloud providers. Crossplane acts as a controller that extends Kubernetes with a cloud-agnostic way to define and manage external cloud resources. This process enables organizations to provision, configure, and manage the lifecycle of infrastructure resources using manifest files.
This guide explains how to provision cloud infrastructure resources on Vultr using Crossplane. You will leverage the Vultr Kubernetes Engine (VKE) to externally deploy cloud resources such as Managed Databases, Cloud Compute instances and Vultr Object Storage using Kubernetes cluster definitions. This unified deployment approach promotes consistency, reproducibility, and scalability across multiple infrastructure environments.
Before you begin:
Deploy a Vultr Kubernetes Engine (VKE) cluster with at least three nodes to use as the management cluster.
Deploy a Vultr Ubuntu server to use as the management workstation.
Access the server using SSH as a non-root user with sudo privileges.
Install and configure Kubectl to access the VKE cluster.
Install the Helm Package Manager using Snap.
Crossplane securely authenticates and deploys resources to your Vultr account using an API key. For each Crossplane resource request triggered from your Kubernetes cluster, the provider configuration validates the composition settings and authenticates with your Vultr API Key to successfully apply the resource to your Vultr account. Follow the steps below to enable your Vultr API Key and enable Crossplane to deploy resources using your VKE cluster IP.
Open the Vultr Console.
Click Account on the left navigation menu to access your Vultr account settings.
Find and select API within the OTHER section to access your Vultr account API settings.
Click Enable API to allow API access on your Vultr account and generate a new Personal Access Token.
When successful, click the Copy API Key to Clipboard symbol to copy your generated Vultr API Key.
Navigate to Products and click Kubernetes on the left navigation menu to view your cluster IP address.
Click your VKE cluster to access the control panel and copy the public IP Address value to your clipboard.
Access your Vultr API settings page, and paste the cluster IP Address value in the Enter your IPV4 or IPV6 below field. For example, 192.0.2.100.
Enter your cluster IP subnet in the / field to correctly match your VKE IP. For example, 30 depending on your cluster IP class.
Click Add to grant your VKE cluster IP access to the Vultr API Key.
In case you experience cluster authentication failures with your Vultr API key, view your cluster nodes and copy the IP address value of the main node to grant access to the API key. For example:
Your output should look like the one below:
Within the above output, the cluster uses the main node IP 192.0.2.100 for external communications. Grant the IP access to your Vultr API key with a generic /30 subnet or the corresponding public IP subnet. To allow the full cluster IP network range for example, 192.0.2.0, use the classful IP classful subnet value depending on the public IP address of your VKE cluster:
| Address Class | Subnet | Address Range | | Class A | /8 | 1.0.0.1 to 126.255.255.254| | Class B | /16 | 128.0.1.1 to 191.255.254.254 | | Class C | /24 | 192.0.0.1 to 223.255.255.254 |
To correctly use Crossplane in your VKE cluster, verify that the correct IP address is allowed in your API Access Control section. When enabled, the Crossplane can access your Vultr account with the API key and deploy resources using your cluster IP.
View your VKE cluster nodes to verify that you are connected to the cluster.
Output:
Create a new directory to store your Crossplane configuration files.
Switch to the directory.
Add the Crossplane repository to your Helm sources.
Update the Helm repository index.
Install Crossplane to your VKE cluster using Helm.
When successful, your output should look like the one below:
View information about all resources deployed in the Crossplane namespace crossplane-system to verify that the installation is successful.
Your output should be similar to the one below:
To provision resources, configure Crossplane with the Vultr provider extension to enable your Vultr account API key to manage cloud resources from your VKE cluster. The Vultr Crossplane provider enables the provision of cloud resources such as instances, storage volumes, networks, and firewalls to your Vultr account. Follow the steps below to configure Crossplane with the Vultr provider configuration and API key.
Create a new resource file provider.yaml to define the Vultr Crossplane provider values.
Add the following contents to the file.
The above configuration creates a new Vultr Crossplane provider resource with the following values:
apiVersion: Specifies the Crossplane API version to use with the Provider resource.kind: Sets the Kubernetes resource type.name: Sets the resource name for indentification within the cluster.package: Specifies the provider package URL to use with Crossplane. For example, provider-vultr:v0.2.0 uses the Vultr provider package version v0.2.0.Apply resource configuration to your cluster.
Wait for at least 90 seconds and view the cluster provider resources to verify that the Vultr Crosssplane provider status is healthy.
Output:
Create a new secret resource file vultr-secret.yaml to store the Vultr API key.
Add the following contents to the file. Replace R2dpexamplekey with your actual Vultr API key.
Apply the resource to your cluster.
Create a new provider manifest providerconfig.yaml to define how Crossplane authenticates with your Vultr API key.
Add the following contents to the file.
Apply the provider configuration to your cluster.
Verify that the provider configuration is available in your cluster.
Output:
You have set up the configured Crossplane with valid Vultr values to provision resources to your account. For each Crossplane request, the application uses the provider configuration to reference the Vultr API key and deploy resources using the Vultr provider profile.
Follow the steps below to create Vultr Compute instances using Crossplane and the Vultr API Key.
Create a new resource file compute.yaml to define your Cloud Compute instance specifications.
Add the following configurations to the file.
Save and close the file.
The above configuration creates a new Vultr Cloud Compute instance the resource label example-linux-server and the following vc2-1c-1gb plan specifications:
sgpTo modify your instance specifications, run the following Curl requests using the Vultr API to view all supported values.
Within the instance configuration:
apiVersion: Specifies the Vultr Crossplace Provider API version to use with the instance configuration.kind: Sets the Kubernetes resource type.labels: Sets the cluster resource identification labels. For example, testing.upbound.io/example-name: my_instance sets the Vultr instance name to my_instance while name: linux-instance sets the cluster resource name to linux-instance.forProvider: Sets the Vultr provider resource specifications to provision the instance.osId: Sets the target operating system to deploy with the server. For example, 387 sets Ubuntu 20.04 as the instance operating system.plan: Defines the Vultr plan to apply to the instance. For example, vc2-1c-1gb deploys the instance with 1 CPU core and 1GB of RAM.region: Sets the target Vultr region by shortcode to deploy the instance. For example, sgp sets the deployment location to Singapore.label: Sets the Vultr instance name.Apply the Vultr instance resource file to your cluster.
Wait for at least 3 minutes for the deployment process to complete, then view your Crossplane instance resources using the following command.
When the Vultr Cloud Compute instance successfully deploys on your Vultr account, the resource READY value changes to TRUE similar to the output below:
Access the Vultr Console and navigate to Products -> Compute to verify that your instance is available.
Crossplane deploys Vultr instances to your account using your configuration and assigned resource values. When you delete resource from your cluster, Crossplane destroys the matching instance ID on your Vultr account. For example, when you run kubectl delete instance linux-instance, Crossplane destroys the cluster resource together with the associated Vultr instance.
Crossplane provisions Vultr Managed Databases to your Vultr account using the database engine, and backend compute plan specifications associated with your resource configuration. Follow the steps below to deploy a Vultr Managed Database for PostgreSQL with Crossplane to your Vultr account.
Create a new resource file db.yaml to define your Vultr Managed Database for PostgreSQL specifications.
Add the following contents to the file.
Save and close the file.
The above configuration creates a new Vultr Managed Database for PostgreSQL with the following vultr-dbaas-startup-cc-1-55-2 starter plan specifications:
pg15my_managed_database1, memory 2GB, storage 55 GB, monthly cost $30ewrTo view other supported Vultr Managed Database specification values, run the following API requests.
Within the resource configuration:
name: Specifies the database resource name for identification within the cluster.databaseEngine: Sets the Vultr Managed Database engine. For example, pg enables the PostgreSQL database engine.databaseEngineVersion: Specifies the database engine version to install.label: Specifies a label for the database instance.plan: Specifies the plan or size of the database instance. The plan vultr-dbaas-startup-cc-1-55-2 represents a specific database plan or configuration.region: Specifies the region to deploy the Managed Database instance. The region ID value ewr sets the Newark, New Jersey Vultr location as the target deployment region.Apply the resource file to your cluster to create the Vultr Managed Database for PostgreSQL.
Wait for at least 5 minutes for the Vultr Managed Database deployment process to complete, then view the cluster database resources to verify the Crossplane resource status.
Output:
Access the Vultr Console and navigate to Products -> Databases to verify that the managed database is available.
Create a new environment variable to store your Vultr API Key. Replace R2dpexamplekey with your actual API key.
Run the following Curl request to list all available Vultr Managed Databases on your account.
Find your target Vultr Managed Database ID value within the request output similar to the one below:
Within the above output, the Vultr Managed Database runs with the ID: 8968-3b-4aa-81-be57, use the ID value to create a new database, replicas and users using Crossplane.
Create a new resource file exampledb.yaml to store the new database values
Add the following contents to the file. Replace 8968-3b-4aa-81-be57 with your actual Vultr Managed Database ID.
Save and close the file.
The above configuration creates a new database with the following values:
8968-3b-4aa-81-be57example_dbWithin the configuration:
kind: Specifies the Crossplane resource type. The value DB specifies a database resource.labels: name: Sets the resource name for identification within the cluster.databaseId: Specifies the target Vultr Managed Database to create the new database.name: Sets the new database name.Apply the resource to add the new database to your existing Vultr Managed Database cluster.
View the cluster DB resource type and verify that the database is available.
Output:
Access your Vultr Managed Database control panel and navigate to the Databases tab to verify that the new database is available.
Create a new resource file dbuser.yaml to define the Managed Database user details.
Add the following contents to the file. Replace 8968-3b-4aa-81-be57 with your actual Vultr Managed Database ID.
Save and close the file.
The above configuration creates a new Vultr Managed Database user with the following details:
strongpassword244example_userWithin the configuration:
kind: Sets the Crossplane resource type. The value User specifies a new database user configuration.labels: name: Sets the Crossplane database user resource name.databaseId: Specifies the target Vultr Managed Database for the new user.password: Sets the Vultr Managed Database user password.username: Sets the Vultr Managed Database user name.Apply the resource file to your cluster to create the new Vultr Managed Database user.
View the Crossplane user resource definition to verify that the new user is available.
Output:
Access your Vultr Managed Database Control Panel and navigate to the Database Users tab to verify that the new user is available
Create a new resource file objectstorage.yaml to store your Vultr Object Storage specifications.
Add the following contents to the file.
Save and close the file.
The above configuration creates a new Vultr Object Storage with the following values:
sample-object-storage6. To view the list of supported Vultr Object Storage cluster location IDs, run the following API request:Within the configuration:
kind: Sets the resource type as Vultr Object Storage.labels: name: Sets the Crossplane resource name for identification within the cluster.clusterId: Sets the target Vultr location to deploy Object Storage.label: Specifies the Vultr Object Storage name.Apply the resource to your cluster to create your Vultr Object Storage
Wait for at least 3 minutes for the Vultr Object Storage deployment process to complete, then view the Crossplane objects resources to verify that your new object storage instance is available
Output:
Access the Vultr Console and navigate to Products -> Storage -> Object Storage to verify the resource is available.
Create a new resource file blockstorage.yaml to store your Vultr Block Storage values.
Add the following contents to the file.
Save and close the file.
The above configuration creates a new Vultr Block Storage volume with the following specifications:
example-block-storage10 GBewrWithin the configuration:
kind: Sets the Block Storage definition as the Crossplane resource type.labels: name: Sets the Crossplane resource name for identification within the cluster.label: Specifies the Vultr Block Storage volume name.region: Sets the Vultr location to deploy the Object Storage instance.sizeGb: Specifies the Vultr Block Storage volume size in Gigabytes. For example, 10 creates a 10 GB volume.Apply the resource file to your cluster to create Vultr Block Storage volume.
Wait for at least 3 minutes for the Vultr Block Storage deployment process to complete, then view the Crossplane storage resources and verify that the volume is available.
Output:
Access the Vultr Console and navigate to Products -> Storage -> Block Storage to verify that the new volume is available.
Create a new resource file vkecluster.yaml to define the new VKE cluster specifications.
Add the following contents to the file.
Save and close the file.
The above configuration creates a new Vultr Kubernetes Engine (VKE) cluster resource with the following specifications:
my-vke-clusterexample-vke-cluster1 nodesvc2-1c-2gb - 1 vCPU, 2 GB memorymanv1.29.1+1my_cluster_nodesWithin the configuration:
kind: Sets the Crossplane resource type. The value Kubernetes defines a VKE cluster resource.labels: name: Specifies the Crossplane resource name for identification within the cluster.label: Sets the VKE cluster name.nodePools: Specifies the cluster worker node specifications.autoScaler: Enables or disables auto-scaling of the VKE cluster. The value True enables auto-scaling of the cluster nodes.label: Sets the VKE nodes label.maxNodes: Specifies the maximum number of nodes when scaling the VKE cluster.minNodes: Sets the minimum number of nodes when downscaling the VKE cluster.nodeQuantity: Specifies the maximum number of nodes on the VKE cluster.plan: Specifies the VKE nodes Cloud Compute plan.region: Sets the Vultr location to deploy the VKE cluster.version: Specifies the Kubernetes version to deploy on the VKE cluster.Apply the resource to your cluster to create the VKE cluster.
Wait for at least 5 minutes for the VKE cluster deployment process to complete, then view the Crossplane resources to verify that your VKE cluster resource is available.
Output:
Navigate to Products -> Kubernetes and verify that the new VKE cluster is available.
Crossplane may fail to deploy specific resources on your Vultr account depending on your resource definitions or access to the Vultr API key. Depending on your cluster configuration, view your resource configuration to verify the logged error entries. For example, if you deploy a Vultr Cloud Compute instance with a True synced value, but a False ready value, access the Vultr Console and verify your instance status.
If Crossplane fails to provision resources to your Vultr account. View the resource logs to verify the latest error entries. For example, view the linux-instance resource status and latest log entries.
Depending on the possible cause of the Crossplane error, your resource output may be similar to the one below:
Based on the above Crossplane error message, the VKE cluster IP address is not authorized to deploy resources to your Vultr account. Open the Vultr Console and add your VKE cluster IP to the allowed addresses list to grant Crossplane access to your Vultr account.
When deploying Vultr Managed Databases resources such as users, Crossplane may fail to synchronize with the database cluster similar to the output below:
Describe the Crossplane resource to view the possible source of the error. For example, view the database user resource new-database-user logs.
Your output should look like the one below:
Within the above output, Crossplane logs a database subscription ID error. This means, the resource database ID does not match any valid Vultr Managed Databases linked to your account. Run the following Curl request to view your target database ID.
You have provisioned infrastructure resources on your Vultr account using Crossplane. Depending on your infrastructure needs, Crossplane uses declarative YAML files to provision resources using your provider API key similar to other solutions such as Terraform and Terragrunt. For more information about Crossplane, visit the official documentation. To explore additional Vultr Crossplane configuration samples, visit the provider repository.
0 Comments
Be the first to comment and share your perspective with the community.