Skip to content

About

A kubernetes operator that expose clever cloud's resources through custom resource definition

Topics

Resources

Code of conduct

Stars

15 stars

Watchers

3 watching

Forks

Repository files navigation

Clever kubernetes operator

Continuous integration

A kubernetes operator that exposes clever cloud's resources through custom resource definition

How it works

This project is based on the operator pattern to provide Custom Resources. Those resources will match Clever-Cloud's add-ons.

Status

The operator is under development, you can use it, but it may have bugs or unimplemented features. You could see missing features by checking issues with the label enhancement.

Install

There are multiple ways to install the operator, you can built it from sources and deploy it through your own registry or use an already built operator hosted on dockerhub or operatorhub.

From source

You will need some tools on your computer to build and deploy the operator, at least you will git, rust toolchain and docker. To deploy the operator, you will also need the kubectl command and a kubernetes cluster.

So, firstly, you will need to retrieve the source. You can clone them directly from GitHub using the following command.

$ git clone https://github.com/CleverCloud/clever-kubernetes-operator.git

or

$ gh repo clone CleverCloud/clever-kubernetes-operator

Then, you will need to go into the new created folder where are located the source code.

$ cd clever-kubernetes-operator

At this step, you can choose to build the binary and use it directly or build the docker image and push it to your registry and then deploy it into your kubernetes cluster.

Build the binary

To build the binary, you can use the following command:

$ make build

The operator binary will be located under the folder target/release/clever-kubernetes-operator. Then, you can run it.

$ target/release/clever-kubernetes-operator

Build the docker image and deploy it

To build the docker image, you can use the following command:

$ DOCKER_IMG=<your-registry>/<your-namespace>/clever-kubernetes-operator:latest make docker-build

Then, push it to your registry.

$ DOCKER_IMG=<your-registry>/<your-namespace>/clever-kubernetes-operator:latest make docker-push

Then, update the kubernetes deployment script located in deployments/kubernetes/v1.36.0/20-deployment.yaml to deploy your docker image in your kubernetes cluster. Finally, apply the deployment script.

$ make deploy-kubernetes

or

$ kubectl apply -f deployments/kubernetes/v1.36.0

From the helm chart

You can also use the available Helm chart. Configure the values.yaml file in deployments/kubernetes/helm with your own values, then run:

$ helm install clever-kubernetes-operator -n clever-kubernetes-operator --create-namespace -f values.yaml .

From dockerhub

The docker image will be provided by the dockerhub account of Clever-Cloud and you only need to apply the deployment script.

$ make deploy-kubernetes

or

$ kubectl apply -f https://raw.githubusercontent.com/CleverCloud/clever-kubernetes-operator/main/deployments/kubernetes/v1.36.0/10-custom-resource-definition.yaml
$ kubectl apply -f https://raw.githubusercontent.com/CleverCloud/clever-kubernetes-operator/main/deployments/kubernetes/v1.36.0/20-deployment.yaml

Credentials

To connect to the Clever Cloud API, the operator supports three authentication methods:

1. Full OAuth1 Authentication (Four Parameters)

This option uses the complete OAuth1 authentication flow with all four required credentials.

[api]
token = "your-oauth-token"
secret = "your-oauth-secret"
consumer-key = "your-consumer-key"
consumer-secret = "your-consumer-secret"

When to use:

  • When you have your own OAuth consumer application registered with Clever Cloud
  • When you need custom permissions or scopes
  • For production environments where you want full control over authentication

2. Simplified OAuth1 Authentication (Token and Secret Only)

This option uses OAuth1 authentication but automatically applies the public Clever Tools consumer credentials when you only provide token and secret.

[api]
token = "your-oauth-token"
secret = "your-oauth-secret"

When to use:

  • For most standard use cases
  • When you have personal tokens but don't want to manage consumer credentials
  • For development or testing environments

When only token and secret are provided, the SDK automatically uses the same public consumer credentials as the Clever Cloud CLI tools.

3. Bearer Token Authentication

This is the simplest authentication method, using a single bearer token with the "oauthless auth backend."

[api]
token = "your-bearer-token"

When to use:

  • When working with the oauthless auth backend
  • For simple integrations or scripts
  • When you have a personal access token that doesn't require OAuth flow

For most users, Option 2 (token and secret only) provides the best balance of security and convenience.

Configuration

Global

To work properly, the operator needs to be configured with at least credentials to connect the Clever Cloud's API. Those configurations could be provided through a ConfigMap, a Secret or by the environment.

An example of deployment using a Secret is located at deployments/kubernetes/v1.36.0/20-deployment.yaml. An example of deployment using a ConfigMap is located at deployments/helm/.

Environment variables are:

