Skip to content

crossplane-contrib/provider-civo

Repository files navigation

provider-civo

Overview

This provider-civo repository is the Crossplane infrastructure provider for Civo. The provider that is built from the source code in this repository can be installed into a Crossplane control plane and adds the following new functionality:

  • CivoKubernetes
  • CivoInstances

Contributing

provider-civo is a community driven project and we welcome contributions. See the Crossplane Contributing guidelines to get started. Please look at dev.md for local development.

Contact

Please use the following to reach members of the community:

Code of Conduct

provider-civo adheres to the same Code of Conduct as the core Crossplane project.

Run it locally

In the development phase you can test your changes on the crossplane-civo-provider via its facility script:

~ (crossplane-civo-provider) $ make localdev

By using its subcommand init you will get a civo kubernetes cluster up and running in a production region of your choice. This cluster will be hosting the Crossplane CRDs (Custom Resource Definition) for Civo (for example CivoKubernetes). To generate and install the new CRDs from the crossplane-civo-provider codebase you can use the subcommand update. Once they're installed, the above command will run the crossplane-civo-provider locally in background and will connect to the newly created cluster. The example subcommand will return an example to connect to the crossplane-master cluster and to deploy a CivoKubernetes CR. This will trigger the creation of another cluster in the destination region you specified.

Prerequisites

Set-up a Kubernetes cluster with Crossplane installed. The instructions can be found in the official Crossplane documentation.

To add the Civo Provider Configuration Package, run:

kubectl crossplane install provider xpkg.upbound.io/civo/provider-civo:v0.1

In this case, we are going to follow the resources in the example repostory.

Before creating a Provider resource, edit the API key in provider.yaml. You can find the API key in your Civo account at Settings > Profile > Security.

Next, we can apply the Provider:

kubectl apply -f examples/civo/provider/provider.yaml

Once the resource has been created, we can apply the cluster resource:

kubectl apply -f examples/civo/cluster/cluster.yaml

This will create a new Kubernetes cluster, according to the specifications provided in the cluster. You can check the status with kubectl:

kubectl get civokubernetes.cluster.civo.crossplane.io
NAME              READY   MESSAGE             APPLICATIONS
test-crossplane   True    Cluster is active   ["argo-cd","prometheus-operator"]

Connection details

With the use of kubectl it is possible to retrieve the CivoKubernetes kubeconfig directly.

Getting a kubeconfig:

kubectl get secrets cluster-details -o jsonpath="{.data.kubeconfig}" | base64 -d > kubeconfig

Validating our new cluster:

kubectl get nodes --kubeconfig kubeconfig
NAME                                       STATUS   ROLES    AGE     VERSION
k3s-test-cluster-ec4e8ef1-node-pool-41cf   Ready    <none>   4m21s   v1.20.2+k3s1
k3s-test-cluster-ec4e8ef1-node-pool-23e0   Ready    <none>   4m13s   v1.20.2+k3s1