Skip to content

Commit

Permalink
Add the Terraform workerset integration for Hetzner (#331)
Browse files Browse the repository at this point in the history
* Add the Terraform workerset integration for Hetzner

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Increase the default number of replicas on Hetzner to 3

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
  • Loading branch information
xmudrii authored and kubermatic-bot committed Apr 3, 2019
1 parent 1dc82e6 commit 9479556
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/terraform/hetzner/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ output "kubeone_workers" {
pool1 = {
serverType = "${var.worker_type}"
location = "${var.datacenter}"
replicas = 1
replicas = 3
sshPublicKeys = ["${file("${var.ssh_public_key_file}")}"]
operatingSystem = "${var.image}"
}
Expand Down
27 changes: 25 additions & 2 deletions pkg/terraform/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ type gceWorkerConfig struct {
Zone string `json:"zone"`
}

type hetznerWorkerConfig struct {
ServerType string `json:"serverType"`
Datacenter string `json:"datacenter"`
Location string `json:"location"`
}

// Config represents configuration in the terraform output format
type Config struct {
KubeOneAPI struct {
Expand Down Expand Up @@ -316,8 +322,25 @@ func (c *Config) updateDigitalOceanWorkerset(workerset *config.WorkerConfig, cfg
return nil
}

func (c *Config) updateHetznerWorkerset(_ *config.WorkerConfig, _ json.RawMessage) error {
return errors.New("cloudprovider Hetzner is not implemented yet")
func (c *Config) updateHetznerWorkerset(workerset *config.WorkerConfig, cfg json.RawMessage) error {
var hetznerConfig hetznerWorkerConfig
if err := json.Unmarshal(cfg, &hetznerConfig); err != nil {
return err
}

flags := []cloudProviderFlags{
{key: "serverType", value: hetznerConfig.ServerType},
{key: "datacenter", value: hetznerConfig.Datacenter},
{key: "location", value: hetznerConfig.Location},
}

for _, flag := range flags {
if err := setWorkersetFlag(workerset, flag.key, flag.value); err != nil {
return errors.WithStack(err)
}
}

return nil
}

func (c *Config) updateOpenStackWorkerset(workerset *config.WorkerConfig, cfg json.RawMessage) error {
Expand Down

0 comments on commit 9479556

Please sign in to comment.