Provision k8s cluster with Kubespray

This commit is contained in:
Paul-Henri Froidmont 2019-04-04 02:25:38 +02:00
parent 2f9be424d3
commit d1db285cf0
13 changed files with 108 additions and 239 deletions

41
terraform/main.tf Normal file
View file

@ -0,0 +1,41 @@
provider "scaleway" {
region = "${var.region}"
}
data "scaleway_image" "ubuntu" {
architecture = "${var.architecture}"
name = "${var.image}"
}
//resource "scaleway_ip" "public_ip" {
// count = 1
//}
resource "scaleway_server" "node" {
count = "${var.node_instance_count}"
name = "node${count.index+1}"
image = "${data.scaleway_image.ubuntu.id}"
type = "${var.node_instance_type}"
state = "running"
dynamic_ip_required = true,
tags = ["k8s", "kube-node"]
}
resource "scaleway_server" "master" {
count = "${var.master_instance_count}"
name = "master${count.index+1}"
image = "${data.scaleway_image.ubuntu.id}"
type = "${var.master_instance_type}"
state = "running"
dynamic_ip_required = true,
tags = ["k8s", "kube-master","etcd"]
}
output "node_private_ips" {
value = ["${scaleway_server.node.*.private_ip}"]
}
output "master_private_ips" {
value = ["${scaleway_server.master.*.private_ip}"]
}

View file

@ -1,79 +0,0 @@
provider "scaleway" {
region = "${var.region}"
}
data "scaleway_image" "ubuntu" {
architecture = "${var.architecture}"
name = "${var.image}"
}
data "scaleway_image" "ubuntu_mini" {
architecture = "${var.architecture}"
name = "${var.mini_image}"
}
//resource "scaleway_ip" "public_ip" {
// count = 1
//}
resource "scaleway_server" "worker" {
count = "${var.worker_instance_count}"
name = "worker${count.index+1}"
image = "${data.scaleway_image.ubuntu.id}"
type = "${var.worker_instance_type}"
state = "running"
tags = ["k8s","k8s_workers"]
// volume {
// size_in_gb = 50
// type = "l_ssd"
// }
}
resource "scaleway_server" "master" {
count = "${var.master_instance_count}"
name = "master${count.index+1}"
image = "${data.scaleway_image.ubuntu.id}"
type = "${var.master_instance_type}"
state = "running"
tags = ["k8s","k8s_masters"]
}
resource "scaleway_server" "proxy1" {
count = 1
name = "proxy1"
image = "${data.scaleway_image.ubuntu.id}"
type = "${var.proxy_instance_type}"
public_ip = "51.158.77.6"
state = "running"
tags = ["k8s","k8s_proxy","primary"]
}
resource "scaleway_server" "proxy2" {
count = 1
name = "proxy2"
image = "${data.scaleway_image.ubuntu.id}"
type = "${var.proxy_instance_type}"
state = "running"
tags = ["k8s","k8s_proxy","secondary"]
}
output "worker_private_ips" {
value = ["${scaleway_server.worker.*.private_ip}"]
}
output "master_private_ips" {
value = ["${scaleway_server.master.*.private_ip}"]
}
output "proxy0_private_ips" {
value = ["${scaleway_server.proxy1.*.private_ip}"]
}
output "proxy1_private_ips" {
value = ["${scaleway_server.proxy2.*.private_ip}"]
}
output "public_ip" {
value = ["${scaleway_server.proxy1.*.public_ip}"]
}

View file

@ -7,33 +7,21 @@ variable "architecture" {
}
variable "image" {
default = "ubuntu-bionic-k8s"
}
variable "mini_image" {
default = "Ubuntu Mini Xenial 25G"
default = "Ubuntu Bionic"
}
variable "master_instance_type" {
default = "START1-S"
default = "DEV1-S"
}
variable "master_instance_count" {
default = 3
default = 1
}
variable "proxy_instance_type" {
default = "START1-S"
variable "node_instance_type" {
default = "DEV1-S"
}
variable "worker_instance_type" {
default = "START1-S"
}
variable "worker_volume_size" {
default = 100
}
variable "worker_instance_count" {
default = 3
variable "node_instance_count" {
default = 2
}