Skip to content

Commit

Permalink
Updating clever operator - Installation instructions needed to be cle…
Browse files Browse the repository at this point in the history
…arer (#524)

## Describe your PR

Feedback from Clever Cloud Fest demo


## Checklist

- [ ] My PR is related to an opened issue : #
- [X] I've read the [contributing
guidelines](/CleverCloud/documentation/blob/main/CONTRIBUTING.md)


## Reviewers
_Who should review these changes?_ @CleverCloud/reviewers
@juliamrch & @davlgd

---------

Co-authored-by: Julia March <101819212+juliamrch@users.noreply.github.com>
  • Loading branch information
LostInBrittany and juliamrch authored Feb 13, 2025
1 parent c75d6e9 commit fd918f2
Showing 1 changed file with 116 additions and 51 deletions.
167 changes: 116 additions & 51 deletions content/guides/clever-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,84 +50,152 @@ Before you begin, ensure that you have the following tools and resources based o

These prerequisites are essential for getting started with the Clever Operator, whether you're contributing to its development or deploying it in production.

## Getting the credentials

The Clever Operator requires configuration to connect to Clever Cloud's API and manage resources within your Kubernetes cluster. This configuration requires four credentials:

- _Consumer key_
- _Consumer Secret_
- _Token_
- _Secret_

To obtain them, you need to connect to the Clever Cloud API, that has an OAuth1 based authentication. As explained in the [Clever Cloud API Overview](/api/howto), you need to create an OAuth consumer token in the Clever Cloud console, use it to obtain the _Consumer key_ and the _Consumer Secret_, and do the OAuth authentication dance to get the _Token_ and _Secret_.


