Skip to content

Commit

Permalink
23 configuration options for autoscaling (#27)
Browse files Browse the repository at this point in the history
* feat(sdk): update sdk scaleway (#26)

Signed-off-by: Alexandre Philibeaux <[email protected]>

* feat(container): add options for autoscaling

Signed-off-by: Alexandre Philibeaux <[email protected]>

---------

Signed-off-by: Alexandre Philibeaux <[email protected]>
  • Loading branch information
philibea authored Jul 3, 2024
1 parent b51a5e6 commit 8ba34b7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ You can can setup this namespace with our cli `scw containers namespace create`

### simple deploy

| input name | value |
| ------------------ | -------------------------------------- |
| type | deploy (default value ) |
| scw_registry | rg.fr-par.scw.cloud/test/images:latest |
| scw_region | fr-par (default value) |
| scw_container_port | 80 (default value ) |
| scw_memory_limit | 256 (default value ) |
| input name | value |
| -------------------- | -------------------------------------- |
| type | deploy (default value ) |
| scw_registry | rg.fr-par.scw.cloud/test/images:latest |
| scw_region | fr-par (default value) |
| scw_container_port | 80 (default value ) |
| scw_memory_limit | 256 (default value ) |
| scw_cpu_limit | 256 (default value ) |
| scw_min_scale | 1 (default value ) |
| scw_max_scale | 5 (default value ) |
| scw_max_concurrency | 5 (default value ) |
| scw_cpu_limit | 70 (default value ) |

```bash
on: [push]
Expand Down
10 changes: 10 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ inputs:
description: "Max Scale of the Container"
required: false
default: "5"
scw_cpu_limit:
description: "CPU Limit of the Container"
required: false
default: "70"
scw_max_concurrency:
description: "Max Concurrency of the Container"
required: false
default: "5"
scw_dns:
description: "DNS name where your container will be available. Limitation: 63 char maximun"
required: false
Expand Down Expand Up @@ -84,6 +92,8 @@ runs:
- ${{ inputs.scw_memory_limit }}
- ${{ inputs.scw_min_scale }}
- ${{ inputs.scw_max_scale }}
- ${{ inputs.scw_cpu_limit }}
- ${{ inputs.scw_max_concurrency }}
- ${{ inputs.scw_dns }}
- ${{ inputs.scw_dns_prefix }}
- ${{ inputs.root_zone }}
Expand Down
7 changes: 6 additions & 1 deletion container.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,24 @@ func CreateContainerAndDeploy(
port, _ := strconv.ParseInt(envOr(EnvContainerPort, fmt.Sprint(Port)), 10, 32)
memoryLimit, _ := strconv.ParseInt(envOr(EnvMemoryLimit, fmt.Sprint(MemoryLimit)), 10, 32)
minScale, _ := strconv.ParseInt(envOr(EnvMinScale, fmt.Sprint(MinScale)), 10, 32)
maxScale, _ := strconv.ParseInt(envOr(EnvMinScale, fmt.Sprint(MinScale)), 10, 32)
maxScale, _ := strconv.ParseInt(envOr(EnvMaxScale, fmt.Sprint(MaxScale)), 10, 32)
maxConcurrency, _ := strconv.ParseInt(envOr(EnvMaxConcurrency, fmt.Sprint(MaxConcurrency)), 10, 32)
cpuLimit, _ := strconv.ParseInt(envOr(EnvMaxConcurrency, fmt.Sprint(MaxConcurrency)), 10, 32)

Port := uint32(port)
MemoryLimit := uint32(memoryLimit)
MinScale := uint32(minScale)
MaxScale := uint32(maxScale)
MaxConcurrency := uint32(maxConcurrency)
CPULimit := uint32(cpuLimit)

createdContainer, err := api.CreateContainer(&container.CreateContainerRequest{
Description: &Description,
MaxConcurrency: &MaxConcurrency,
MemoryLimit: &MemoryLimit,
MinScale: &MinScale,
MaxScale: &MaxScale,
CPULimit: &CPULimit,
Name: ContainerName,
NamespaceID: NamespaceContainer.ID,
Port: &Port,
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ const (
EnvContainerNamespaceID = "INPUT_SCW_CONTAINERS_NAMESPACE_ID"
EnvContainerPort = "INPUT_SCW_CONTAINER_PORT"
EnvDNS = "INPUT_SCW_DNS"
EnvDNSPrefix = "INPUT_SCW_DNS_PREFIX"
EnvDNSPrefix = "INPUT_SCW_DNS_PREFIX"
EnvRegion = "INPUT_SCW_REGION"
EnvPathRegistry = "INPUT_SCW_REGISTRY"
EnvProjectID = "INPUT_SCW_PROJECT_ID"
EnvSecretKey = "INPUT_SCW_SECRET_KEY"
EnvMemoryLimit = "INPUT_SCW_MEMORY_LIMIT"
EnvMinScale = "INPUT_SCW_MIN_SCALE"
EnvMaxScale = "INPUT_SCW_MAX_SCALE"
EnvMaxConcurrency = "INPUT_SCW_MAX_CONCURRENCY"
EnvCPULimit = "INPUT_SCW_CPU_LIMIT"
EnvRootZone = "INPUT_ROOT_ZONE"
EnvEnvironmentVariables = "INPUT_SCW_ENVIRONMENT_VARIABLES"
EnvSecrets = "INPUT_SCW_SECRETS"
Expand All @@ -35,6 +37,7 @@ var (
MaxScale uint32 = 5
MaxConcurrency uint32 = 5
MemoryLimit uint32 = 256
CPULimit uint32 = 70
Timeout scw.Duration = scw.Duration{
Seconds: 60,
Nanos: 0,
Expand Down

0 comments on commit 8ba34b7

Please sign in to comment.