run terraform FMT for readability
This commit is contained in:
parent
6eb6e806e7
commit
74fd975b57
10 changed files with 358 additions and 357 deletions
|
@ -1,55 +1,53 @@
|
||||||
|
|
||||||
module "network" {
|
module "network" {
|
||||||
source = "modules/network"
|
source = "modules/network"
|
||||||
|
|
||||||
external_net = "${var.external_net}"
|
external_net = "${var.external_net}"
|
||||||
network_name = "${var.network_name}"
|
network_name = "${var.network_name}"
|
||||||
cluster_name = "${var.cluster_name}"
|
cluster_name = "${var.cluster_name}"
|
||||||
dns_nameservers = "${var.dns_nameservers}"
|
dns_nameservers = "${var.dns_nameservers}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module "ips" {
|
module "ips" {
|
||||||
source = "modules/ips"
|
source = "modules/ips"
|
||||||
|
|
||||||
number_of_k8s_masters = "${var.number_of_k8s_masters}"
|
number_of_k8s_masters = "${var.number_of_k8s_masters}"
|
||||||
number_of_k8s_masters_no_etcd = "${var.number_of_k8s_masters_no_etcd}"
|
number_of_k8s_masters_no_etcd = "${var.number_of_k8s_masters_no_etcd}"
|
||||||
number_of_k8s_nodes = "${var.number_of_k8s_nodes}"
|
number_of_k8s_nodes = "${var.number_of_k8s_nodes}"
|
||||||
floatingip_pool = "${var.floatingip_pool}"
|
floatingip_pool = "${var.floatingip_pool}"
|
||||||
number_of_bastions = "${var.number_of_bastions}"
|
number_of_bastions = "${var.number_of_bastions}"
|
||||||
external_net = "${var.external_net}"
|
external_net = "${var.external_net}"
|
||||||
network_name = "${var.network_name}"
|
network_name = "${var.network_name}"
|
||||||
router_id = "${module.network.router_id}"
|
router_id = "${module.network.router_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
module "compute" {
|
module "compute" {
|
||||||
source = "modules/compute"
|
source = "modules/compute"
|
||||||
|
|
||||||
cluster_name = "${var.cluster_name}"
|
cluster_name = "${var.cluster_name}"
|
||||||
number_of_k8s_masters = "${var.number_of_k8s_masters}"
|
number_of_k8s_masters = "${var.number_of_k8s_masters}"
|
||||||
number_of_k8s_masters_no_etcd = "${var.number_of_k8s_masters_no_etcd}"
|
number_of_k8s_masters_no_etcd = "${var.number_of_k8s_masters_no_etcd}"
|
||||||
number_of_etcd = "${var.number_of_etcd}"
|
number_of_etcd = "${var.number_of_etcd}"
|
||||||
number_of_k8s_masters_no_floating_ip = "${var.number_of_k8s_masters_no_floating_ip}"
|
number_of_k8s_masters_no_floating_ip = "${var.number_of_k8s_masters_no_floating_ip}"
|
||||||
number_of_k8s_masters_no_floating_ip_no_etcd = "${var.number_of_k8s_masters_no_floating_ip_no_etcd}"
|
number_of_k8s_masters_no_floating_ip_no_etcd = "${var.number_of_k8s_masters_no_floating_ip_no_etcd}"
|
||||||
number_of_k8s_nodes = "${var.number_of_k8s_nodes}"
|
number_of_k8s_nodes = "${var.number_of_k8s_nodes}"
|
||||||
number_of_bastions = "${var.number_of_bastions}"
|
number_of_bastions = "${var.number_of_bastions}"
|
||||||
number_of_k8s_nodes_no_floating_ip = "${var.number_of_k8s_nodes_no_floating_ip}"
|
number_of_k8s_nodes_no_floating_ip = "${var.number_of_k8s_nodes_no_floating_ip}"
|
||||||
number_of_gfs_nodes_no_floating_ip = "${var.number_of_gfs_nodes_no_floating_ip}"
|
number_of_gfs_nodes_no_floating_ip = "${var.number_of_gfs_nodes_no_floating_ip}"
|
||||||
gfs_volume_size_in_gb = "${var.gfs_volume_size_in_gb}"
|
gfs_volume_size_in_gb = "${var.gfs_volume_size_in_gb}"
|
||||||
public_key_path = "${var.public_key_path}"
|
public_key_path = "${var.public_key_path}"
|
||||||
image = "${var.image}"
|
image = "${var.image}"
|
||||||
image_gfs = "${var.image_gfs}"
|
image_gfs = "${var.image_gfs}"
|
||||||
ssh_user = "${var.ssh_user}"
|
ssh_user = "${var.ssh_user}"
|
||||||
ssh_user_gfs = "${var.ssh_user_gfs}"
|
ssh_user_gfs = "${var.ssh_user_gfs}"
|
||||||
flavor_k8s_master = "${var.flavor_k8s_master}"
|
flavor_k8s_master = "${var.flavor_k8s_master}"
|
||||||
flavor_k8s_node = "${var.flavor_k8s_node}"
|
flavor_k8s_node = "${var.flavor_k8s_node}"
|
||||||
flavor_etcd = "${var.flavor_etcd}"
|
flavor_etcd = "${var.flavor_etcd}"
|
||||||
flavor_gfs_node = "${var.flavor_gfs_node}"
|
flavor_gfs_node = "${var.flavor_gfs_node}"
|
||||||
network_name = "${var.network_name}"
|
network_name = "${var.network_name}"
|
||||||
flavor_bastion = "${var.flavor_bastion}"
|
flavor_bastion = "${var.flavor_bastion}"
|
||||||
k8s_master_fips = "${module.ips.k8s_master_fips}"
|
k8s_master_fips = "${module.ips.k8s_master_fips}"
|
||||||
k8s_node_fips = "${module.ips.k8s_node_fips}"
|
k8s_node_fips = "${module.ips.k8s_node_fips}"
|
||||||
bastion_fips = "${module.ips.bastion_fips}"
|
bastion_fips = "${module.ips.bastion_fips}"
|
||||||
|
|
||||||
network_id = "${module.network.router_id}"
|
network_id = "${module.network.router_id}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
variable user_data {
|
||||||
|
type = "string"
|
||||||
|
|
||||||
|
|
||||||
variable user_data {
|
|
||||||
type = "string"
|
|
||||||
default = <<EOF
|
default = <<EOF
|
||||||
#cloud-config
|
#cloud-config
|
||||||
manage_etc_hosts: localhost
|
manage_etc_hosts: localhost
|
||||||
|
@ -9,272 +8,319 @@ package_update: true
|
||||||
package_upgrade: true
|
package_upgrade: true
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_keypair_v2" "k8s" {
|
resource "openstack_compute_keypair_v2" "k8s" {
|
||||||
name = "kubernetes-${var.cluster_name}"
|
name = "kubernetes-${var.cluster_name}"
|
||||||
public_key = "${chomp(file(var.public_key_path))}"
|
public_key = "${chomp(file(var.public_key_path))}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_secgroup_v2" "k8s_master" {
|
resource "openstack_compute_secgroup_v2" "k8s_master" {
|
||||||
name = "${var.cluster_name}-k8s-master"
|
name = "${var.cluster_name}-k8s-master"
|
||||||
description = "${var.cluster_name} - Kubernetes Master"
|
description = "${var.cluster_name} - Kubernetes Master"
|
||||||
rule {
|
|
||||||
ip_protocol = "tcp"
|
rule {
|
||||||
from_port = "6443"
|
ip_protocol = "tcp"
|
||||||
to_port = "6443"
|
from_port = "6443"
|
||||||
cidr = "0.0.0.0/0"
|
to_port = "6443"
|
||||||
}
|
cidr = "0.0.0.0/0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_secgroup_v2" "bastion" {
|
resource "openstack_compute_secgroup_v2" "bastion" {
|
||||||
name = "${var.cluster_name}-bastion"
|
name = "${var.cluster_name}-bastion"
|
||||||
description = "${var.cluster_name} - Bastion Server"
|
description = "${var.cluster_name} - Bastion Server"
|
||||||
rule {
|
|
||||||
ip_protocol = "tcp"
|
rule {
|
||||||
from_port = "22"
|
ip_protocol = "tcp"
|
||||||
to_port = "22"
|
from_port = "22"
|
||||||
cidr = "0.0.0.0/0"
|
to_port = "22"
|
||||||
}
|
cidr = "0.0.0.0/0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_secgroup_v2" "k8s" {
|
resource "openstack_compute_secgroup_v2" "k8s" {
|
||||||
name = "${var.cluster_name}-k8s"
|
name = "${var.cluster_name}-k8s"
|
||||||
description = "${var.cluster_name} - Kubernetes"
|
description = "${var.cluster_name} - Kubernetes"
|
||||||
rule {
|
|
||||||
ip_protocol = "icmp"
|
rule {
|
||||||
from_port = "-1"
|
ip_protocol = "icmp"
|
||||||
to_port = "-1"
|
from_port = "-1"
|
||||||
cidr = "0.0.0.0/0"
|
to_port = "-1"
|
||||||
}
|
cidr = "0.0.0.0/0"
|
||||||
rule {
|
}
|
||||||
ip_protocol = "tcp"
|
|
||||||
from_port = "1"
|
rule {
|
||||||
to_port = "65535"
|
ip_protocol = "tcp"
|
||||||
self = true
|
from_port = "1"
|
||||||
}
|
to_port = "65535"
|
||||||
rule {
|
self = true
|
||||||
ip_protocol = "udp"
|
}
|
||||||
from_port = "1"
|
|
||||||
to_port = "65535"
|
rule {
|
||||||
self = true
|
ip_protocol = "udp"
|
||||||
}
|
from_port = "1"
|
||||||
rule {
|
to_port = "65535"
|
||||||
ip_protocol = "icmp"
|
self = true
|
||||||
from_port = "-1"
|
}
|
||||||
to_port = "-1"
|
|
||||||
self = true
|
rule {
|
||||||
}
|
ip_protocol = "icmp"
|
||||||
|
from_port = "-1"
|
||||||
|
to_port = "-1"
|
||||||
|
self = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "bastion" {
|
resource "openstack_compute_instance_v2" "bastion" {
|
||||||
name = "${var.cluster_name}-bastion-${count.index+1}"
|
name = "${var.cluster_name}-bastion-${count.index+1}"
|
||||||
count = "${var.number_of_bastions}"
|
count = "${var.number_of_bastions}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_bastion}"
|
flavor_id = "${var.flavor_bastion}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
|
||||||
}
|
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s.name}",
|
|
||||||
"${openstack_compute_secgroup_v2.bastion.name}",
|
|
||||||
"default" ]
|
|
||||||
metadata = {
|
|
||||||
ssh_user = "${var.ssh_user}"
|
|
||||||
kubespray_groups = "bastion"
|
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
provisioner "local-exec" {
|
network {
|
||||||
command = "sed s/USER/${var.ssh_user}/ contrib/terraform/openstack/ansible_bastion_template.txt | sed s/BASTION_ADDRESS/${var.bastion_fips[0]}/ > contrib/terraform/openstack/group_vars/no-floating.yml"
|
name = "${var.network_name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
user_data = "${var.user_data}"
|
security_groups = ["${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
|
"${openstack_compute_secgroup_v2.bastion.name}",
|
||||||
|
"default",
|
||||||
|
]
|
||||||
|
|
||||||
|
metadata = {
|
||||||
|
ssh_user = "${var.ssh_user}"
|
||||||
|
kubespray_groups = "bastion"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "local-exec" {
|
||||||
|
command = "sed s/USER/${var.ssh_user}/ contrib/terraform/openstack/ansible_bastion_template.txt | sed s/BASTION_ADDRESS/${var.bastion_fips[0]}/ > contrib/terraform/openstack/group_vars/no-floating.yml"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "k8s_master" {
|
resource "openstack_compute_instance_v2" "k8s_master" {
|
||||||
name = "${var.cluster_name}-k8s-master-${count.index+1}"
|
name = "${var.cluster_name}-k8s-master-${count.index+1}"
|
||||||
count = "${var.number_of_k8s_masters}"
|
count = "${var.number_of_k8s_masters}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_k8s_master}"
|
flavor_id = "${var.flavor_k8s_master}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s_master.name}",
|
}
|
||||||
"${openstack_compute_secgroup_v2.bastion.name}",
|
|
||||||
"${openstack_compute_secgroup_v2.k8s.name}",
|
security_groups = ["${openstack_compute_secgroup_v2.k8s_master.name}",
|
||||||
"default" ]
|
"${openstack_compute_secgroup_v2.bastion.name}",
|
||||||
metadata = {
|
"${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
ssh_user = "${var.ssh_user}"
|
"default",
|
||||||
kubespray_groups = "etcd,kube-master,kube-node,k8s-cluster,vault"
|
]
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
metadata = {
|
||||||
user_data = "${var.user_data}"
|
ssh_user = "${var.ssh_user}"
|
||||||
|
kubespray_groups = "etcd,kube-master,kube-node,k8s-cluster,vault"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "k8s_master_no_etcd" {
|
resource "openstack_compute_instance_v2" "k8s_master_no_etcd" {
|
||||||
name = "${var.cluster_name}-k8s-master-ne-${count.index+1}"
|
name = "${var.cluster_name}-k8s-master-ne-${count.index+1}"
|
||||||
count = "${var.number_of_k8s_masters_no_etcd}"
|
count = "${var.number_of_k8s_masters_no_etcd}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_k8s_master}"
|
flavor_id = "${var.flavor_k8s_master}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s_master.name}",
|
}
|
||||||
"${openstack_compute_secgroup_v2.k8s.name}" ]
|
|
||||||
metadata = {
|
security_groups = ["${openstack_compute_secgroup_v2.k8s_master.name}",
|
||||||
ssh_user = "${var.ssh_user}"
|
"${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
kubespray_groups = "kube-master,kube-node,k8s-cluster,vault"
|
]
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
metadata = {
|
||||||
user_data = "${var.user_data}"
|
ssh_user = "${var.ssh_user}"
|
||||||
|
kubespray_groups = "kube-master,kube-node,k8s-cluster,vault"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "etcd" {
|
resource "openstack_compute_instance_v2" "etcd" {
|
||||||
name = "${var.cluster_name}-etcd-${count.index+1}"
|
name = "${var.cluster_name}-etcd-${count.index+1}"
|
||||||
count = "${var.number_of_etcd}"
|
count = "${var.number_of_etcd}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_etcd}"
|
flavor_id = "${var.flavor_etcd}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s.name}" ]
|
}
|
||||||
metadata = {
|
|
||||||
ssh_user = "${var.ssh_user}"
|
security_groups = ["${openstack_compute_secgroup_v2.k8s.name}"]
|
||||||
kubespray_groups = "etcd,vault,no-floating"
|
|
||||||
depends_on = "${var.network_id}"
|
metadata = {
|
||||||
}
|
ssh_user = "${var.ssh_user}"
|
||||||
user_data = "${var.user_data}"
|
kubespray_groups = "etcd,vault,no-floating"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "k8s_master_no_floating_ip" {
|
resource "openstack_compute_instance_v2" "k8s_master_no_floating_ip" {
|
||||||
name = "${var.cluster_name}-k8s-master-nf-${count.index+1}"
|
name = "${var.cluster_name}-k8s-master-nf-${count.index+1}"
|
||||||
count = "${var.number_of_k8s_masters_no_floating_ip}"
|
count = "${var.number_of_k8s_masters_no_floating_ip}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_k8s_master}"
|
flavor_id = "${var.flavor_k8s_master}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s_master.name}",
|
}
|
||||||
"${openstack_compute_secgroup_v2.k8s.name}",
|
|
||||||
"default" ]
|
security_groups = ["${openstack_compute_secgroup_v2.k8s_master.name}",
|
||||||
metadata = {
|
"${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
ssh_user = "${var.ssh_user}"
|
"default",
|
||||||
kubespray_groups = "etcd,kube-master,kube-node,k8s-cluster,vault,no-floating"
|
]
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
metadata = {
|
||||||
user_data = "${var.user_data}"
|
ssh_user = "${var.ssh_user}"
|
||||||
|
kubespray_groups = "etcd,kube-master,kube-node,k8s-cluster,vault,no-floating"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "k8s_master_no_floating_ip_no_etcd" {
|
resource "openstack_compute_instance_v2" "k8s_master_no_floating_ip_no_etcd" {
|
||||||
name = "${var.cluster_name}-k8s-master-ne-nf-${count.index+1}"
|
name = "${var.cluster_name}-k8s-master-ne-nf-${count.index+1}"
|
||||||
count = "${var.number_of_k8s_masters_no_floating_ip_no_etcd}"
|
count = "${var.number_of_k8s_masters_no_floating_ip_no_etcd}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_k8s_master}"
|
flavor_id = "${var.flavor_k8s_master}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s_master.name}",
|
}
|
||||||
"${openstack_compute_secgroup_v2.k8s.name}" ]
|
|
||||||
metadata = {
|
security_groups = ["${openstack_compute_secgroup_v2.k8s_master.name}",
|
||||||
ssh_user = "${var.ssh_user}"
|
"${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
kubespray_groups = "kube-master,kube-node,k8s-cluster,vault,no-floating"
|
]
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
metadata = {
|
||||||
user_data = "${var.user_data}"
|
ssh_user = "${var.ssh_user}"
|
||||||
|
kubespray_groups = "kube-master,kube-node,k8s-cluster,vault,no-floating"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "k8s_node" {
|
resource "openstack_compute_instance_v2" "k8s_node" {
|
||||||
name = "${var.cluster_name}-k8s-node-${count.index+1}"
|
name = "${var.cluster_name}-k8s-node-${count.index+1}"
|
||||||
count = "${var.number_of_k8s_nodes}"
|
count = "${var.number_of_k8s_nodes}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_k8s_node}"
|
flavor_id = "${var.flavor_k8s_node}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s.name}",
|
}
|
||||||
"${openstack_compute_secgroup_v2.bastion.name}",
|
|
||||||
"default" ]
|
security_groups = ["${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
metadata = {
|
"${openstack_compute_secgroup_v2.bastion.name}",
|
||||||
ssh_user = "${var.ssh_user}"
|
"default",
|
||||||
kubespray_groups = "kube-node,k8s-cluster"
|
]
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
metadata = {
|
||||||
user_data = "${var.user_data}"
|
ssh_user = "${var.ssh_user}"
|
||||||
|
kubespray_groups = "kube-node,k8s-cluster"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "k8s_node_no_floating_ip" {
|
resource "openstack_compute_instance_v2" "k8s_node_no_floating_ip" {
|
||||||
name = "${var.cluster_name}-k8s-node-nf-${count.index+1}"
|
name = "${var.cluster_name}-k8s-node-nf-${count.index+1}"
|
||||||
count = "${var.number_of_k8s_nodes_no_floating_ip}"
|
count = "${var.number_of_k8s_nodes_no_floating_ip}"
|
||||||
image_name = "${var.image}"
|
image_name = "${var.image}"
|
||||||
flavor_id = "${var.flavor_k8s_node}"
|
flavor_id = "${var.flavor_k8s_node}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = [ "${openstack_compute_secgroup_v2.k8s.name}",
|
}
|
||||||
"default" ]
|
|
||||||
metadata = {
|
security_groups = ["${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
ssh_user = "${var.ssh_user}"
|
"default",
|
||||||
kubespray_groups = "kube-node,k8s-cluster,no-floating"
|
]
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
metadata = {
|
||||||
user_data = "${var.user_data}"
|
ssh_user = "${var.ssh_user}"
|
||||||
|
kubespray_groups = "kube-node,k8s-cluster,no-floating"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "${var.user_data}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_floatingip_associate_v2" "bastion" {
|
resource "openstack_compute_floatingip_associate_v2" "bastion" {
|
||||||
count = "${var.number_of_bastions}"
|
count = "${var.number_of_bastions}"
|
||||||
floating_ip = "${var.bastion_fips[count.index]}"
|
floating_ip = "${var.bastion_fips[count.index]}"
|
||||||
instance_id = "${element(openstack_compute_instance_v2.bastion.*.id, count.index)}"
|
instance_id = "${element(openstack_compute_instance_v2.bastion.*.id, count.index)}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_floatingip_associate_v2" "k8s_master" {
|
resource "openstack_compute_floatingip_associate_v2" "k8s_master" {
|
||||||
count = "${var.number_of_k8s_masters}"
|
count = "${var.number_of_k8s_masters}"
|
||||||
instance_id = "${element(openstack_compute_instance_v2.k8s_master.*.id, count.index)}"
|
instance_id = "${element(openstack_compute_instance_v2.k8s_master.*.id, count.index)}"
|
||||||
floating_ip = "${var.k8s_master_fips[count.index]}"
|
floating_ip = "${var.k8s_master_fips[count.index]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_floatingip_associate_v2" "k8s_node" {
|
resource "openstack_compute_floatingip_associate_v2" "k8s_node" {
|
||||||
count = "${var.number_of_k8s_nodes}"
|
count = "${var.number_of_k8s_nodes}"
|
||||||
floating_ip = "${var.k8s_node_fips[count.index]}"
|
floating_ip = "${var.k8s_node_fips[count.index]}"
|
||||||
instance_id = "${element(openstack_compute_instance_v2.k8s_node.*.id, count.index)}"
|
instance_id = "${element(openstack_compute_instance_v2.k8s_node.*.id, count.index)}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "openstack_blockstorage_volume_v2" "glusterfs_volume" {
|
resource "openstack_blockstorage_volume_v2" "glusterfs_volume" {
|
||||||
name = "${var.cluster_name}-glusterfs_volume-${count.index+1}"
|
name = "${var.cluster_name}-glusterfs_volume-${count.index+1}"
|
||||||
count = "${var.number_of_gfs_nodes_no_floating_ip}"
|
count = "${var.number_of_gfs_nodes_no_floating_ip}"
|
||||||
description = "Non-ephemeral volume for GlusterFS"
|
description = "Non-ephemeral volume for GlusterFS"
|
||||||
size = "${var.gfs_volume_size_in_gb}"
|
size = "${var.gfs_volume_size_in_gb}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "glusterfs_node_no_floating_ip" {
|
resource "openstack_compute_instance_v2" "glusterfs_node_no_floating_ip" {
|
||||||
name = "${var.cluster_name}-gfs-node-nf-${count.index+1}"
|
name = "${var.cluster_name}-gfs-node-nf-${count.index+1}"
|
||||||
count = "${var.number_of_gfs_nodes_no_floating_ip}"
|
count = "${var.number_of_gfs_nodes_no_floating_ip}"
|
||||||
image_name = "${var.image_gfs}"
|
image_name = "${var.image_gfs}"
|
||||||
flavor_id = "${var.flavor_gfs_node}"
|
flavor_id = "${var.flavor_gfs_node}"
|
||||||
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
key_pair = "${openstack_compute_keypair_v2.k8s.name}"
|
||||||
network {
|
|
||||||
name = "${var.network_name}"
|
network {
|
||||||
}
|
name = "${var.network_name}"
|
||||||
security_groups = ["${openstack_compute_secgroup_v2.k8s.name}",
|
}
|
||||||
"default" ]
|
|
||||||
metadata = {
|
security_groups = ["${openstack_compute_secgroup_v2.k8s.name}",
|
||||||
ssh_user = "${var.ssh_user_gfs}"
|
"default",
|
||||||
kubespray_groups = "gfs-cluster,network-storage,no-floating"
|
]
|
||||||
depends_on = "${var.network_id}"
|
|
||||||
}
|
metadata = {
|
||||||
user_data = "#cloud-config\nmanage_etc_hosts: localhost\npackage_update: true\npackage_upgrade: true"
|
ssh_user = "${var.ssh_user_gfs}"
|
||||||
|
kubespray_groups = "gfs-cluster,network-storage,no-floating"
|
||||||
|
depends_on = "${var.network_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
user_data = "#cloud-config\nmanage_etc_hosts: localhost\npackage_update: true\npackage_upgrade: true"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_compute_volume_attach_v2" "glusterfs_volume" {
|
resource "openstack_compute_volume_attach_v2" "glusterfs_volume" {
|
||||||
count = "${var.number_of_gfs_nodes_no_floating_ip}"
|
count = "${var.number_of_gfs_nodes_no_floating_ip}"
|
||||||
instance_id = "${element(openstack_compute_instance_v2.glusterfs_node_no_floating_ip.*.id, count.index)}"
|
instance_id = "${element(openstack_compute_instance_v2.glusterfs_node_no_floating_ip.*.id, count.index)}"
|
||||||
volume_id = "${element(openstack_blockstorage_volume_v2.glusterfs_volume.*.id, count.index)}"
|
volume_id = "${element(openstack_blockstorage_volume_v2.glusterfs_volume.*.id, count.index)}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,74 +1,48 @@
|
||||||
variable "cluster_name" {
|
variable "cluster_name" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_masters" {
|
variable "number_of_k8s_masters" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_masters_no_etcd" {
|
variable "number_of_k8s_masters_no_etcd" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_etcd" {
|
variable "number_of_etcd" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_masters_no_floating_ip" {
|
variable "number_of_k8s_masters_no_floating_ip" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_masters_no_floating_ip_no_etcd" {
|
variable "number_of_k8s_masters_no_floating_ip_no_etcd" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_nodes" {
|
variable "number_of_k8s_nodes" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_nodes_no_floating_ip" {
|
variable "number_of_k8s_nodes_no_floating_ip" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_bastions" {
|
variable "number_of_bastions" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_gfs_nodes_no_floating_ip" {
|
variable "number_of_gfs_nodes_no_floating_ip" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "gfs_volume_size_in_gb" {
|
variable "gfs_volume_size_in_gb" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "public_key_path" {
|
variable "public_key_path" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "image" {
|
variable "image" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "image_gfs" {
|
variable "image_gfs" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "ssh_user" {
|
variable "ssh_user" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "ssh_user_gfs" {
|
variable "ssh_user_gfs" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "flavor_k8s_master" {
|
variable "flavor_k8s_master" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "flavor_k8s_node" {
|
variable "flavor_k8s_node" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "flavor_etcd" {
|
variable "flavor_etcd" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "flavor_gfs_node" {
|
variable "flavor_gfs_node" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "network_name" {
|
variable "network_name" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "flavor_bastion" {
|
variable "flavor_bastion" {}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
variable "network_id"{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
variable "network_id" {}
|
||||||
|
|
||||||
variable "k8s_master_fips" {
|
variable "k8s_master_fips" {
|
||||||
type = "list"
|
type = "list"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
resource "null_resource" "dummy_dependency" {
|
resource "null_resource" "dummy_dependency" {
|
||||||
triggers {
|
triggers {
|
||||||
dependency_id = "${var.router_id}"
|
dependency_id = "${var.router_id}"
|
||||||
|
@ -6,19 +5,19 @@ resource "null_resource" "dummy_dependency" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_floatingip_v2" "k8s_master" {
|
resource "openstack_networking_floatingip_v2" "k8s_master" {
|
||||||
count = "${var.number_of_k8s_masters}"
|
count = "${var.number_of_k8s_masters}"
|
||||||
pool = "${var.floatingip_pool}"
|
pool = "${var.floatingip_pool}"
|
||||||
depends_on = ["null_resource.dummy_dependency"]
|
depends_on = ["null_resource.dummy_dependency"]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_floatingip_v2" "k8s_node" {
|
resource "openstack_networking_floatingip_v2" "k8s_node" {
|
||||||
count = "${var.number_of_k8s_nodes}"
|
count = "${var.number_of_k8s_nodes}"
|
||||||
pool = "${var.floatingip_pool}"
|
pool = "${var.floatingip_pool}"
|
||||||
depends_on = ["null_resource.dummy_dependency"]
|
depends_on = ["null_resource.dummy_dependency"]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_floatingip_v2" "bastion" {
|
resource "openstack_networking_floatingip_v2" "bastion" {
|
||||||
count = "${var.number_of_bastions}"
|
count = "${var.number_of_bastions}"
|
||||||
pool = "${var.floatingip_pool}"
|
pool = "${var.floatingip_pool}"
|
||||||
depends_on = ["null_resource.dummy_dependency"]
|
depends_on = ["null_resource.dummy_dependency"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
output "k8s_master_fips" {
|
output "k8s_master_fips" {
|
||||||
value = ["${openstack_networking_floatingip_v2.k8s_master.*.address}"]
|
value = ["${openstack_networking_floatingip_v2.k8s_master.*.address}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
output "k8s_node_fips" {
|
output "k8s_node_fips" {
|
||||||
value = ["${openstack_networking_floatingip_v2.k8s_node.*.address}"]
|
value = ["${openstack_networking_floatingip_v2.k8s_node.*.address}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
output "bastion_fips" {
|
output "bastion_fips" {
|
||||||
value = ["${openstack_networking_floatingip_v2.bastion.*.address}"]
|
value = ["${openstack_networking_floatingip_v2.bastion.*.address}"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,15 @@
|
||||||
variable "number_of_k8s_masters" {
|
variable "number_of_k8s_masters" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_masters_no_etcd" {
|
variable "number_of_k8s_masters_no_etcd" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_k8s_nodes" {
|
variable "number_of_k8s_nodes" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "floatingip_pool" {
|
variable "floatingip_pool" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "number_of_bastions" {
|
variable "number_of_bastions" {}
|
||||||
|
|
||||||
}
|
variable "external_net" {}
|
||||||
|
|
||||||
variable "external_net" {
|
variable "network_name" {}
|
||||||
|
|
||||||
}
|
variable "router_id" {}
|
||||||
|
|
||||||
variable "network_name" {
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "router_id"{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
resource "openstack_networking_router_v2" "k8s" {
|
resource "openstack_networking_router_v2" "k8s" {
|
||||||
name = "${var.cluster_name}-router"
|
name = "${var.cluster_name}-router"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
output "router_id" {
|
output "router_id" {
|
||||||
value = "${openstack_networking_router_interface_v2.k8s.id}"
|
value = "${openstack_networking_router_interface_v2.k8s.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "network_id" {
|
output "network_id" {
|
||||||
value = "${openstack_networking_subnet_v2.k8s.id}"
|
value = "${openstack_networking_subnet_v2.k8s.id}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
variable "external_net" {
|
variable "external_net" {}
|
||||||
|
|
||||||
}
|
variable "network_name" {}
|
||||||
|
|
||||||
variable "network_name" {
|
variable "cluster_name" {}
|
||||||
}
|
|
||||||
|
|
||||||
variable "cluster_name" {
|
variable "dns_nameservers" {
|
||||||
}
|
|
||||||
|
|
||||||
variable "dns_nameservers"{
|
|
||||||
type = "list"
|
type = "list"
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,68 +44,68 @@ variable "gfs_volume_size_in_gb" {
|
||||||
|
|
||||||
variable "public_key_path" {
|
variable "public_key_path" {
|
||||||
description = "The path of the ssh pub key"
|
description = "The path of the ssh pub key"
|
||||||
default = "~/.ssh/id_rsa.pub"
|
default = "~/.ssh/id_rsa.pub"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "image" {
|
variable "image" {
|
||||||
description = "the image to use"
|
description = "the image to use"
|
||||||
default = "ubuntu-14.04"
|
default = "ubuntu-14.04"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "image_gfs" {
|
variable "image_gfs" {
|
||||||
description = "Glance image to use for GlusterFS"
|
description = "Glance image to use for GlusterFS"
|
||||||
default = "ubuntu-16.04"
|
default = "ubuntu-16.04"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_user" {
|
variable "ssh_user" {
|
||||||
description = "used to fill out tags for ansible inventory"
|
description = "used to fill out tags for ansible inventory"
|
||||||
default = "ubuntu"
|
default = "ubuntu"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_user_gfs" {
|
variable "ssh_user_gfs" {
|
||||||
description = "used to fill out tags for ansible inventory"
|
description = "used to fill out tags for ansible inventory"
|
||||||
default = "ubuntu"
|
default = "ubuntu"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "flavor_bastion" {
|
variable "flavor_bastion" {
|
||||||
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
||||||
default = 3
|
default = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "flavor_k8s_master" {
|
variable "flavor_k8s_master" {
|
||||||
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
||||||
default = 3
|
default = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "flavor_k8s_node" {
|
variable "flavor_k8s_node" {
|
||||||
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
||||||
default = 3
|
default = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "flavor_etcd" {
|
variable "flavor_etcd" {
|
||||||
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
||||||
default = 3
|
default = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "flavor_gfs_node" {
|
variable "flavor_gfs_node" {
|
||||||
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
description = "Use 'nova flavor-list' command to see what your OpenStack instance uses for IDs"
|
||||||
default = 3
|
default = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "network_name" {
|
variable "network_name" {
|
||||||
description = "name of the internal network to use"
|
description = "name of the internal network to use"
|
||||||
default = "internal"
|
default = "internal"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "dns_nameservers"{
|
variable "dns_nameservers" {
|
||||||
description = "An array of DNS name server names used by hosts in this subnet."
|
description = "An array of DNS name server names used by hosts in this subnet."
|
||||||
type = "list"
|
type = "list"
|
||||||
default = []
|
default = []
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "floatingip_pool" {
|
variable "floatingip_pool" {
|
||||||
description = "name of the floating ip pool to use"
|
description = "name of the floating ip pool to use"
|
||||||
default = "external"
|
default = "external"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "external_net" {
|
variable "external_net" {
|
||||||
|
|
Loading…
Reference in a new issue