Skip to content

Commit 642aa2a

Browse files
authored
Merge pull request #8221 from ovh/MB-ai-deploy-tokens
[AI Deploy] - Access tokens guide update
2 parents db0115e + 5dbe5d2 commit 642aa2a

File tree

113 files changed

+1399
-871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1399
-871
lines changed
Lines changed: 95 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: AI Deploy - Accessing your app with tokens
3-
excerpt: Discover how to create a scoped token and query your AI Deploy app
4-
updated: 2023-04-04
2+
title: AI Deploy - Accessing your app with tokens (EN)
3+
excerpt: Learn how to create scoped tokens to securely access your AI Deploy applications
4+
updated: 2025-07-28
55
---
66

77
> [!primary]
@@ -13,92 +13,137 @@ updated: 2023-04-04
1313

1414
This guide covers the creation of application tokens for AI Deploy.
1515

16+
This is particularly useful when you want to make your app accessible to others without sharing your username and password. Moreover, using tokens facilitates the integration of your app with other services or scripts, such as those using curl, allowing for a more automated and flexible interaction with your AI Deploy application.
17+
18+
In this tutorial, we will create and assign tokens to a basic AI Deploy app, running the [infrastructureascode/hello-world](https://hub.docker.com/r/infrastructureascode/hello-world) Docker image.
19+
1620
## Requirements
1721

1822
- a **Public cloud** project
1923
- access to the [OVHcloud Control Panel](/links/manager)
20-
- a Running AI Deploy app (the deployed app in this guide uses the Docker image [infrastructureascode/hello-world](https://hub.docker.com/r/infrastructureascode/hello-world))
2124

2225
## Instructions
2326

24-
### Adding labels to an App
27+
By default, the following two labels are automatically added to each AI Deploy application:
2528

26-
Tokens are scoped based on labels added to your AI Deploy app. To scope a token you need to add a label to your AI Deploy app upon submission.
29+
- `ovh/id` whose value is the ID of the AI Deploy app
30+
- `ovh/type` whose value is `app`, the type of AI resource
2731

28-
![app add label](images/01-app-add-label.png){.thumbnail}
32+
> [!primary]
33+
> These labels are prefixed by `ovh/`, meaning these are reserved by the platform. These labels will be automatically overwritten by the platform if you attempt to redefine them during submission. They won't be displayed in the manager UI.
34+
>
2935
30-
In this instance we add the label `group=A` to the AI Deploy app. A set of defaults labels is added to all AI Deploy apps:
36+
In addition to these default labels, you can **create new ones** to further customize and secure your application access.
3137

32-
- `ovh/id` whose value is the ID of the AI Deploy app
33-
- `ovh/type` with value `app`, the type of AI resource
38+
### Adding labels to an app
3439

35-
> [!primary]
36-
> Labels prefixed by `ovh/` are reserved by the platform, those labels are overriden upon submission if any are provided.
40+
Tokens are scoped based on labels added to your AI Deploy app. To scope a token, you must add a label to your AI Deploy app. This can be done either during the app creation process or after the app is deployed. You can add multiple labels by repeating the following process.
3741

38-
All the labels of an AI Deploy app are listed on the AI Deploy app details under **Tags**:
42+
#### Adding label during app creation
3943

40-
![app dashboard](images/02-app-dashboard.png){.thumbnail}
44+
To add a label when creating an AI Deploy app, access the `Advanced Configuration`{.action} step in the app creation process. This section allows you to specify a custom Docker command, the mounted volumes, and **the app labels**.
4145

42-
### Generating tokens
46+
From this last sub-section, you can add a key-value pair. The key is the label identifier (e.g., `group`), while the value is the corresponding value assigned to this key (e.g., `A`). In this tutorial, we use the example `group=A` as the label of the AI Deploy app:
4347

44-
From the **AI Deploy** page, you access the tokens management page by clicking the `Tokens`{.action} tab.
48+
![app add label](images/01-app-add-label.png){.thumbnail}
4549

46-
![app list](images/03-app-list.png)
50+
Once created, all the labels of an AI Deploy app are listed on the app details, under **Labels** field:
4751

48-
Once on the token management tab, simply click on `New Token`{.action}.
52+
![app dashboard](images/02-app-dashboard.png){.thumbnail}
4953

50-
![token list new](images/04-token-list-new-2.png){.thumbnail}
54+
#### Adding label to an existing app
55+
56+
If your app is already deployed, you can still add or update labels at any time using the Control Panel (UI) or the `ovhai` CLI.
57+
58+
> [!tabs]
59+
> **Using the Control Panel (UI)**
60+
>>
61+
>> Navigate to the **AI Deploy** section where all your apps are listed. **Click the name of your app** to open its details page. Locate the **Labels** section. Enter the key-value pair and click `+`{.action} to add the label to your app.
62+
>>
63+
>> ![image](images/03-app-add-label-existing-app.png){.thumbnail}
64+
>>
65+
>> After saving, the added label will be visible in the **Labels** section of the app details.
66+
>>
67+
> **Using ovhai CLI**
68+
>>
69+
>> To follow this section, make sure you have installed the [ovhai CLI](/pages/public_cloud/ai_machine_learning/cli_10_howto_install_cli) on your computer or on an instance.
70+
>>
71+
>> You can also add labels to an existing app using the `ovhai` CLI. Run the following command:
72+
>>
73+
>> ```console
74+
>> ovhai app set-label <app_id> <name> <value>
75+
>> ```
76+
>>
77+
>> Replace <app_id> with the unique identifier of your app (found in the app details or by running `ovhai app ls`). And replace <name> and <value> with your desired key and value pair. For example:
78+
>>
79+
>> ```console
80+
>> ovhai app set-label a8318623-8357-48b4-bd3b-648c3e343ec9 group A
81+
>> ```
82+
>>
83+
>> This command adds the label `group=A` to the app with ID `a8318623-8357-48b4-bd3b-648c3e343ec9`.
84+
>>
85+
>> You can verify app labels by running `ovhai app get <app_id>`. Labels will be displayed at the top of app details, in the *Labels* field.
5186
52-
#### Read token
87+
### Generating tokens
5388
54-
There are two types of roles that can be assigned to a token:
89+
From the **AI Dashboard** page, you can access the tokens management page by clicking on the `Tokens`{.action} tab. From there, you can click on the `+ Create a token`{.action} button to create a new token:
5590
56-
- AI Platform - Read-only
57-
- AI Platform - Operator
91+
![token list new](images/04-token-list.png){.thumbnail}
5892
59-
A Read-only token will only grant you the right to query the deployed app while an Operator token would also allow you to manage the AI Deploy app itself.
93+
There are two types of roles that can be assigned to a token:
6094
61-
Let us create a token for the AI Deploy apps matching the label `group=A` with read-only access in the GRA cluster.
62-
To create an AI Deploy app token we need to specify 3 parameters:
95+
- **AI Platform - Reader**: allows only querying the app
96+
- **AI Platform - Operator**: allows querying and full lifecycle management (start/stop/delete)
6397
64-
- The token scope is specified through label selectors, and a token will be scoped over any app matching the set of label selectors. In this case `group=A`
65-
- The token role: AI Training - Read-only
66-
- The region (cluster in which are deployed the AI Deploy apps): GRA.
98+
#### Read token
6799
68-
Fill out the form:
100+
Let's create a token for the AI Deploy apps matching the label `group=A` with read-only access in the GRA (Gravelines) cluster. To do this, we will need to fill 4 parameters:
69101
70102
![token generation input read](images/05-token-gen-input-read.png){.thumbnail}
71103
72-
Click `Generate`{.action}. Upon success, you are redirected to the token list with the newly generated token displayed at the top:
73-
74-
![token generation result](images/06-token-gen-result-read.png){.thumbnail}
104+
- **Token name**: used for token identification, management only.
105+
- **Label selector**: determines which apps the token applies to (e.g., `group=A`).
106+
- **Role**: choose from:
107+
- `AI Reader`: read-only
108+
- `AI Operator`: read & manage
109+
- **Region**: e.g., `GRA` (for Gravelines)
75110
76-
Save the token string for later use.
111+
After completing the form, click `Generate`{.action} to confirm the token creation.
77112
78113
> [!warning]
79-
> The token is only displayed once, make sure to save it before leaving the page or you will need to regenerate the token.
114+
> You will then receive the value of your new token, which you must **carefully save**, as its value is only displayed once. If you lose the token value, you will need to [regenerate it](#regenerating-a-token).
115+
116+
You will then be redirected to the token list, where the newly generated token will be displayed at the top:
117+
118+
![token generation result](images/06-token-gen-result-read.png){.thumbnail}
80119
81120
This newly generated token provides read access over all resources tagged with the label `group=A` including the ones submitted after the creation of the token.
82121
83-
#### Operator token
122+
If you prefer working from the command line, you can generate the same token using the `ovhai` CLI:
84123
85-
An operator token grants read access along with management access for the matching apps. This means that you can manage the AI Deploy app lifecycle (start/stop/delete) using either the CLI (more info [here](/pages/public_cloud/ai_machine_learning/cli_10_howto_install_cli)) or the [AI Training API](https://gra.ai.cloud.ovh.net/) by providing this token.
124+
```console
125+
ovhai token create reader-token --role read --label-selector group=A
126+
```
86127
87-
This Operator token will be scoped on a specific AI Deploy app and we will use the default `ovh/id` label to do so (since it is reserved, there is only one AI Deploy app that can match this label selector).
128+
#### Operator token
88129

89-
- Token scope: `ovh/id=4c4f6253-a059-424a-92da-5e06a12ddffd`
90-
- The token role: AI Training - Operator
91-
- The region: GRA.
130+
An operator token grants read access along with management access for the matching apps. This allows you to manage the AI Deploy app lifecycle (start/stop/delete) using either the CLI (more info [here](/pages/public_cloud/ai_machine_learning/cli_10_howto_install_cli)) or the [AI API](https://gra.ai.cloud.ovh.net/) by providing this token.
92131

93132
![token generation input operator](images/07-token-gen-input-op.png){.thumbnail}
94133

95-
Additional information about the use of a token to manage an AI Training resource can be found [here](/pages/public_cloud/ai_machine_learning/cli_13_howto_app_token_cli#use-the-app-token).
134+
Equivalent CLI command is:
135+
136+
```console
137+
ovhai token create operator-token --role operator --label-selector group=A
138+
```
139+
140+
You can also scope a token to a specific app using the `ovh/id` label and the app’s ID as its value. This label is added automatically by default as explained [above](#instructions) and, because it is reserved, it will uniquely match only one app.
96141

97142
### Using a token to query an AI Deploy app
98143

99144
With the token we generated in the previous step, we will now query the app. For this demonstration, we deployed a simple Hello World app that always responds `Hello, World!`.
100145

101-
You can get the access URL of your app in the details of the AI Deploy app, above the **Tags**.
146+
You can get the access URL of your app in the details of the AI Deploy app, above the **Labels**.
102147

103148
#### Browser
104149

@@ -114,7 +159,7 @@ You now land on the exposed AI Deploy app service:
114159

115160
#### Code integration
116161

117-
You can also directly CURL the AI Deploy app using the token as an `Authorization` header:
162+
You can also use CURL to directly query the AI Deploy app using the token as an `Authorization` header:
118163

119164
```bash
120165
export TOKEN=<your-token>
@@ -137,7 +182,7 @@ From the list of tokens, click on the action menu and select `Regenerate`{.actio
137182

138183
![token regenerate](images/08-token-list-regen.png){.thumbnail}
139184

140-
Then click on `Regenerate`{.action} to confirm.
185+
Then click on `Confirm`{.action}:
141186

142187
![token regenerate confirm](images/09-token-regen-confirm.png){.thumbnail}
143188

@@ -147,8 +192,12 @@ If you simply need to invalidate the token, you can delete it using the same act
147192

148193
![token delete](images/10-token-list-delete.png)
149194

195+
## Go further
196+
197+
Additional information about the use of a token to manage AI Solutions using `ovhai` CLI can be found [here](/pages/public_cloud/ai_machine_learning/cli_13_howto_app_token_cli).
198+
150199
## Feedback
151200

152201
Please feel free to send us your questions, feedback and suggestions to help our team improve the service on the OVHcloud [Discord server](https://discord.gg/ovhcloud)
153202

154-
If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](/links/professional-services) to get a quote and ask our Professional Services experts for a custom analysis of your project.
203+
If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](/links/professional-services) to get a quote and ask our Professional Services experts for a custom analysis of your project.

0 commit comments

Comments
 (0)