Skip to content
This repository was archived by the owner on Oct 31, 2019. It is now read-only.

Commit 920a87d

Browse files
xinnong-wangjlamillan
authored andcommitted
Make Load Balancer for Kubernetes Master(s) an optional parameter. Resolves #125. Resolves #137.
1 parent 7ae71db commit 920a87d

File tree

25 files changed

+574
-485
lines changed

25 files changed

+574
-485
lines changed

docs/input-variables.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ name | default | description
2121
etcdShape | VM.Standard1.1 | OCI shape for etcd nodes
2222
k8sMasterShape | VM.Standard1.1 | OCI shape for k8s master(s)
2323
k8sWorkerShape | VM.Standard1.2 | OCI shape for k8s worker(s)
24+
master_oci_lb_enabled | "true" | enable/disable the k8s master oci load balancer. "true": use oci load balancer for k8s master . "false": use a reverse proxy as a software load balancer for k8s masters.
25+
etcdLBShape | 100Mbps | etcd cluster OCI Load Balancer shape / bandwidth
26+
etcd_lb_enabled | "true" | enable/disable the etcd load balancer. "true" use the etcd load balancer ip, "false" use a list of etcd instance ips
27+
k8sMasterLBShape | 100Mbps | Kubernetes Master OCI Load Balancer shape / bandwidth
2428
k8sMasterAd1Count | 1 | number of k8s masters to create in Availability Domain 1
2529
k8sMasterAd2Count | 0 | number of k8s masters to create in Availability Domain 2
2630
k8sMasterAd3Count | 0 | number of k8s masters to create in Availability Domain 3
@@ -33,11 +37,8 @@ etcdAd3Count | 0 | number of etcd n
3337
worker_iscsi_volume_create | "false" | boolean flag indicating whether or not to attach an iSCSI volume to attach to each worker node
3438
worker_iscsi_volume_size | unset | optional size of an iSCSI volume to attach to each worker
3539
worker_iscsi_volume_mount | /var/lib/docker | optional mount path of iSCSI volume when worker_iscsi_volume_size is set
36-
etcd_iscsi_volume_create | "false" | boolean flag indicating whether or not to attach an iSCSI volume to attach to each etcd node
40+
etcd_iscsi_volume_create | false | boolean flag indicating whether or not to attach an iSCSI volume to attach to each etcd node
3741
etcd_iscsi_volume_size | 50 | size in GBs of volume when etcd_iscsi_volume_create is set
38-
etcd_lb_enabled | "true" | enable/disable the etcd load balancer. "true" use the etcd load balancer ip, "false" use a list of etcd instance ips
39-
etcdLBShape | 100Mbps | etcd cluster OCI Load Balancer shape / bandwidth
40-
k8sMasterLBShape | 100Mbps | Kubernetes Master OCI Load Balancer shape / bandwidth
4142

4243
### TLS Certificates & SSH key pair
4344
name | default | description

instances/etcd/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ resource "oci_core_instance" "TFInstanceEtcd" {
66
count = "${var.count}"
77
availability_domain = "${var.availability_domain}"
88
compartment_id = "${var.compartment_ocid}"
9-
display_name = "${var.label_prefix}${var.display_name}-${count.index}"
10-
hostname_label = "${var.hostname_label}-${count.index}"
9+
display_name = "${var.label_prefix}${var.display_name_prefix}-${count.index}"
10+
hostname_label = "${var.hostname_label_prefix}-${count.index}"
1111
image = "${lookup(data.oci_core_images.ImageOCID.images[0], "id")}"
1212
shape = "${var.shape}"
1313

1414
create_vnic_details {
1515
subnet_id = "${var.subnet_id}"
16-
display_name = "${var.label_prefix}${var.display_name}-${count.index}"
17-
hostname_label = "${var.hostname_label}-${count.index}"
16+
display_name = "${var.label_prefix}${var.display_name_prefix}-${count.index}"
17+
hostname_label = "${var.hostname_label_prefix}-${count.index}"
1818
assign_public_ip = "${(var.control_plane_subnet_access == "private") ? "false" : "true"}"
1919
private_ip = "${var.assign_private_ip == "true" ? cidrhost(lookup(var.network_cidrs,var.subnet_name), count.index+2) : ""}"
2020
},

instances/etcd/variables.tf

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
variable "network_cidrs" {
22
type = "map"
3-
default = {
4-
VCN-CIDR = "10.0.0.0/16"
5-
PublicSubnetAD1 = "10.0.10.0/24"
6-
PublicSubnetAD2 = "10.0.11.0/24"
7-
PublicSubnetAD3 = "10.0.12.0/24"
8-
etcdSubnetAD1 = "10.0.20.0/24"
9-
etcdSubnetAD2 = "10.0.21.0/24"
10-
etcdSubnetAD3 = "10.0.22.0/24"
11-
masterSubnetAD1 = "10.0.30.0/24"
12-
masterSubnetAD2 = "10.0.31.0/24"
13-
masterSubnetAD3 = "10.0.32.0/24"
14-
workerSubnetAD1 = "10.0.40.0/24"
15-
workerSubnetAD2 = "10.0.41.0/24"
16-
workerSubnetAD3 = "10.0.42.0/24"
17-
k8sCCMLBSubnetAD1 = "10.0.50.0/24"
18-
k8sCCMLBSubnetAD2 = "10.0.51.0/24"
19-
k8sCCMLBSubnetAD3 = "10.0.52.0/24"
20-
}
213
}
224
variable "availability_domain" {}
235
variable "compartment_ocid" {}
24-
variable "display_name" {}
25-
variable "hostname_label" {}
6+
variable "display_name_prefix" {}
7+
variable "hostname_label_prefix" {}
268

279
variable "shape" {
2810
default = "VM.Standard1.1"

instances/k8smaster/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ resource "oci_core_instance" "TFInstanceK8sMaster" {
1010
hostname_label = "${var.hostname_label_prefix}-${count.index}"
1111
image = "${lookup(data.oci_core_images.ImageOCID.images[0], "id")}"
1212
shape = "${var.shape}"
13-
subnet_id = "${var.subnet_id}"
13+
14+
create_vnic_details {
15+
subnet_id = "${var.subnet_id}"
16+
display_name = "${var.label_prefix}${var.display_name_prefix}-${count.index}"
17+
hostname_label = "${var.hostname_label_prefix}-${count.index}"
18+
assign_public_ip = "${(var.control_plane_subnet_access == "private") ? "false" : "true"}"
19+
private_ip = "${var.assign_private_ip == "true" ? cidrhost(lookup(var.network_cidrs,var.subnet_name), count.index+2) : ""}"
20+
}
1421

1522
extended_metadata {
1623
roles = "masters"

instances/k8smaster/variables.tf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ variable "count" {
99
default = "1"
1010
}
1111

12+
variable "control_plane_subnet_access" {
13+
description = "Whether instances in the control plane are launched in a public or private subnets"
14+
default = "public"
15+
}
16+
17+
variable "network_cidrs" {
18+
type = "map"
19+
}
1220
variable "subnet_id" {}
21+
variable "subnet_name" {}
1322
variable "domain_name" {}
1423
variable "shape" {}
1524
variable "tenancy_ocid" {}
@@ -81,6 +90,7 @@ variable "flexvolume_driver_secret" {}
8190
variable "volume_provisioner_version" {}
8291
variable "volume_provisioner_secret" {}
8392

84-
85-
86-
93+
variable "assign_private_ip" {
94+
description = "Assign a static private ip based on CIDR block for that AD"
95+
default = false
96+
}

instances/k8sworker/cloud_init/bootstrap.template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ write_files:
7575
content: |
7676
${api-server-key-content}
7777
78+
${reverse_proxy-content}
7879

7980
runcmd:
8081
- echo "Running k8s init..."

instances/k8sworker/datasources.tf

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ data "template_file" "setup-template" {
1313
template = "${file("${path.module}/scripts/setup.template.sh")}"
1414

1515
vars = {
16-
master_lb = "${var.master_lb}"
17-
domain_name = "${var.domain_name}"
18-
docker_ver = "${var.docker_ver}"
19-
etcd_ver = "${var.etcd_ver}"
20-
flannel_ver = "${var.flannel_ver}"
21-
k8s_ver = "${var.k8s_ver}"
22-
docker_max_log_size = "${var.worker_docker_max_log_size}"
23-
docker_max_log_files = "${var.worker_docker_max_log_files}"
24-
etcd_discovery_url = "${file("${path.root}/generated/discovery${var.etcd_discovery_url}")}"
25-
etcd_endpoints = "${var.etcd_endpoints}"
26-
worker_iscsi_volume_mount = "${var.worker_iscsi_volume_mount}"
27-
flexvolume_driver_version = "${var.flexvolume_driver_version}"
16+
master_lb = "${var.master_lb}"
17+
domain_name = "${var.domain_name}"
18+
docker_ver = "${var.docker_ver}"
19+
etcd_ver = "${var.etcd_ver}"
20+
flannel_ver = "${var.flannel_ver}"
21+
k8s_ver = "${var.k8s_ver}"
22+
docker_max_log_size = "${var.worker_docker_max_log_size}"
23+
docker_max_log_files = "${var.worker_docker_max_log_files}"
24+
etcd_discovery_url = "${file("${path.root}/generated/discovery${var.etcd_discovery_url}")}"
25+
etcd_endpoints = "${var.etcd_endpoints}"
26+
worker_iscsi_volume_mount = "${var.worker_iscsi_volume_mount}"
27+
flexvolume_driver_version = "${var.flexvolume_driver_version}"
28+
reverse_proxy_setup = "${var.reverse_proxy_setup}"
2829
}
2930
}
3031

@@ -97,6 +98,7 @@ data "template_file" "kube_worker_cloud_init_file" {
9798
ca-key-content = "${base64gzip(var.root_ca_key)}"
9899
api-server-key-content = "${base64gzip(var.api_server_private_key_pem)}"
99100
api-server-cert-content = "${base64gzip(var.api_server_cert_pem)}"
101+
reverse_proxy-content = "${var.reverse_proxy_clount_init}"
100102
}
101103
}
102104

instances/k8sworker/scripts/setup.template.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ sed -e "s/__FQDN_HOSTNAME__/$FQDN_HOSTNAME/g" \
234234
-e "s/__SWAP_OPTION__/$SWAP_OPTION/g" \
235235
/root/services/kubelet.service > /etc/systemd/system/kubelet.service
236236

237+
${reverse_proxy_setup}
237238
## Wait for k8s master to be available. There is a possible race on pod networks otherwise.
238239
until [ "$(curl -k --cert /etc/kubernetes/ssl/apiserver.pem --key /etc/kubernetes/ssl/apiserver-key.pem $K8S_API_SERVER_LB/healthz 2>/dev/null)" == "ok" ]; do
239240
sleep 3

instances/k8sworker/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@ variable "worker_iscsi_volume_mount" {
8383
}
8484

8585
variable "flexvolume_driver_version" {}
86+
87+
variable "reverse_proxy_setup" {}
88+
89+
variable "reverse_proxy_clount_init" {}

0 commit comments

Comments
 (0)