Name Kind Default Required Description
CLEVER_OPERATOR_OPERATOR_LISTEN SocketAddress 0.0.0.0:8000 yes
CLEVER_OPERATOR_API_SECRET String none false
CLEVER_OPERATOR_API_TOKEN String none yes if used alone, we assume that we are using oauthless auth backend
CLEVER_OPERATOR_API_CONSUMER_KEY String none false
CLEVER_OPERATOR_API_CONSUMER_SECRET String none false
CLEVER_OPERATOR_API_ENDPOINT String none false base url of the Clever Cloud API, see below
CLEVER_OPERATOR_API_CA_BUNDLE String none false path to a pem bundle of certificate authorities, see below

API endpoint

By default, the operator talks to the public Clever Cloud API, https://api.clever-cloud.com — or https://api-bridge.clever-cloud.com when a bare bearer token is used, as this is the endpoint the oauthless auth backend lives on.

To target another installation, set the CLEVER_OPERATOR_API_ENDPOINT environment variable or the endpoint key of the api section:

[api]
endpoint = "https://api.clever-cloud.example.com"
token = "your-oauth-token"
secret = "your-oauth-secret"

The value is normalised: a trailing slash is trimmed, and anything the operator could not append a path to — another scheme than http/https, a query string, a fragment, embedded credentials — is rejected when the configuration is loaded. Running with --config <path> --check reports such a value; when the configuration is discovered from the default search paths below, a rejected value makes the operator fall back to the clever-tools configuration instead of reporting the problem.

As for the credentials, the environment variable only provides a default: a value set in the configuration file takes precedence over it. An empty variable counts as not set.

A per-namespace clever-kubernetes-operator Secret overrides the credentials of a namespace, not the installation they belong to: it inherits this endpoint unless it declares an endpoint of its own.

Another installation does not necessarily offer the same add-ons as the public platform, while the custom resources the operator knows are fixed when it is built. When it starts, the operator fetches the add-on catalog of the api and logs, at the warn level, the providers it has no custom resource for as well as the supported kinds the api does not expose — applying a custom resource of such a kind fails at reconciliation. This is a diagnostic only: it waits at most ten seconds for the api, and an api that cannot be reached or answers something unexpected is logged the same way and does not prevent the operator from starting. Run it with at least -v to see these messages.

Private certificate authorities

The operator trusts the certificate authorities compiled into it — the Mozilla root bundle. It reads neither the system trust store nor SSL_CERT_FILE, so running update-ca-certificates in the image has no effect on it.

A self-hosted installation is commonly served by a certificate signed by a private authority, which would make every request fail on the TLS handshake. Point CLEVER_OPERATOR_API_CA_BUNDLE, or the ca_bundle key of the api section, at a pem file holding that authority — it may hold several, concatenated:

[api]
endpoint = "https://api.clever-cloud.example.com"
ca_bundle = "/etc/clever-kubernetes-operator-ca/ca-bundle.pem"
token = "your-oauth-token"
secret = "your-oauth-secret"

The value is a path and not inline pem so it can be mounted from a ConfigMap or a Secret; the Helm chart does exactly that, see its config.caBundle value. These authorities are added on top of the built-in ones, never in place of them, as such an installation may well be served by a mixed chain.

The file is read when the operator builds its client, that is when it starts: a path that does not exist, or that holds no pem certificate, makes it refuse to start and names the file at fault, instead of failing later on every reconciliation with an opaque handshake error. --check reports the same thing without starting anything, whether the configuration was named with --config or discovered from the search paths below. It is not re-read afterwards: rotating the authorities needs the pod to be restarted.

configmap generate and secret generate do not read it, on purpose — the path they encode is the one of the pod, not of the machine running them.

The plain manifests under deployments/kubernetes/ mount nothing of the sort: use the Helm chart, or add the volume and its mount to the deployment yourself.

As for the endpoint, the environment variable only provides a default, a value set in the configuration file takes precedence over it, and an empty variable counts as not set. A per-namespace clever-kubernetes-operator Secret inherits this bundle unless it declares a ca_bundle of its own.

By default, if the --config flag is not provided to the binary, the operator will look at the following paths to retrieve its configuration:

  • /usr/share/clever-kubernetes-operator/config.{toml,yaml,json}
  • /etc/clever-kubernetes-operator/config.{toml,yaml,json}
  • $HOME/.config/clever-kubernetes-operator/config.{toml,yaml,json}
  • $HOME/.local/share/clever-kubernetes-operator/config.{toml,yaml,json}
  • config.{toml,yaml,json}

License

See the license.

Getting in touch

About

A kubernetes operator that expose clever cloud's resources through custom resource definition

Topics

Resources

Code of conduct

Stars

15 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages