Skip to content

Commit

Permalink
docs(srv): add containers api/cli + fix indent in function MTA-3950
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyOubouaziz committed Dec 5, 2023
1 parent 1dfa8de commit 0de4bff
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 233 deletions.
110 changes: 43 additions & 67 deletions serverless/containers/api-cli/deploy-container-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,85 +29,61 @@ Refer to the [Scaleway Developers website](https://www.scaleway.com/en/developer

1. Run the following command in your terminal to create a containers namespace:

```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_NAMESPACE_NAME>",
"project_id": "YOUR_PROJECT_ID"
}' \
"https://api.scaleway.com/containers/v1beta1/regions/fr-par/ namespaces"
```

An output similar to the following displays:

```json
{"id":"example-fb93-43e3-a036-7be69f1af7a1", "name":"your-namespace-name", "environment_variables":{}, "organization_id":"example-776f-4f65-a41e-6c5fc58b4076", "project_id":"example-c162-43f7-bb3e-1182e6f12342", "status":"pending", "registry_namespace_id":"", "error_message":null, "registry_endpoint":"", "description":"", "secret_environment_variables":[], "region":"fr-par"}%
```
```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_NAMESPACE_NAME>",
"project_id": "YOUR_PROJECT_ID"
}' \
"https://api.scaleway.com/containers/v1beta1/regions/fr-par/namespaces"
```

2. Run the following command to create a container:
An output similar to the following displays:

```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_CONTAINER_NAME>",
"namespace_id": "<YOUR_NAMESPACE_ID>",
"runtime": "<RUNTIME>"
}' \
"https://api.scaleway.com/containers/v1beta1/regions/fr-par/containers"
```

An output similar to the following displays:

```json
{"id":"ef777a64-1f4e-4d43-8227-26927c7de057", "name":"your-container-name", "namespace_id":"example-fb93-43e3-a036-7be69f1af7a1", "status":"created", "environment_variables":{}, "min_scale":0, "max_scale":5, "runtime":"python310", "memory_limit":256, "cpu_limit":140, "timeout":"300s", "handler":"handler.handle", "error_message":null, "privacy":"public", "description":"", "domain_name":"namespaceg04rnwx-container-example.containers.cnt.fr-par.scw.cloud", "secret_environment_variables":[], "http_option":"enabled", "runtime_message":"", "build_message":null, "region":"fr-par"}%
```

3. Create a zip file containing your container's code by following [this procedure](/serverless/containers/how-to/package-container-dependencies-in-zip/).

<Message type="note">
For testing purposes, you can create a zip archive with a simple Python file named `handler.py` inside, that contains the following code:

```python
def handle(event, context):
return {
"body": {
"message": 'Hello, world',
},
"statusCode": 200,
}
```json
{"id":"example-fb93-43e3-a036-7be69f1af7a1", "name":"your-namespace-name", "environment_variables":{}, "organization_id":"example-776f-4f65-a41e-6c5fc58b4076", "project_id":"example-c162-43f7-bb3e-1182e6f12342", "status":"pending", "registry_namespace_id":"", "error_message":null, "registry_endpoint":"", "description":"", "secret_environment_variables":[], "region":"fr-par"}%
```
</Message>

4. Upload your zip file [using the Scaleway console](/serverless/containers/how-to/package-container-dependencies-in-zip/#how-to-upload-your-zip-file-to-the-scaleway-console) or [using the Scaleway API](/serverless/containers/how-to/package-container-dependencies-in-zip/#how-to-upload-your-zip-file-using-the-scaleway-api).

5. Run the following command to deploy your container:
2. Run the following command to create a container:

```json
curl -X POST \
```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{}' \
"https://api.scaleway.com/containers/v1beta1/regions/fr-par/containers/<YOUR_CONTAINER_ID>/deploy"
```
-d '{
"name": "<YOUR_CONTAINER_NAME>",
"namespace_id": "<YOUR_NAMESPACE_ID>",
"runtime": "<RUNTIME>"
}' \
"https://api.scaleway.com/containers/v1beta1/regions/fr-par/containers"
```

Your container is now being deployed.
An output similar to the following displays:

<Message type="tip">
You can check the status of your container from the [Scaleway console](https://www.console/scaleway.com/) or by running the following command:
```json
{"id":"ef777a64-1f4e-4d43-8227-26927c7de057", "name":"your-container-name", "namespace_id":"example-fb93-43e3-a036-7be69f1af7a1", "status":"created", "environment_variables":{}, "min_scale":0, "max_scale":5, "runtime":"python310", "memory_limit":256, "cpu_limit":140, "timeout":"300s", "handler":"handler.handle", "error_message":null, "privacy":"public", "description":"", "domain_name":"namespaceg04rnwx-container-example.containers.cnt.fr-par.scw.cloud", "secret_environment_variables":[], "http_option":"enabled", "runtime_message":"", "build_message":null, "region":"fr-par"}%
```

<Message type="note">
For testing purposes, you can use the `"registry_image": "nginx:latest"` and `"port": "80"` parameters to quickly create a container.
</Message>

3. Run the following command to deploy your container:

```json
curl -X GET \
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
"https://api.scaleway.com/containers/v1beta1/regions/fr-par/containers/<YOUR_CONTAINER_ID>"
-H "Content-Type: application/json" \
-d '{}' \
"https://api.scaleway.com/containers/v1beta1/regions/fr-par/containers/<YOUR_CONTAINER_ID>/deploy"
```
</Message>
The deployment process can take several minutes depending on the image used.
4. Run the following command to call your container once it is deployed:

6. Run the following command to call your container once it is deployed:
```bash
curl <YOUR_CONTAINER_ENDPOINT>
```

```bash
curl <YOUR_CONTAINER_ENDPOINT>
```
Your container is now deployed and ready to use.
68 changes: 36 additions & 32 deletions serverless/containers/api-cli/deploy-container-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ categories:

1. Open a terminal and type the following command to configure the Scaleway CLI on your machine:

```
```bash
scw init
```

