diff --git a/content/guides/clever-operator.md b/content/guides/clever-operator.md index 89d9ff79..e58d1339 100644 --- a/content/guides/clever-operator.md +++ b/content/guides/clever-operator.md @@ -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 = "" + secret = "" + consumerKey = "" + consumerSecret = "" +``` -### Installing via Helm Chart +Replacing ``, ``, `` and `` 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: "" + secret: "" + consumerKey: "" + consumerSecret: "" ``` - 3. Running the operator: +Replacing ``, ``, `` and `` 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=//clever-operator:latest make docker-build - ``` +{{% steps %}} -1. Pushing the image to your registry: +#### Clone the repository - ```bash - DOCKER_IMG=//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 = "" + secret = "" + consumerKey = "" + consumerSecret = "" +``` -4. Deploying to Kubernetes: - ```bash - make deploy-kubernetes - ``` +Replacing ``, ``, `` and `` 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:** @@ -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: "" - secret: "" - consumerKey: "" - consumerSecret: "" - proxy: - host: "proxy.example.com" - port: 8080 + name: clever-secret + namespace: + stringData: + config: | + [api] + endpoint = "https://api.clever-cloud.com/v2" + token = + secret = + consumerKey = + consumerSecret = ``` - **Applying the Configuration:** Apply the Secret to your namespace: