Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/snapshots/APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
torrefatto committed Sep 26, 2024
2 parents dd262d4 + 645fb03 commit 49ecef2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
11 changes: 7 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
## v5.1.0 (unreleased)

* Add `--deployment-strategy` which can have the value `rolling`, `canary`, `blue-green` or `immediate` to service.
- https://github.com/koyeb/koyeb-cli/pull/248/files
## v5.2.0 (unreleased)
* Add the `snapshots` subcommand to manage volume snapshots.
- https://github.com/koyeb/koyeb-cli/pull/250/files

## v5.1.0 (2024-09-26)

* Add `--deployment-strategy` which can have the value `rolling`, `blue-green` or `immediate` to service.
- https://github.com/koyeb/koyeb-cli/pull/248/files
* Fix the logic on how validation is performed for `--port` to avoid raising an error when `TCP` ports are used and `--routes` are not set.

## v5.0.0 (2024-08-20)

* Breaking change: the application name needs to be provided with `koyeb db` commands. In the past, the command `koyeb db create mydb` created a database named `mydb` under the hardcoded application `koyeb-db-preview-app`. With this new version, it is mandatory to specify the service name, for example with `koyeb db create myapp/mydb` or `koyeb db create mydb --app myapp`.
Expand Down
8 changes: 4 additions & 4 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ See examples of koyeb service create --help
--checks-grace-period strings Set healthcheck grace period in seconds.
Use the format <healthcheck>=<seconds>, for example --checks-grace-period 8080=10
--deployment-strategy STRATEGY Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--deployment-strategy string Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--docker string Docker image
--docker-args strings Set arguments to the docker command. To provide multiple arguments, use the --docker-args flag multiple times.
--docker-command string Set the docker CMD explicitly. To provide arguments to the command, use the --docker-args flag.
Expand Down Expand Up @@ -575,7 +575,7 @@ koyeb deploy <path> <app>/<service> [flags]
--checks-grace-period strings Set healthcheck grace period in seconds.
Use the format <healthcheck>=<seconds>, for example --checks-grace-period 8080=10
--deployment-strategy STRATEGY Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--deployment-strategy string Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--env strings Update service environment variables using the format KEY=VALUE, for example --env FOO=bar
To use the value of a secret as an environment variable, specify the secret name preceded by @, for example --env FOO=@bar
To delete an environment variable, prefix its name with '!', for example --env '!FOO'
Expand Down Expand Up @@ -1375,7 +1375,7 @@ $> koyeb service create myservice --app myapp --docker nginx --port 80:tcp
--checks-grace-period strings Set healthcheck grace period in seconds.
Use the format <healthcheck>=<seconds>, for example --checks-grace-period 8080=10
--deployment-strategy STRATEGY Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--deployment-strategy string Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--docker string Docker image
--docker-args strings Set arguments to the docker command. To provide multiple arguments, use the --docker-args flag multiple times.
--docker-command string Set the docker CMD explicitly. To provide arguments to the command, use the --docker-args flag.
Expand Down Expand Up @@ -1795,7 +1795,7 @@ $> koyeb service update myapp/myservice --port 80:tcp --route '!/'
--checks-grace-period strings Set healthcheck grace period in seconds.
Use the format <healthcheck>=<seconds>, for example --checks-grace-period 8080=10
--deployment-strategy STRATEGY Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--deployment-strategy string Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".
--docker string Docker image
--docker-args strings Set arguments to the docker command. To provide multiple arguments, use the --docker-args flag multiple times.
--docker-command string Set the docker CMD explicitly. To provide arguments to the command, use the --docker-args flag.
Expand Down
36 changes: 21 additions & 15 deletions pkg/koyeb/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (h *ServiceHandler) addServiceDefinitionFlagsForAllSources(flags *pflag.Fla
[]string{},
"Add a region where the service is deployed. You can specify this flag multiple times to deploy the service in multiple regions.\n"+
"To update a service and remove a region, prefix the region name with '!', for example --region '!par'\n"+
"If the region is not specified on service creation, the service is deployed in fra\n",
"If the region is not specified on service creation, the service is deployed in was\n",
)
flags.StringSlice(
"env",
Expand All @@ -320,7 +320,7 @@ func (h *ServiceHandler) addServiceDefinitionFlagsForAllSources(flags *pflag.Fla
flags.String("instance-type", "nano", "Instance type")

var strategy DeploymentStrategy
flags.Var(&strategy, "deployment-strategy", `Deployment strategy, either "rolling" (default), "canary", "blue-green" or "immediate".`)
flags.Var(&strategy, "deployment-strategy", `Deployment strategy, either "rolling" (default), "blue-green" or "immediate".`)

flags.Int64("scale", 1, "Set both min-scale and max-scale")
flags.Int64("min-scale", 1, "Min scale")
Expand Down Expand Up @@ -710,25 +710,33 @@ func (h *ServiceHandler) setDefaultPortsAndRoutes(definition *koyeb.DeploymentDe
definition.SetPorts(h.getDeploymentPort(8000))
definition.SetRoutes(h.getDeploymentRoute(8000))

// When one or more port are set but no route is set:
// - if more than one port is set, we can't determine which one should be used to create the default route, so we return an error
// - if exactly only one port is set, we create the default route with this port
// When one or more ports are set but no route is explicitly configured:
// - if only one HTTP/HTTP2 port is defined, create the default route using that port
// - if more than one HTTP/HTTP2 port is set, we return an error as we can't determine routes configuration
case len(currentPorts) > 0 && len(currentRoutes) == 0:
if len(currentPorts) > 1 {
httpPorts := []koyeb.DeploymentPort{}

for _, port := range currentPorts {
if port.GetProtocol() == "http" || port.GetProtocol() == "http2" {
httpPorts = append(httpPorts, port)
}
}

if len(httpPorts) == 1 {
definition.SetRoutes(h.getDeploymentRoute(httpPorts[0].GetPort()))
}

if len(httpPorts) > 1 {
return &errors.CLIError{
What: "Error while configuring the service",
Why: `your service has two or more ports set but no matching routes`,
Why: `your service has two or more HTTP/HTTP2 ports set but no matching routes`,
Additional: []string{
"For each port, you must specify a matching route with the --routes flag",
"For each HTTP/HTTP2 port, you must specify a matching route with the --routes flag",
},
Orig: nil,
Solution: "Set the routes and try again",
}
}
portNumber := currentPorts[0].GetPort()
if currentPorts[0].GetProtocol() != "tcp" {
definition.SetRoutes(h.getDeploymentRoute(portNumber))
}

// If one or more routes are set but no port is set:
// - if more than one route is set, we can't determine which one should be used to create the default port, so we return an error
Expand Down Expand Up @@ -1736,14 +1744,12 @@ func (s *DeploymentStrategy) Set(value string) error {
switch value {
case "rolling":
*s = DeploymentStrategy(koyeb.DEPLOYMENTSTRATEGYTYPE_ROLLING)
case "canary":
*s = DeploymentStrategy(koyeb.DEPLOYMENTSTRATEGYTYPE_CANARY)
case "blue-green":
*s = DeploymentStrategy(koyeb.DEPLOYMENTSTRATEGYTYPE_BLUE_GREEN)
case "immediate":
*s = DeploymentStrategy(koyeb.DEPLOYMENTSTRATEGYTYPE_IMMEDIATE)
default:
return fmt.Errorf("invalid deployment strategy: %s. Valid values are: rolling, canary, blue-green, immediate.", value)
return fmt.Errorf("invalid deployment strategy: %s. Valid values are: rolling, blue-green, immediate.", value)
}
return nil
}
Expand Down

0 comments on commit 49ecef2

Please sign in to comment.