Add host IP to /etc/hosts on all nodes 13/47313/1
authorBryan Sullivan <bryan.sullivan@att.com>
Thu, 16 Nov 2017 07:39:23 +0000 (23:39 -0800)
committerBryan Sullivan <bryan.sullivan@att.com>
Thu, 16 Nov 2017 07:39:23 +0000 (23:39 -0800)
JIRA: MODELS-2

Change-Id: I3ec97467dca521d869943d2334a452e1a73ff6e7
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
tools/cloudify/k8s-cloudify.sh
tools/kubernetes/k8s-cluster.sh

index bff85e4..36abb63 100644 (file)
@@ -141,6 +141,7 @@ function setup () {
   HOST_IP=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
 
   # Forward host port 80 to VM
+  log "Setip iptables to forward $HOST_IP port 80 to Cloudify Manager VM at $VM_IP"
   sudo iptables -t nat -I PREROUTING -p tcp -d $HOST_IP --dport 80 -j DNAT --to-destination $VM_IP:80
   sudo iptables -I FORWARD -m state -d $VM_IP/32 --state NEW,RELATED,ESTABLISHED -j ACCEPT
   sudo iptables -t nat -A POSTROUTING -j MASQUERADE
index f55c1b9..54c5973 100644 (file)
@@ -58,9 +58,9 @@ function setup_prereqs() {
 sudo apt-get -y remove kubectl kubelet kubeadm
 sudo apt-get update
 sudo apt-get upgrade -y
-# Set hostname on agent nodes
-if [[ "$1" == "agent" ]]; then
-  echo $(ip route get 8.8.8.8 | awk '{print $NF; exit}') $HOSTNAME | sudo tee -a /etc/hosts
+# Set hostname
+if [[ $(grep -c $HOSTNAME /etc/hosts) -eq 0 ]]; then
+  echo "$(ip route get 8.8.8.8 | awk '{print $NF; exit}') $HOSTNAME" | sudo tee -a /etc/hosts
 fi
 # Install docker 1.12 (default for xenial is 1.12.6)
 sudo apt-get install -y docker.io