Crossplane Provider IONOS Cloud Usage Example

Overview

Crossplane allows the user to manage infrastructure directly from Kubernetes. Crossplane extends a Kubernetes cluster to support orchestrating any infrastructure or managed service. Providers extend Crossplane to enable infrastructure resource provisioning of specific APIs.

Crossplane Provider IONOS Cloud contains a Controller and Custom Resource Definitions(CRDs). The CRDs are defined in sync with the API and contain the desired state. The Controller has a reconcile loop, and it constantly compares the desired state vs the actual state and takes action to reach the desired state. Using the SDK Go, the Controller performs CRUD operations and resources are managed in the IONOS Cloud.

In this Proof of Concept of the IONOS Cloud Provider, we will create a DBaaS Postgres cluster resource in the IONOS Cloud.

Prerequisites

Ensure that you have the following:

  • A Kubernetes implementation, such as kind

  • Docker

  • Credentials to access IONOS Cloud

  • Clone this repository locally to be able to run examples

Check prerequisites

You can now check your prerequisites. To check K8s, in case of using kind, run the following command:

kind version

To check the credentials, run the following command:

OR

To clone the repository locally, run the following command:

Set up Crossplane Provider IONOS Cloud

To set up Crossplane Provider IONOS Cloud, follow these steps:

Create a K8s cluster (in case of using kind)

To create a cluster in case of using kind, run the following command:

Create namespace for the crossplane ecosystem

To create namespace for the crossplane ecosystem, run the following command:

Install Crossplane via helm

To create a cluster in case of using helm, run the following command:

Register CRDs into k8s cluster

To register CRDs into k8s cluster, run the following command:

Note: Before continuing, you can check if kubectl get providers will recognize the CRDs of type providers. The command should return: No resources found.

Install ProviderConfig for credentials

To install ProviderConfig for credentials, run the following commands:

OR

Note: You can overwrite the default IONOS Cloud API endpoint, by setting host_url to: --from-literal=credentials="{\"host_url\":\"${IONOS_API_URL}\"}".

Install Crossplane Provider for IONOS Cloud

To install Crossplane Provider for IONOS Cloud, run the following command:

You can install other providers, such as Helm and Kubernetes, using the following:

Check the health of Crossplane Provider IONOS Cloud

To check if the Crossplane Provider IONOS Cloud is installed and healthy, run the following command:

You should be able to see pods running in the crossplane-system namespace for each provider installed. To see the existing pods from all namespaces, run kubectl get pods -A.

Run the following command to see the pods:

Check CRDs

To check the CRDs, run the following command:

A CRD named postgresclusters.dbaas.ionoscloud.crossplane.io should be displayed in the output.

After that, you can create a Custom Resource (CR) of type postgresclusters.dbaas.ionoscloud.crossplane.io to provision a DBaaS Postgres cluster in the IONOS Cloud.

Provision DBaaS Postgres cluster

For the DBaaS Postgres service, there is only cluster resource available into the Crossplane Provider IONOS Cloud.

Create a Data Center CR, LAN CR, and Postgres cluster CR

To create a data center CR, LAN CR, and Postgres cluster CR, run the following command:

Get a Data Center CR, LAN CR, and Postgres cluster CR

To check if the created Postgres cluster CR is synced and ready, run the following command:

To view more details, run the following command:

The external-name of the CR is the Cluster ID from IONOS Cloud. The cluster CR will be marked as ready when the cluster is in available state.

You can check if the DBaaS Postgres cluster was created in the IONOS Cloud using ionosctl latest versions. Run the following command:

  1. In the DCD, go to the Menu > Databases > Postgres clusters.

  2. Check if the data center and LAN CRs are created using:

Update a Data Center CR, LAN and Postgres ccuster CR

If you want to update the CRs created, update values from the examples/ionoscloud/dbaas/postgres-cluster.yaml file using the following command:

The updates applied should be updated in the external resource in IONOS Cloud.

Delete a Data Center CR, LAN and Postgres cluster CRs

To delete the Postgres cluster CR with the name example, use the following command:

This would trigger the destroying of the DBaaS Postgres cluster.

Delete the LAN and data center CRs using:

OR

You can use the following command

Summary

Refer to the following tables for DBaaS Postgres resources commands:

Custom Resource

Create/Delete/Update

DBaaS Postgres cluster

Custom Resource

GET

GET More Details

JSON Output

DBaaS Postgres cluster

For more information on all Managed Resources of Crossplane Provider IONOS Cloud, see Provision Resources on IONOS Cloud.

Uninstallation

To uninstall, you need to follow these steps:

Uninstall the Provider

After deleting all resources, it is safe to uninstall the Crossplane Provider IONOS Cloud. Run the following command:

Note: Make sure you delete the ProviderConfig before deleting the Provider. For more information, see Uninstall Crossplane.

Now it is safe to delete also the Provider. The ProviderRevision will be deleted automatically using:

Uninstall K8s cluster

Use the following command to delete the k8s cluster:

Last updated