# provider-exoscale

`provider-exoscale` is a [Crossplane](https://crossplane.io/) provider built with [Upjet](https://github.com/crossplane/upjet) that exposes Exoscale compute, database (DBaaS), networking, and IAM resources as Kubernetes custom resources.

Source and full list of managed resources: [github.com/exoscale/provider-exoscale](https://github.com/exoscale/provider-exoscale) · [Upbound Marketplace](https://marketplace.upbound.io/providers/exoscale/provider-exoscale)

## Prerequisites

- An existing Kubernetes cluster
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/#kubectl) installed and configured
- [Helm](https://helm.sh/docs/intro/install/) installed
- An [Exoscale](https://portal.exoscale.com/register) account with [API credentials](https://community.exoscale.com/documentation/iam/quick-start/)

## Install Crossplane

```bash
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update

helm install crossplane crossplane-stable/crossplane \
  --namespace crossplane-system \
  --create-namespace

kubectl wait deployment crossplane \
  --namespace crossplane-system \
  --for=condition=Available \
  --timeout=120s
```

## Install the Provider

```bash
export PROVIDER_EXOSCALE_VERSION=v0.1.0

cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-exoscale
spec:
  package: xpkg.upbound.io/exoscale/provider-exoscale:$PROVIDER_EXOSCALE_VERSION
EOF

kubectl wait provider/provider-exoscale \
  --for=condition=Healthy \
  --timeout=120s
```

Verify the installation:

```bash
kubectl get providers
kubectl get crds | grep exoscale
```

## Configure

Create an [IAM API Key](https://community.exoscale.com/documentation/iam/quick-start/) in the Exoscale console, then store the credentials in a Kubernetes secret and create a `ClusterProviderConfig`:

```bash
export EXOSCALE_API_KEY=<your-api-key>
export EXOSCALE_API_SECRET=<your-api-secret>

kubectl create secret generic exoscale-credentials \
  --namespace crossplane-system \
  --from-literal=credentials="{\"key\": \"$EXOSCALE_API_KEY\", \"secret\": \"$EXOSCALE_API_SECRET\"}"

cat <<EOF | kubectl apply -f -
apiVersion: exoscale.m.exoscale.ch/v1beta1
kind: ClusterProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      name: exoscale-credentials
      namespace: crossplane-system
      key: credentials
EOF
```

## Usage

Once the provider is configured, you can manage Exoscale resources with standard Kubernetes manifests. The following example provisions a compute instance:

```bash
cat <<EOF | kubectl apply -f -
apiVersion: compute.exoscale.m.exoscale.ch/v1alpha1
kind: Instance
metadata:
  name: my-instance
  namespace: crossplane-system
spec:
  forProvider:
    zone: ch-gva-2
    name: my-instance
    type: standard.medium
    diskSize: 10
EOF

kubectl wait instance.compute.exoscale.m.exoscale.ch/my-instance \
  --namespace crossplane-system \
  --for=condition=Ready \
  --timeout=120s
```

Monitor all managed resources:

```bash
watch kubectl get managed -A
```

You can find a simple hello world in the readme of the github project and ready-to-use example manifests for every supported resource are available in the [`examples/namespaced/`](https://github.com/exoscale/provider-exoscale/tree/main/examples/namespaced) directory of the repository.

