Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add openstack worker support #209

Merged
merged 2 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/config/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (p ProviderName) ProviderCredentials() (map[string]string, error) {

return nil, errors.New("error parsing aws credentials")
case ProviderNameOpenStack:
return parseCredentialVariables([]string{"OS_AUTH_URL", "OS_USER_NAME", "OS_PASSWORD", "OS_DOMAIN_NAME", "OS_TENANT_NAME"})
return parseCredentialVariables([]string{"OS_AUTH_URL", "OS_USER_NAME", "OS_PASSWORD", "OS_DOMAIN_NAME", "OS_TENANT_NAME", "OS_REGION_NAME"})
case ProviderNameHetzner:
return parseCredentialVariables([]string{"HZ_TOKEN"})
case ProviderNameDigitalOcean:
Expand Down
41 changes: 39 additions & 2 deletions pkg/terraform/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ type doWorkerConfig struct {
Region string `json:"region"`
}

type openStackWorkerConfig struct {
Image string `json:"image"`
Flavor string `json:"flavor"`
SecurityGroups []string `json:"securityGroups"`
FloatingIPPool string `json:"floatingIPPool"`
AvailabilityZone string `json:"availabilityZone"`
Network string `json:"network"`
Subnet string `json:"subnet"`
}

// Config represents configuration in the terraform output format
type Config struct {
KubeOneAPI struct {
Expand Down Expand Up @@ -264,8 +274,35 @@ func (c *Config) updateHetznerWorkerset(_ *config.WorkerConfig, _ json.RawMessag
return errors.New("cloudprovider Hetzner is not implemented yet")
}

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

if err := setWorkersetFlag(workerset, "floatingIPPool", openstackConfig.FloatingIPPool); err != nil {
return err
}
if err := setWorkersetFlag(workerset, "image", openstackConfig.Image); err != nil {
return err
}
if err := setWorkersetFlag(workerset, "flavor", openstackConfig.Flavor); err != nil {
return err
}
if err := setWorkersetFlag(workerset, "securityGroups", openstackConfig.SecurityGroups); err != nil {
return err
}
if err := setWorkersetFlag(workerset, "availabilityZone", openstackConfig.AvailabilityZone); err != nil {
return err
}
if err := setWorkersetFlag(workerset, "network", openstackConfig.Network); err != nil {
return err
}
if err := setWorkersetFlag(workerset, "subnet", openstackConfig.Subnet); err != nil {
return err
}

return nil
}

func (c *Config) updateVSphereWorkerset(_ *config.WorkerConfig, _ json.RawMessage) error {
Expand Down
2 changes: 1 addition & 1 deletion terraform/openstack/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ resource "openstack_compute_instance_v2" "control_plane" {
count = "${var.control_plane_count}"

name = "${var.cluster_name}-cluster-${count.index}"
image_name = "${var.control_plane_image}"
image_name = "${var.image}"
flavor_name = "${var.control_plane_flavor}"
key_pair = "${openstack_compute_keypair_v2.deployer.name}"
security_groups = ["${openstack_networking_secgroup_v2.securitygroup.name}"]
Expand Down
16 changes: 16 additions & 0 deletions terraform/openstack/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,19 @@ output "kubeone_hosts" {
}
}
}

output "kubeone_workers" {
value = {
nodes1 = {
image = "${var.image}"
instanceProfile = "${var.worker_flavor}"
securityGroupIDs = ["${openstack_networking_secgroup_v2.securitygroup.id}"]
floatingIPPool = "${var.external_network_name}"
network = "${openstack_networking_network_v2.network.name}"
subnet = "${openstack_networking_subnet_v2.subnet.name}"

operatingSystem = "ubuntu"
replicas = 1
}
}
}
9 changes: 7 additions & 2 deletions terraform/openstack/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ variable "control_plane_count" {

variable "control_plane_flavor" {
default = "m1.small"
description = "OpenStack instance flavor"
description = "OpenStack instance flavor for the control plane nodes"
}

variable "control_plane_image" {
variable "image" {
default = "Ubuntu 18.04 LTS"
description = "OpenStack image for the control plane nodes"
}

variable "worker_flavor" {
default = "m1.small"
description = "OpenStack instance flavor for the worker nodes"
}

variable "subnet_cidr" {
default = "192.168.1.0/24"
description = "OpenStack subnet cidr"
Expand Down