Expand Down Expand Up @@ -88,29 +88,29 @@ categories:

1. Run the following command in your terminal to create a containers namespace:

```
scw container namespace create name=<YOUR_NAMESPACE_NAME>
```

An output similar to the following displays:

```
ID 6e74dbb7-9323-46bb-abc7-5c0105f4e70e
Name <YOUR_NAMESPACE_NAME>
OrganizationID 55e28409-776f-4f65-a41e-6c5fc58b4076
ProjectID 55e28409-776f-4f65-a41e-6c5fc58b4076
Status pending
RegistryNamespaceID -
RegistryEndpoint -
Description -
Region fr-par
```

3. Run the following command in your terminal to create a container:

```
scw container container create name=<CONTAINER_NAME> namespace-id=<NAMESPACE_ID> registry-image=<IMAGE_REGISTRY_URL>
```
```bash
scw container namespace create name=<YOUR_NAMESPACE_NAME>
```

An output similar to the following displays:
```
ID 6e74dbb7-9323-46bb-abc7-5c0105f4e70e
Name <YOUR_NAMESPACE_NAME>
OrganizationID 55e28409-776f-4f65-a41e-6c5fc58b4076
ProjectID 55e28409-776f-4f65-a41e-6c5fc58b4076
Status pending
RegistryNamespaceID -
RegistryEndpoint -
Description -
Region fr-par
```

2. Run the following command in your terminal to create a container:

```bash
scw container container create name=<CONTAINER_NAME> namespace-id=<NAMESPACE_ID> registry-image=<IMAGE_REGISTRY_URL>
```

An output similar to the following displays:

Expand All @@ -134,20 +134,24 @@ categories:
RuntimeMessage -
```

<Message type="note">
For testing purposes, you can use the `registry-image=nginx:latest` and `port=80` parameters to quickly create a container.
</Message>

## Deploying a container

1. Run the following command to deploy your container with the zip archive you just created:

```
scw container container deploy <CONTAINER_ID>
```
```bash
scw container container deploy <CONTAINER_ID>
```

The deployment process can take several minutes depending on the image used.
The deployment process can take several minutes depending on the image used.

2. Run the following command to call your container:

```bash
curl <YOUR_CONTAINER_ENDPOINT>
```
```bash
curl <YOUR_CONTAINER_ENDPOINT>
```

Your container is now deployed and ready to be used.
Your container is now deployed and ready to be used.
126 changes: 63 additions & 63 deletions serverless/functions/api-cli/deploy-function-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,85 +29,85 @@ Refer to the [Scaleway Developers website](https://www.scaleway.com/en/developer

1. Run the following command in your terminal to create a functions namespace:

```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_NAMESPACE_NAME>",
"project_id": "YOUR_PROJECT_ID"
}' \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/ namespaces"
```

An output similar to the following displays:

```json
{"id":"example-fb93-43e3-a036-7be69f1af7a1", "name":"your-namespace-name", "environment_variables":{}, "organization_id":"example-776f-4f65-a41e-6c5fc58b4076", "project_id":"example-c162-43f7-bb3e-1182e6f12342", "status":"pending", "registry_namespace_id":"", "error_message":null, "registry_endpoint":"", "description":"", "secret_environment_variables":[], "region":"fr-par"}%
```
```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_NAMESPACE_NAME>",
"project_id": "YOUR_PROJECT_ID"
}' \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/ namespaces"
```

2. Run the following command to create a function:
An output similar to the following displays:

```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_FUNCTION_NAME>",
"namespace_id": "<YOUR_NAMESPACE_ID>",
"runtime": "<RUNTIME>"
}' \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/functions"
```
```json
{"id":"example-fb93-43e3-a036-7be69f1af7a1", "name":"your-namespace-name", "environment_variables":{}, "organization_id":"example-776f-4f65-a41e-6c5fc58b4076", "project_id":"example-c162-43f7-bb3e-1182e6f12342", "status":"pending", "registry_namespace_id":"", "error_message":null, "registry_endpoint":"", "description":"", "secret_environment_variables":[], "region":"fr-par"}%
```

An output similar to the following displays:
2. Run the following command to create a function:

```json
{"id":"ef777a64-1f4e-4d43-8227-26927c7de057", "name":"your-function-name", "namespace_id":"example-fb93-43e3-a036-7be69f1af7a1", "status":"created", "environment_variables":{}, "min_scale":0, "max_scale":5, "runtime":"python310", "memory_limit":256, "cpu_limit":140, "timeout":"300s", "handler":"handler.handle", "error_message":null, "privacy":"public", "description":"", "domain_name":"namespaceg04rnwx-function-example.functions.fnc.fr-par.scw.cloud", "secret_environment_variables":[], "http_option":"enabled", "runtime_message":"", "build_message":null, "region":"fr-par"}%
```
```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_FUNCTION_NAME>",
"namespace_id": "<YOUR_NAMESPACE_ID>",
"runtime": "<RUNTIME>"
}' \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/functions"
```

3. Create a zip file containing your function's code by following [this procedure](/serverless/functions/how-to/package-function-dependencies-in-zip/).
An output similar to the following displays:

<Message type="note">
For testing purposes, you can create a zip archive with a simple Python file named `handler.py` inside, that contains the following code:

```python
def handle(event, context):
return {
"body": {
"message": 'Hello, world',
},
"statusCode": 200,
}
```json
{"id":"ef777a64-1f4e-4d43-8227-26927c7de057", "name":"your-function-name", "namespace_id":"example-fb93-43e3-a036-7be69f1af7a1", "status":"created", "environment_variables":{}, "min_scale":0, "max_scale":5, "runtime":"python310", "memory_limit":256, "cpu_limit":140, "timeout":"300s", "handler":"handler.handle", "error_message":null, "privacy":"public", "description":"", "domain_name":"namespaceg04rnwx-function-example.functions.fnc.fr-par.scw.cloud", "secret_environment_variables":[], "http_option":"enabled", "runtime_message":"", "build_message":null, "region":"fr-par"}%
```
</Message>

4. Upload your zip file [using the Scaleway console](/serverless/functions/how-to/package-function-dependencies-in-zip/#how-to-upload-your-zip-file-to-the-scaleway-console) or [using the Scaleway API](/serverless/functions/how-to/package-function-dependencies-in-zip/#how-to-upload-your-zip-file-using-the-scaleway-api).
3. Create a zip file containing your function's code by following [this procedure](/serverless/functions/how-to/package-function-dependencies-in-zip/).

5. Run the following command to deploy your function:
<Message type="note">
For testing purposes, you can create a zip archive with a simple Python file named `handler.py` inside, that contains the following code:

```json
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{}' \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/functions/<YOUR_FUNCTION_ID>/deploy"
```
```python
def handle(event, context):
return {
"body": {
"message": 'Hello, world',
},
"statusCode": 200,
}
```
</Message>

Your function is now being deployed.
4. Upload your zip file [using the Scaleway console](/serverless/functions/how-to/package-function-dependencies-in-zip/#how-to-upload-your-zip-file-to-the-scaleway-console) or [using the Scaleway API](/serverless/functions/how-to/package-function-dependencies-in-zip/#how-to-upload-your-zip-file-using-the-scaleway-api).

<Message type="tip">
You can check the status of your function from the [Scaleway console](https://www.console/scaleway.com/) or by running the following command:
5. Run the following command to deploy your function:

```json
curl -X GET \
curl -X POST \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/functions/<YOUR_FUNCTION_ID>"
-H "Content-Type: application/json" \
-d '{}' \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/functions/<YOUR_FUNCTION_ID>/deploy"
```
</Message>

Your function is now being deployed.

<Message type="tip">
You can check the status of your function from the [Scaleway console](https://www.console/scaleway.com/) or by running the following command:

```json
curl -X GET \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
"https://api.scaleway.com/functions/v1beta1/regions/fr-par/functions/<YOUR_FUNCTION_ID>"
```
</Message>

6. Run the following command to call your function once it is deployed:

```bash
curl <YOUR_FUNCTION_ENDPOINT>
```
```
curl <YOUR_FUNCTION_ENDPOINT>
```
Loading

0 comments on commit 0de4bff

Please sign in to comment.