> #### This seems cumbersome, is there an easier way?
>
> Yes the OAuth dance is complex. If you want a simpler setup, there is a small application that you can deploy on Clever Cloud and that automates most of the pain away from you.
>
> The code and tutorial are on [https://github.com/CleverCloud/oauth-consumer-server](https://github.com/CleverCloud/oauth-consumer-server).
## Installation

The simplest ways to deploy the Clever Operator are either directly from Docker Hub or using the Helm chart.

### Deploying from DockerHub

Applying the deployment scripts:
{{% steps %}}

#### Clone the repository

```bash
kubectl apply -f https://raw.githubusercontent.com/CleverCloud/clever-operator/main/deployments/kubernetes/v1.24.0/10-custom-resource-definition.yaml
kubectl apply -f https://raw.githubusercontent.com/CleverCloud/clever-operator/main/deployments/kubernetes/v1.24.0/20-deployment.yaml
git clone https://github.com/CleverCloud/clever-operator/
```

#### Insert your credentials into the manifests

The manifests are on folder `/deployments/kubernetes/v1.24.0/`. Modify the `ConfigMap` object in file `/deployments/kubernetes/v1.24.0/:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: clever-operator-configuration
namespace: clever-operator-system
data:
config.toml: |
[api]
endpoint = "https://api.clever-cloud.com/v2"
token = "<your_token>"
secret = "<your_secret>"
consumerKey = "<your_consumer_key>"
consumerSecret = "<your_consumer_secret>"
```
### Installing via Helm Chart
Replacing `<your_token>`, `<your_secret>`, `<your_consumer_key>` and `<your_consumer_secret>` by the credentials obtained in the precedent section.

1. Configuring `values.yaml` in `deployments/kubernetes/helm` with your values.
#### Apply the manifests to deploy the operator

2. Installing the chart:
```bash
helm install clever-operator -n clever-operator --create-namespace -f values.yaml .
```
```bash
kubectl apply -f /deployments/kubernetes/v1.24.0/10-custom-resource-definition.yaml
kubectl apply -f /deployments/kubernetes/v1.24.0/20-deployment.yaml
```

{{% /steps %}}

### Building from Source
### Installing via Helm Chart

{{% steps %}}

1. Cloning the repository:
#### Clone the repository

```bash
git clone https://github.com/CleverCloud/clever-operator.git
cd clever-operator
git clone https://github.com/CleverCloud/clever-operator/
```

2. Building the binary:
#### Configure your credentials in the `config` section of the file `values.yaml` in `deployments/kubernetes/helm`

```bash
make build
```yaml
config:
token: "<your_token>"
secret: "<your_secret>"
consumerKey: "<your_consumer_key>"
consumerSecret: "<your_consumer_secret>"
```

3. Running the operator:
Replacing `<your_token>`, `<your_secret>`, `<your_consumer_key>` and `<your_consumer_secret>` by the credentials obtained in the precedent section.

#### Install the chart:

```bash
target/release/clever-operator
helm install clever-operator -n clever-operator --create-namespace -f values.yaml .
```

### Building and Deploying the Docker Image
{{% /steps %}}

1. Building the Docker image:
### Building from Source

```bash
DOCKER_IMG=<your-registry>/<your-namespace>/clever-operator:latest make docker-build
```
{{% steps %}}

1. Pushing the image to your registry:
#### Clone the repository

```bash
DOCKER_IMG=<your-registry>/<your-namespace>/clever-operator:latest make docker-push
```
```bash
git clone https://github.com/CleverCloud/clever-operator.git
cd clever-operator
```

3. Updating the Kubernetes deployment script:

Modify `deployments/kubernetes/v1.24.0/20-deployment.yaml` to use your Docker image.
#### Insert your credentials into the manifests.

The manifests are on folder `/deployments/kubernetes/v1.24.0/`. Modify the `ConfigMap` object in file `/deployments/kubernetes/v1.24.0/:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: clever-operator-configuration
namespace: clever-operator-system
data:
config.toml: |
[api]
endpoint = "https://api.clever-cloud.com/v2"
token = "<your_token>"
secret = "<your_secret>"
consumerKey = "<your_consumer_key>"
consumerSecret = "<your_consumer_secret>"
```

4. Deploying to Kubernetes:
```bash
make deploy-kubernetes
```
Replacing `<your_token>`, `<your_secret>`, `<your_consumer_key>` and `<your_consumer_secret>` by the credentials obtained in the precedent section.

#### Build the binary:

## Configuration
```bash
make build
```

#### Running the operator:

The Clever Operator requires configuration to connect to Clever Cloud's API and manage resources within your Kubernetes cluster. Configuration options are available at two levels: global (applies to all namespaces) and namespace-specific.
```bash
target/release/clever-operator
```

{{% /steps %}}

## Configuration

For details on how to obtain these credentials, follow the instructions on the [How to obtain the credentials for the Clever Operator](./credentials.md) document.
Configuration options are available at two levels: global (applies to all namespaces) and namespace-specific.

### Global Configuration

Global configuration settings apply across all namespaces and are defined via environment variables or configuration files.
Global configuration settings apply across all namespaces. Global configuration can be provided through a `ConfigMap`, a `Secret` or by the environment.

- **Environment Variables:**

Expand Down Expand Up @@ -156,19 +224,16 @@ Namespace-level configurations override the global settings for specific namespa
apiVersion: v1
kind: Secret
metadata:
name: clever-operator
namespace: my-namespace
data:
config: |-
api:
endpoint: "https://api.clever-cloud.com/v2"
token: "<your-api-token>"
secret: "<your-api-secret>"
consumerKey: "<your-consumer-key>"
consumerSecret: "<your-consumer-secret>"
proxy:
host: "proxy.example.com"
port: 8080
name: clever-secret
namespace: <your_namespace>
stringData:
config: |
[api]
endpoint = "https://api.clever-cloud.com/v2"
token = <your_token>
secret = <your_secret>
consumerKey = <your_consumer_key>
consumerSecret = <your_consumer_secret>
```

- **Applying the Configuration:** Apply the Secret to your namespace:
Expand Down

0 comments on commit fd918f2

Please sign in to comment.