From 423376a924feab3f793a84755a2f3a3411f6f7ec Mon Sep 17 00:00:00 2001 From: Raphael Randschau Date: Mon, 24 Oct 2016 19:55:30 +0200 Subject: [PATCH] fix(networking): allow cluster internal communication since Scaleway does not have private DNS that resolves by default we have to change the hostnames to the internal IP prior to registering workers. Then the internal communication works fine --- main.tf | 2 ++ templates/master.sh | 9 ++++++++- templates/worker.sh | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 9d7d00b..2d270d8 100644 --- a/main.tf +++ b/main.tf @@ -42,6 +42,7 @@ resource "scaleway_server" "k8s-master" { provisioner "remote-exec" { inline = [ + "sudo echo ${self.private_ip} > /tmp/private_ip", "sudo chmod +x /tmp/master.sh", "sudo /tmp/master.sh", ] @@ -80,6 +81,7 @@ resource "scaleway_server" "k8s-worker" { provisioner "remote-exec" { inline = [ + "sudo echo ${self.private_ip} > /tmp/private_ip", "sudo chmod +x /tmp/worker.sh", "sudo /tmp/worker.sh", ] diff --git a/templates/master.sh b/templates/master.sh index 4d9d822..bb8ea0f 100644 --- a/templates/master.sh +++ b/templates/master.sh @@ -1,5 +1,12 @@ #!/bin/bash -v +# modify hostname to allow communication between Scaleway instances. +private_ip=$(cat /tmp/private_ip) +hostname $private_ip +echo $private_ip > /etc/hostname +echo "127.0.0.1 $private_ip" >> /etc/hosts + +# install kubernetes master apt-get install -y apt-transport-https curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - @@ -11,7 +18,7 @@ apt-get install -y kubelet kubeadm kubectl kubernetes-cni curl -sSL https://get.docker.com/ | sh systemctl start docker -kubeadm init --token=${k8stoken} +kubeadm init --token=${k8stoken} --use-kubernetes-version v1.4.3 kubectl apply -f https://git.io/weave-kube diff --git a/templates/worker.sh b/templates/worker.sh index c0cdd73..0ddd0fe 100644 --- a/templates/worker.sh +++ b/templates/worker.sh @@ -1,5 +1,12 @@ #!/bin/bash -v +# modify hostname to allow communication between Scaleway instances. +private_ip=$(cat /tmp/private_ip) +hostname $private_ip +echo $private_ip > /etc/hostname +echo "127.0.0.1 $private_ip" >> /etc/hosts + +# install kubernetes worker apt-get install -y apt-transport-https curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -