How to use Kubernetes External Secrets Operator with Secret Manager
Objective
This guide explains how to set up the Kubernetes External Secret Operator to use the OVHcloud Secret Manager as a provider.
Requirements
- An OVHcloud customer account.
- You must have ordered an OKMS domain or created a first secret.
- A Managed Kubernetes Service cluster.
Instructions
Set up the Secret Manager
To allow access to the Secret Manager you will need to have a token, the region and okms-id of your Secret Manager.
Credential creation
Create an IAM local user with access rights on your domain.
The user should be a member of a group with the ADMIN role. If you are using IAM policies instead, the user should have at least the following rights on the OKMS domain:
okms:apikms:secret/createokms:apikms:secret/version/getDataokms:apiovh:secret/get
Alternatively, it's possible to create a user using OVHcloud CLI:
Then create a Personal Acces Token (PAT) user_pat:
Use the following API call:
With the following payload (fill it in with your own values):
The API will answer with:
The PAT can be created with the OVHcloud CLI and the following command (fill in it with your own values):
CLI will answer with the token value:
As an alternative, you can store directly the PAT in a environment variable:
Keep the value of the token field as it will never be prompted again and will be used to authenticate to the Secret Manager as user_pat.
Secret Manager information
You will also need the region and the okms-id of the OKMS domain you want to use. This ID and this region can be found in the OVHcloud Control Panel or via the OVHcloud CLI:
Set up the Secret Provider in Kubernetes
Install the External Secret Operator (ESO) on your Kubernetes cluster
Check that the ESO is running:
Create a secret containing the PAT
Start by encoding your user_pat in base 64 so it can be stored in a Kubernetes secret.
Alternatively, if the user_pat was stored in an environment variable:
Then create a secret.yaml file:
And apply it with the kubectl apply -f secret.yaml command.
Alternatively, if you are using an environment variable:
The secret should have been created:
Configure the External Secret Operator
First, set up a ClusterSecretStore that is responsible of the synchronization with the Secret Manager.
We configure the SecretStore using HashiCorp Vault with token authentification and with the OKMS endpoint as backend.
Add the user_pat as a secret to be able to use it in the charts.
To define a new ClusterSecretStore resource, create a clustersecretstore.yaml file with the following content:
Only token authentication is supported.
This integration works with a SecretStore as well.
The region name can be translated from your region location using:
As an example for Europe (France - Paris), the OKMS endpoint is eu-west-par.okms.ovh.net.
Deploy the resource in your cluster:
Use the External Secret Operator
Once the ClusterSecretStore is set up you can define the ExternalSecret that comes from the secret manager.
Create an externalsecret.yaml file with this content:
Apply the resource in your cluster:
It will create a Kubernetes Secret object.
For any additional information on how to manage the External Secret Operator, refer to the dedicated documentation, using the HashiCorp Vault provider: https://external-secrets.io/latest/.
Go further
Join our community of users.