Getting started with UpCloud Crossplane provider

In this getting started tutorial you will learn how to:

  • Install Crossplane related tooling into your Kubernetes cluster
  • Install UpCloud Crossplane Provider and required provider configuration
  • Create an SDN network and a Cloud Server with Crossplane

Prerequisites

First, you will need to install Crossplane tooling on your local machine. Follow the instructions on their documentation.

Next, create a Kubernetes cluster - any will do.

  • To create an UpCloud Kubernetes cluster, follow the tutorials available here.
  • You can also use kind to create a local development cluster with kind create cluster -n crossplane-test

Prepare the kubeconfig for accessing your cluster. Ensure you have the right configuration and the right context in use by running:

kubectl config get-contexts

Once you are ready, run up uxp install. This command installs the latest Upbound Universal Crossplane (UXP) management pods and custom resource definitions (CRD) into your cluster through a Helm chart.

Installing the provider

Install the Crossplane UpCloud provider. The simplest way to do that is to just apply the following YAML manifest with kubectl:

apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
    name: provider-upcloud
spec:
    package: xpkg.upbound.io/upcloud/provider-upcloud:v0.0.4

Next, create a Secret with your UpCloud API credentials and a ProviderConfig that will use them to provision your infra. Apply the following:

apiVersion: v1
kind: Secret
metadata:
    name: example-provider-creds
    namespace: default
type: Opaque
stringData:
    credentials: |
        {
            "username": "username",
            "password": "password123"
        }
---
apiVersion: provider.upcloud.io/v1beta1
kind: ProviderConfig
metadata:
    name: default
spec:
    credentials:
        source: Secret
        secretRef:
            name: example-provider-creds
            namespace: default
            key: credentials

Create a network

First, lets create an SDN network.

apiVersion: network.upcloud.io/v1alpha1
kind: Network
metadata:
  name: example
spec:
  forProvider:
    ipNetwork:
    - address: 10.11.0.0/24
      dhcp: true
      dhcpDefaultRoute: false
      family: IPv4
      gateway: 10.11.0.1
    name: crossplane_private_net_x
    zone: de-fra1

Verify the network status:

$ kubectl get network.network.upcloud.io/example
NAME      READY   SYNCED   EXTERNAL-NAME                          AGE
example   True    True     abbaacdc-9463-4327-1337-14d5566ad2d1   5s

Create a server

Finally, create a Cloud Server to the network we created in the previous step.

apiVersion: server.upcloud.io/v1alpha1
kind: Server
metadata:
  name: example
spec:
  forProvider:
    hostname: crossplane-examples
    labels:
      env: dev
      production: "false"
    login:
    - user: myusername
    networkInterface:
    - type: public
    - type: private
      networkRef:
        name: example
    - type: private
      networkRef:
        name: example
    plan: 1xCPU-1GB
    template:
    - size: 25
      storage: Ubuntu Server 20.04 LTS (Focal Fossa)
    zone: de-fra1

See server status and wait until the resource has been created:

$ kubectl get server.server.upcloud.io/example -w
NAME      READY   SYNCED   EXTERNAL-NAME   AGE
example   False   True                    36s
...
example   True    True     00eeface-b00c-4587-b857-cafe9f1ed5a6   55s

You can list server details, such as IP addresses, through kubectl describe server.server.upcloud.io/example.

Next steps

For a complete list of examples, check the examples in the GitHub repository to see what other Managed Resources you can use and how.

Have fun!