Skip to content

Commit

Permalink
Fixed controller node name of DNS 1123 rules
Browse files Browse the repository at this point in the history
  • Loading branch information
alicek106 committed Mar 24, 2019
1 parent 8f9cb68 commit e88e04f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ansible/hosts/ec2.py
Expand Up @@ -713,7 +713,8 @@ def add_instance(self, instance, region):
if not hostname:
hostname = dest
else:
hostname = self.to_safe(hostname).lower()
print('Do nothing to keep DNS 1123 rule in EC2 instance hostname') # Edited 2019. 03. 24
# hostname = self.to_safe(hostname).lower()

# if we only want to include hosts that match a pattern, skip those that don't
if self.pattern_include and not self.pattern_include.match(hostname):
Expand Down Expand Up @@ -789,6 +790,7 @@ def add_instance(self, instance, region):
# Inventory: Group by tag keys
if self.group_by_tag_keys:
for k, v in instance.tags.items():
print(v)
if self.expand_csv_tags and v and ',' in v:
values = map(lambda x: x.strip(), v.split(','))
else:
Expand Down
5 changes: 4 additions & 1 deletion ansible/hosts/groups
Expand Up @@ -7,18 +7,21 @@

[tag_ansibleNodeType_controller]

[tag_ansibleNodeType_controller_etcd]

#######################
#### Kubespray Groups

[etcd:children]
tag_ansibleNodeType_controller
tag_ansibleNodeType_controller_etcd
tag_ansibleNodeType_etcd

[kube-node:children]
tag_ansibleNodeType_worker

[kube-master:children]
tag_ansibleNodeType_controller
tag_ansibleNodeType_controller_etcd

[k8s-cluster:children]
kube-master
Expand Down
4 changes: 2 additions & 2 deletions terraform/optional_etcd/2-etcd.tf → terraform/2-etcd.tf
Expand Up @@ -4,7 +4,7 @@
# Delete the below comments to activate etcd.
# But I commented because I'm using kubespray for only 1 master, 1 etcd in 1 instance (default)
resource "aws_instance" "etcd" {
count = 1
count = 2
ami = "${lookup(var.amis, var.region)}"
instance_type = "${var.etcd_instance_type}"

Expand All @@ -21,6 +21,6 @@ resource "aws_instance" "etcd" {
Name = "etcd-${count.index}"
ansibleFilter = "${var.ansibleFilter}"
ansibleNodeType = "etcd"
ansibleNodeName = "etcd${count.index}"
ansibleNodeName = "etcd.${count.index}"
}
}
2 changes: 1 addition & 1 deletion terraform/3-workers.tf
Expand Up @@ -22,7 +22,7 @@ resource "aws_instance" "worker" {
Name = "worker-${count.index}"
ansibleFilter = "${var.ansibleFilter}"
ansibleNodeType = "worker"
ansibleNodeName = "worker${count.index}"
ansibleNodeName = "worker.${count.index}"
}
}

Expand Down
31 changes: 28 additions & 3 deletions terraform/4-controllers.tf
Expand Up @@ -3,7 +3,7 @@
############################

resource "aws_instance" "controller" {
count = 1
count = 2
ami = "${lookup(var.amis, var.region)}"
instance_type = "${var.controller_instance_type}"

Expand All @@ -23,7 +23,32 @@ resource "aws_instance" "controller" {
Name = "controller-${count.index}"
ansibleFilter = "${var.ansibleFilter}"
ansibleNodeType = "controller"
ansibleNodeName = "controller${count.index}"
ansibleNodeName = "controller.${count.index}"
}
}

resource "aws_instance" "controller_etcd" {
count = 1
ami = "${lookup(var.amis, var.region)}"
instance_type = "${var.controller_instance_type}"

iam_instance_profile = "${aws_iam_instance_profile.kubernetes.id}"

subnet_id = "${aws_subnet.kubernetes.id}"
private_ip = "${cidrhost(var.vpc_cidr, 40 + count.index)}"
associate_public_ip_address = true # Instances have public, dynamic IP
source_dest_check = false # TODO Required??

availability_zone = "${var.zone}"
vpc_security_group_ids = ["${aws_security_group.kubernetes.id}"]
key_name = "${var.default_keypair_name}"

tags {
Owner = "${var.owner}"
Name = "controller-etcd-${count.index}"
ansibleFilter = "${var.ansibleFilter}"
ansibleNodeType = "controller.etcd"
ansibleNodeName = "controller.etcd.${count.index}"
}
}

Expand All @@ -50,7 +75,7 @@ resource "aws_elb" "kubernetes_api" {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 15
target = "HTTP:8080/healthz"
target = "HTTPS:6443/"
interval = 30
}

Expand Down

0 comments on commit e88e04f

Please sign in to comment.