Skip to content

Commit

Permalink
Add vagrant support
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Oct 16, 2014
1 parent 99bca68 commit 5c4bd55
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cluster/vagrant/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ MINION_TAG="${INSTANCE_PREFIX}-minion"

# IP LOCATIONS FOR INTERACTING WITH THE MINIONS
MINION_IP_BASE="10.245.2."
declare -A VAGRANT_MINION_NAMES_BY_IP

for (( i=0; i <${NUM_MINIONS}; i++)) do
KUBE_MINION_IP_ADDRESSES[$i]="${MINION_IP_BASE}$[$i+2]"
MINION_IP[$i]="${MINION_IP_BASE}$[$i+2]"
MINION_NAMES[$i]="${MINION_IP[$i]}"
VAGRANT_MINION_NAMES[$i]="minion-$[$i+1]"

VAGRANT_MINION_NAMES_BY_IP["${MINION_IP[$i]}"]="${VAGRANT_MINION_NAMES[$i]}"
done
2 changes: 2 additions & 0 deletions cluster/vagrant/provision-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ MASTER_PASSWD=vagrant

# Location to hold temp files for provision process
KUBE_TEMP=/var/kube-temp

PORTAL_NET=10.0.0.0/16
5 changes: 5 additions & 0 deletions cluster/vagrant/provision-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ grains:
- kubernetes-master
EOF

mkdir -p /srv/salt-overlay/pillar
cat <<EOF >/srv/salt-overlay/pillar/cluster-params.sls
portal_net: $PORTAL_NET
EOF

# Configure the salt-master
# Auto accept all keys from minions that try to join
mkdir -p /etc/salt/master.d
Expand Down
13 changes: 13 additions & 0 deletions cluster/vagrant/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,16 @@ function get-password {
export KUBE_PASSWORD=vagrant
echo "Using credentials: $KUBE_USER:$KUBE_PASSWORD"
}

# SSH to a node by name ($1) and run a command ($2).
function ssh-to-node {
local node="$1"
local cmd="$2"
local machine="${VAGRANT_MINION_NAMES_BY_IP[${node}]}"
vagrant ssh "${machine}" -c "${cmd}" | grep -v "Connection to.*closed"
}

# Restart the kube-proxy on a node ($1)
function restart-kube-proxy {
ssh-to-node "$1" "sudo systemctl restart kube-proxy"
}

0 comments on commit 5c4bd55

Please sign in to comment.