diff --git a/README.md b/README.md index 1622c70..d38b9e9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ A [fleeting](https://docs.gitlab.com/runner/fleet_scaling/fleeting/) plugin for ### Caveats -- 🔒 Private networks are not yet supported. - ⬇️ Stopped runner instances are automatically removed and recycled. ## 🏎️ Demo and Ansible Playbook @@ -141,6 +140,7 @@ The following parameters are supported: | `image` | string | Image (slug) of virtual machine, [more information](https://www.cloudscale.ch/en/api/v1#images) | | `volume_size_gb` | number | The size of the root volume in GiB. Must be at least `10`. | | `user_data` | string | Depending on the image choice is either in the format of cloud-init (YAML) or Ignition (JSON). | +| `interfaces` | object | Describes the interfaces to attach to the instances. Check the config template for some examples. | ### Default connector config diff --git a/config/config.toml.template b/config/config.toml.template index 8757339..4c32544 100644 --- a/config/config.toml.template +++ b/config/config.toml.template @@ -96,6 +96,23 @@ concurrent = 40 # The root disk size of each instance. volume_size_gb = 25 + # Networking configuration for the instances + # The Network that is listed first will be used for the communication with the runner controller. + # This direcly mirrors the go sdk types (https://github.com/cloudscale-ch/cloudscale-go-sdk/blob/1baae3ab99a83a25221c77a8c6f4c69838979312/servers.go#L116-L124) + # interfaces = [ + # { network = "UUID3"}, + # { network = "UUID3"}, + # ] + # + # Only one interface in the public network. + # This is also the default if nothing is set + interfaces = [{ network = "public" }] + # Two interfaces, one in a private network + # interfaces = [ + # { network = "public" }, + # { network = "uuid of private net"}, + # ] + # The cloud-config applied to each instance. Note that GitLab expects these # instances to have a running docker daemon. user_data = """#cloud-config diff --git a/provider.go b/provider.go index 2ee76f6..9d104ce 100644 --- a/provider.go +++ b/provider.go @@ -39,6 +39,8 @@ type InstanceGroup struct { Image string `json:"image"` UserData string `json:"user_data"` + Interfaces []cloudscale.InterfaceRequest `json:"interfaces,omitempty"` + VolumeSizeGB int `json:"volume_size_gb,omitempty"` log hclog.Logger @@ -116,6 +118,14 @@ func (g *InstanceGroup) validate() error { err("plugin_config: zone %s should be rma1 or lpg1", g.Zone) } + if g.Interfaces == nil { + g.Interfaces = []cloudscale.InterfaceRequest{ + cloudscale.InterfaceRequest{ + Network: "public", + }, + } + } + if g.VolumeSizeGB < 10 { err("plugin_config: volume_size_gb must be >= 10") } @@ -287,9 +297,6 @@ func (g *InstanceGroup) Increase( ctx context.Context, delta int, ) (succeeded int, err error) { - servers := make([]*cloudscale.Server, 0, delta) - errs := make([]error, 0) - publicKey, err := g.publicKey() if err != nil { return 0, err @@ -309,6 +316,9 @@ func (g *InstanceGroup) Increase( SSHKeys: []string{string(publicKey)}, VolumeSizeGB: g.VolumeSizeGB, UserData: g.UserData, + Interfaces: &[]cloudscale.InterfaceRequest{ + cloudscale.InterfaceRequest{Network: g.Network}, + }, TaggedResourceRequest: cloudscale.TaggedResourceRequest{ Tags: &tagMap, },