Skip to content

Instantly share code, notes, and snippets.

@exocode
Last active July 3, 2022 20:18
Show Gist options
  • Save exocode/7de081d1e8aa52af3ce5a1ee2438d52f to your computer and use it in GitHub Desktop.
Save exocode/7de081d1e8aa52af3ce5a1ee2438d52f to your computer and use it in GitHub Desktop.
Demo for Upbound (not working)

Crossplane, Upbound and Civo

Installing

You have two options to install Crossplane:

  • Either you deploy your Crossplane manifests it through an existing cluster (Minikube, bare-metal, on premise or any other desired cloud provider,...)
  • or through Upbound Enterprise, which is a kind of managed Kubernetes cluster, which solves the chicken-egg problem.

Installing Crossplane with a Helm chart

  • kubectl create namespace crossplane-system
  • helm repo add crossplane-master https://charts.crossplane.io/master/
  • helm repo update
  • helm search repo crossplane-master

Choose the crossplane-master/crossplane chart and install it.

  • helm upgrade --install crossplane crossplane-stable/crossplane --namespace crossplane-system --create-namespace --wait

You can also use the dev version (which didn't worked for me)

  • helm search repo crossplane-master --devel
  • helm install crossplane --namespace crossplane-system crossplane-master/crossplane --devel --version <version>

Check the status of the installation

  • helm list -n crossplane-system
  • kubectl get all -n crossplane-system

Install the Crossplane CLI:

You can either choose a specific version:

  • curl -sL https://raw.githubusercontent.com/crossplane/crossplane/release-0.14/install.sh | sh or

or using the most recent one:

  • curl -sL https://raw.githubusercontent.com/crossplane/crossplane/release-1.5/install.sh | CHANNEL=master sh (be careful with the master channel: at the time I was writing this it was not working for me)

Move CLI to your bin directory (the instructions are also at the end of the previous installation process:

sudo mv kubectl-crossplane /usr/local/bin

Now install the provider onto your cluster:

kubectl crossplane install provider crossplane/provider-civo:main

Obtain a token:

Civo -> Account -> Settings -> Preferences -> Security -> Create a new token

Then encode it in base64:

echo “your API key” | base64

or if you wanna have it in your shell ENV

export CIVO_TOKEN=YOUR_PROVIDER_TOKEN export CIVO_TOKEN_ENCODED=$(echo $CIVO_TOKEN | base64) echo $CIVO_TOKEN_PROVIDED fill in your provider token at the provider.yml

Installing the Civo provider at Crossplane

Create a secret and a ProviderConfig:

apiVersion: v1
kind: Secret
metadata:
  namespace: crossplane-system
  name: provider-civo-secret
type: Opaque
data:
  credentials: $CIVO_TOKEN_ENCODED
---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-civo
spec:
  package: crossplane/provider-civo:main
---
apiVersion: civo.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
  name: provider-civo
spec:
  region: fra1
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: provider-civo-secret
      key: credentials

kubectl apply -f ./cluster-civo-provider-config.yaml

Deploy your cluster through Crossplane

kind: CivoKubernetes
apiVersion: cluster.civo.crossplane.io/v1alpha1
metadata: 
  name: example-civo-cluster
spec:
  name: test-cluster-two
  instances: 3
  size: g3.k3s.small
  applications: # list of applications to deploy
    - "argo-cd"
    - "prometheus-operator"
  connectionDetails:
    connectionSecretNamePrefix: "cluster-details"
    connectionSecretNamespace: "default"
  providerConfigRef:
    name: civo-provider

with

kubectl apply -f cluster-civo.yml

UpBound

Upbound is a Kubernetes operator that allows you to deploy your cluster with a single command.

There are two ways to deploy your cluster:

Either you have a

  • pre-existing Crossplane running in a cluster and attach the Upbound operator to it
  • you are using the paid version of Upbound Enterprise, which creates and hosts the Crossplane cluster for you.

in both ways ou create an Upbound account and install the UpBound CLI. Follow the instructions after the installation.

curl -sL https://cli.upbound.io | sh

Now you need a cluster to run the UpBound CLI. Create one with Civo

civo kuberes create ADD_YOUR_NEEDS

a.) Use the attached UpBound operator

After CLI installation you can use the following command to install the Upbound CRDs into your cluster:

up uxp install

After that you connect the Upbound account to your cluster with the following command: (that command is also visible in your UpBound account)

  • up login --profile=vonhier --account=vonhier or use the token based login
  • up controlplane attach $NAME_YOUR_UPBOUND_CONTROLPLANE --profile=vonhier | up uxp connect -

If successful confirm the installation with the following command:

kubectl -n upbound-system get pods -w

b.) Use the paid version of UpBound Enterprise

Create a controlplane in the UI.

Create a token in the UI.

Then connect the Upbound account to your cluster with the following command:

Connect to the Upbound Enterprise created cluster:

up login

up ctp list

up ctp kubeconfig get CONTROL_PLANE_ID --token=YOUR_TOKEN --account="jezekjancom"

If you wanna save the kube config, you can use the following command:

up ctp kubeconfig get CONTROL_PLANE_ID --token=YOUR_TOKEN --account="jezekjancom" -f upbound_kubeconfig

Install the Civo-Crossplane CRDs:

kubectl crossplane install provider crossplane/provider-civo:main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment