Skip to content

Commit f32292f

Browse files
committed
feat(container) add push image on registry and enhancements
Co-authored-by: Rémy Léone <[email protected]> Update scaleway/resource_container.go Co-authored-by: Rémy Léone <[email protected]> Update scaleway/resource_container.go Co-authored-by: Rémy Léone <[email protected]> Update scaleway/resource_container.go Co-authored-by: Rémy Léone <[email protected]> Update scaleway/resource_container.go Co-authored-by: Rémy Léone <[email protected]> Update scaleway/resource_container.go Co-authored-by: Rémy Léone <[email protected]> fix(containers): add documentation and enhance resource
1 parent 954fbfe commit f32292f

20 files changed

+1829
-2596
lines changed

.github/workflows/acceptance-tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
TF_ACC: 1
4040
TF_UPDATE_CASSETTES: false
4141
TF_TEST_DOMAIN: scaleway-terraform.com
42+
TF_TEST_DOCKER_IMG: docker.io/library/alpine
4243
SCW_DEBUG: 0
4344
SCW_ACCESS_KEY: "SCWXXXXXXXXXXXXXFAKE"
4445
SCW_SECRET_KEY: "11111111-1111-1111-1111-111111111111"

.github/workflows/nightly.yml

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
# Enable recording with the cassette system. By doing so, we ensure that real HTTPS requests are made.
4444
TF_UPDATE_CASSETTES: true
4545
TF_TEST_DOMAIN: scaleway-terraform.com
46+
TF_TEST_DOCKER_IMG: docker.io/library/alpine
4647
SCW_DEBUG: 1
4748
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
4849
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
@@ -66,6 +67,7 @@ jobs:
6667
run: make sweep
6768
env:
6869
TF_TEST_DOMAIN: scaleway-terraform.com
70+
TF_TEST_DOCKER_IMG: docker.io/library/alpine
6971
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
7072
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
7173
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}

TESTING.md

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ You can force the test domain with an environment var:
4646
export TF_TEST_DOMAIN=your-domain.tld
4747
```
4848

49+
For testing the container API with your own image you can force the environment var:
50+
51+
```shell
52+
export TF_TEST_DOCKER_IMG=your_image
53+
```
54+
4955
To ease debugging you can also set:
5056
```sh
5157
export TF_LOG=DEBUG

docs/data-sources/container.md

+17-23
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,33 @@ resource scaleway_container main {
3535
max_concurrency = 80
3636
privacy = "private"
3737
protocol = "h2c"
38-
redeploy = true
38+
deploy = true
3939
4040
environment_variables = {
4141
"foo" = "var"
4242
}
4343
}
4444
```
4545

46-
4746
## Arguments Reference
4847

49-
The following arguments are supported:
48+
The following arguments are required:
49+
50+
- `name` - (Required) The unique name of the container name.
5051

51-
- `name` - (Required) The unique name of the container namespace.
52+
- `namespace_id` - (Required) The container namespace ID of the container.
5253

5354
~> **Important** Updates to `name` will recreate the container.
5455

55-
- `description` (Optional) The description of the container.
56+
## Attributes Reference
5657

57-
- `namespace_id` - (Required) The container namespace ID of the container.
58+
In addition to all arguments above, the following attributes are exported:
5859

59-
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which the namespace should be created.
60+
- `id` - The ID of the container
6061

61-
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the namespace is associated with.
62+
- `description` The description of the container.
6263

63-
- `environment_variables` - The environment variables of the container.
64+
- `environment_variables` - The [environment](https://www.scaleway.com/en/docs/compute/containers/concepts/#environment-variables) variables of the container.
6465

6566
- `min_scale` - The minimum of running container instances continuously. Defaults to 0.
6667

@@ -72,31 +73,24 @@ The following arguments are supported:
7273

7374
- `timeout` - The maximum amount of time in seconds during which your container can process a request before we stop it. Defaults to 300s.
7475

75-
- `privacy` - The privacy type access.
76+
- `privacy` - The privacy type define the way to authenticate to your container. Please check our dedicated [section](https://developers.scaleway.com/en/products/containers/api/#protocol-9dd4c8).
7677

7778
- `registry_image` - The registry image address. e.g: **"rg.fr-par.scw.cloud/$NAMESPACE/$IMAGE"**.
7879

79-
- `max_concurrency` - The maximum the number of simultaneous requests your container can handle at the same time. Defaults to 50.
80+
- `max_concurrency` - The maximum number of simultaneous requests your container can handle at the same time. Defaults to 50.
8081

8182
- `domain_name` - The container domain name.
8283

83-
- `protocol` - The communication protocol. Defaults to http1.
84+
- `protocol` - The communication [protocol](https://developers.scaleway.com/en/products/containers/api/#protocol-9dd4c8) http1 or h2c. Defaults to http1.
8485

8586
- `port` - The port to expose the container. Defaults to 8080.
8687

87-
- `redeploy` - Allow deploy container.
88-
88+
- `deploy` - Boolean indicating whether the container is on a production environment.
8989

90-
## Attributes Reference
91-
92-
In addition to all arguments above, the following attributes are exported:
93-
94-
- `id` - The ID of the container
95-
- `organization_id` - The organization ID the container is associated with.
9690
- `status` - The container status.
91+
9792
- `cron_status` - The cron status of the container.
93+
9894
- `error_message` - The error message of the container.
9995

100-
```bash
101-
$ terraform import scaleway_container.main fr-par/11111111-1111-1111-1111-111111111111
102-
```
96+
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) in which the container was created.

docs/resources/container.md

+67-32
Original file line numberDiff line numberDiff line change
@@ -38,62 +38,97 @@ data "scaleway_container" "by_id" {
3838
}
3939
```
4040

41-
## Argument Reference
41+
## Arguments Reference
4242

43-
- `name` - (Optional) The container name.
44-
Only one of `name` and `container_id` should be specified.
43+
The following arguments are required:
4544

46-
- `container_id` - (Optional) The container id.
47-
- `namespace_id` - (Required) The container namespace id
48-
Only one of `name` and `container_id` should be specified.
49-
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) in which the container exists.
50-
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the namespace is associated with.
45+
- `name` - (Required) The unique name of the container name.
5146

47+
- `namespace_id` - (Required) The container namespace ID of the container.
5248

53-
## Attributes Reference
49+
~> **Important** Updates to `name` will recreate the container.
5450

55-
In addition to all above arguments, the following attributes are exported:
51+
The following arguments are optional:
5652

57-
- `name` - The unique name of the container namespace.
53+
- `description` (Optional) The description of the container.
5854

59-
- `description` The description of the container.
55+
- `environment_variables` - (Optional) The [environment](https://www.scaleway.com/en/docs/compute/containers/concepts/#environment-variables) variables of the container.
6056

61-
- `namespace_id` - The container namespace ID of the container.
57+
- `min_scale` - (Optional) The minimum of running container instances continuously. Defaults to 0.
6258

63-
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which the namespace should be created.
59+
- `max_scale` - (Optional) The maximum of number of instances this container can scale to. Default to 20.
6460

65-
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the namespace is associated with.
61+
- `memory_limit` - (Optional) The memory computing resources in MB to allocate to each container. Defaults to 128.
6662

67-
- `environment_variables` - The environment variables of the container.
63+
- `cpu_limit` - (Optional) The amount of vCPU computing resources to allocate to each container. Defaults to 70.
6864

69-
- `min_scale` - The minimum of running container instances continuously. Defaults to 0.
65+
- `timeout` - (Optional) The maximum amount of time in seconds during which your container can process a request before we stop it. Defaults to 300s.
7066

71-
- `max_scale` - The maximum of number of instances this container can scale to. Default to 20.
67+
- `privacy` - (Optional) The privacy type define the way to authenticate to your container. Please check our dedicated [section](https://developers.scaleway.com/en/products/containers/api/#protocol-9dd4c8).
7268

73-
- `memory_limit` - The memory computing resources in MB to allocate to each container. Defaults to 128.
69+
- `registry_image` - (Optional) The registry image address. e.g: **"rg.fr-par.scw.cloud/$NAMESPACE/$IMAGE"**.
7470

75-
- `cpu_limit` - The amount of vCPU computing resources to allocate to each container. Defaults to 70.
71+
- `max_concurrency` - (Optional) The maximum number of simultaneous requests your container can handle at the same time. Defaults to 50.
7672

77-
- `timeout` - The maximum amount of time in seconds during which your container can process a request before we stop it. Defaults to 300s.
73+
- `domain_name` - (Optional) The container domain name.
7874

79-
- `privacy` - The privacy type access.
75+
- `protocol` - (Optional) The communication [protocol](https://developers.scaleway.com/en/products/containers/api/#protocol-9dd4c8) http1 or h2c. Defaults to http1.
8076

81-
- `registry_image` - The registry image address. e.g: **"rg.fr-par.scw.cloud/$NAMESPACE/$IMAGE"**.
77+
- `port` - (Optional) The port to expose the container. Defaults to 8080.
8278

83-
- `max_concurrency` - The maximum the number of simultaneous requests your container can handle at the same time. Defaults to 50.
79+
- `deploy` - (Optional) Boolean controlling whether the container is on a production environment.
8480

85-
- `domain_name` - The container domain name.
81+
Note that if you want to use your own configuration, you must consult our configuration [restrictions](https://www.scaleway.com/en/docs/compute/containers/reference-content/containers-limitations/#configuration-restrictions) section.
8682

87-
- `protocol` - The communication protocol. Defaults to http1.
83+
## Attributes Reference
8884

89-
- `port` - The port to expose the container. Defaults to 8080.
85+
In addition to all above arguments, the following attributes are exported:
9086

91-
- `redeploy` - Allow deploy container.
87+
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) in which the container was created.
88+
- `status` - The container status.
89+
- `cron_status` - The cron status of the container.
90+
- `error_message` - The error message of the container.
9291

93-
- `organization_id` - The organization ID the container is associated with.
92+
## Import
9493

95-
- `status` - The container status.
94+
Container can be imported using the container_name, e.g.,
9695

97-
- `cron_status` - The cron status of the container.
96+
```bash
97+
$ terraform import scaleway_container.main fr-par/11111111-1111-1111-1111-111111111111
98+
```
99+
100+
## Protocols
101+
102+
The supported protocols are:
103+
104+
* `h2c`: HTTP/2 over TCP.
105+
* `http1`: Hypertext Transfer Protocol.
106+
107+
**Important:** For details about the protocols check [this](https://httpd.apache.org/docs/2.4/howto/http2.html)
108+
109+
## Privacy
110+
111+
By default, creating a container will make it `public`, meaning that anybody knowing the endpoint could execute it.
112+
A container can be made `private` with the privacy parameter.
113+
114+
Please check our [authentication](https://developers.scaleway.com/en/products/containers/api/#protocol-9dd4c8) section
115+
116+
## Memory and vCPUs configuration
117+
118+
The vCPU represents a portion or share of the underlying, physical CPU that is assigned to a particular virtual machine (VM).
119+
120+
You may decide how much computing resources to allocate to each container.
121+
The `memory_limit` (in MB) must correspond with the right amount of vCPU.
122+
123+
**Important:** The right choice for your container's resources is very important, as you will be billed based on compute usage over time and the number of Containers executions.
124+
125+
Please check our [price](https://www.scaleway.com/en/docs/faq/serverless-containers/#prices) section for more details.
126+
127+
| Memory (in MB) | vCPU |
128+
| ----------- | ----------- |
129+
| 128 | 70m |
130+
| 256 | 140m |
131+
| 512 | 280m |
132+
| 1024 | 560m |
98133

99-
- `error_message` - The error message of the container.
134+
**Note:** 560mCPU accounts roughly for half of one CPU power of a Scaleway General Purpose instance

go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ require (
6767
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
6868
github.com/vmihailenco/tagparser v0.1.1 // indirect
6969
github.com/zclconf/go-cty v1.10.0 // indirect
70-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
70+
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
7171
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
7272
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
7373
golang.org/x/text v0.3.7 // indirect
74-
google.golang.org/appengine v1.6.6 // indirect
75-
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect
74+
google.golang.org/appengine v1.6.7 // indirect
75+
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
7676
google.golang.org/grpc v1.45.0 // indirect
7777
google.golang.org/protobuf v1.27.1 // indirect
7878
gopkg.in/yaml.v2 v2.4.0 // indirect

0 commit comments

Comments
 (0)