Skip to content

Commit

Permalink
Minion->Node rename: NODE_IP_BASE, NODE_IP_RANGES, NODE_IP_RANGE, etc
Browse files Browse the repository at this point in the history
NODE_IPS
NODE_IP
NODE_MEMORY_MB
  • Loading branch information
13rac1 committed Nov 25, 2015
1 parent 83ed2fa commit 6fe68a7
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $num_minion = (ENV['NUM_MINIONS'] || 1).to_i

# ip configuration
$master_ip = ENV['MASTER_IP']
$minion_ip_base = ENV['MINION_IP_BASE'] || ""
$minion_ip_base = ENV['NODE_IP_BASE'] || ""
$minion_ips = $num_minion.times.collect { |n| $minion_ip_base + "#{n+3}" }

# Determine the OS platform to use
Expand Down
4 changes: 2 additions & 2 deletions cluster/vagrant/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export MASTER_NAME="${INSTANCE_PREFIX}-master"
REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-false}

# Map out the IPs, names and container subnets of each minion
export MINION_IP_BASE=${MINION_IP_BASE-"10.245.1."}
export NODE_IP_BASE=${NODE_IP_BASE-"10.245.1."}
NODE_CONTAINER_SUBNET_BASE="10.246"
MASTER_CONTAINER_NETMASK="255.255.255.0"
MASTER_CONTAINER_ADDR="${NODE_CONTAINER_SUBNET_BASE}.0.1"
MASTER_CONTAINER_SUBNET="${NODE_CONTAINER_SUBNET_BASE}.0.1/24"
CONTAINER_SUBNET="${NODE_CONTAINER_SUBNET_BASE}.0.0/16"
for ((i=0; i < NUM_MINIONS; i++)) do
MINION_IPS[$i]="${MINION_IP_BASE}$((i+3))"
NODE_IPS[$i]="${NODE_IP_BASE}$((i+3))"
MINION_NAMES[$i]="${INSTANCE_PREFIX}-minion-$((i+1))"
NODE_CONTAINER_SUBNETS[$i]="${NODE_CONTAINER_SUBNET_BASE}.$((i+1)).1/24"
NODE_CONTAINER_ADDRS[$i]="${NODE_CONTAINER_SUBNET_BASE}.$((i+1)).1"
Expand Down
2 changes: 1 addition & 1 deletion cluster/vagrant/provision-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fi
# Setup hosts file to support ping by hostname to each minion in the cluster from apiserver
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
minion=${MINION_NAMES[$i]}
ip=${MINION_IPS[$i]}
ip=${NODE_IPS[$i]}
if [ ! "$(cat /etc/hosts | grep $minion)" ]; then
echo "Adding $minion to hosts file"
echo "$ip $minion" >> /etc/hosts
Expand Down
8 changes: 4 additions & 4 deletions cluster/vagrant/provision-minion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ if [ ! "$(cat /etc/hosts | grep $MASTER_NAME)" ]; then
echo "Adding $MASTER_NAME to hosts file"
echo "$MASTER_IP $MASTER_NAME" >> /etc/hosts
fi
echo "$MINION_IP $MINION_NAME" >> /etc/hosts
echo "$NODE_IP $MINION_NAME" >> /etc/hosts

# Setup hosts file to support ping by hostname to each minion in the cluster
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
minion=${MINION_NAMES[$i]}
ip=${MINION_IPS[$i]}
ip=${NODE_IPS[$i]}
if [ ! "$(cat /etc/hosts | grep $minion)" ]; then
echo "Adding $minion to hosts file"
echo "$ip $minion" >> /etc/hosts
Expand Down Expand Up @@ -145,13 +145,13 @@ cat <<EOF >/etc/salt/minion.d/grains.conf
grains:
cloud: vagrant
network_mode: openvswitch
node_ip: '$(echo "$MINION_IP" | sed -e "s/'/''/g")'
node_ip: '$(echo "$NODE_IP" | sed -e "s/'/''/g")'
api_servers: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
networkInterfaceName: '$(echo "$NETWORK_IF_NAME" | sed -e "s/'/''/g")'
roles:
- kubernetes-pool
cbr-cidr: '$(echo "$CONTAINER_SUBNET" | sed -e "s/'/''/g")'
hostname_override: '$(echo "$MINION_IP" | sed -e "s/'/''/g")'
hostname_override: '$(echo "$NODE_IP" | sed -e "s/'/''/g")'
docker_opts: '$(echo "$DOCKER_OPTS" | sed -e "s/'/''/g")'
EOF

Expand Down
18 changes: 9 additions & 9 deletions cluster/vagrant/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function detect-master () {
# Get minion IP addresses and store in KUBE_NODE_IP_ADDRESSES[]
function detect-minions {
echo "Minions already detected" 1>&2
KUBE_NODE_IP_ADDRESSES=("${MINION_IPS[@]}")
KUBE_NODE_IP_ADDRESSES=("${NODE_IPS[@]}")
}

# Verify prereqs on host machine Also sets exports USING_KUBE_SCRIPTS=true so
Expand Down Expand Up @@ -125,7 +125,7 @@ function create-provision-scripts {
echo "MASTER_NAME='${INSTANCE_PREFIX}-master'"
echo "MASTER_IP='${MASTER_IP}'"
echo "MINION_NAMES=(${MINION_NAMES[@]})"
echo "MINION_IPS=(${MINION_IPS[@]})"
echo "NODE_IPS=(${NODE_IPS[@]})"
echo "NODE_IP='${MASTER_IP}'"
echo "CONTAINER_SUBNET='${CONTAINER_SUBNET}'"
echo "CONTAINER_NETMASK='${MASTER_CONTAINER_NETMASK}'"
Expand Down Expand Up @@ -170,10 +170,10 @@ function create-provision-scripts {
echo "MASTER_IP='${MASTER_IP}'"
echo "MINION_NAMES=(${MINION_NAMES[@]})"
echo "MINION_NAME=(${MINION_NAMES[$i]})"
echo "MINION_IPS=(${MINION_IPS[@]})"
echo "MINION_IP='${MINION_IPS[$i]}'"
echo "NODE_IPS=(${NODE_IPS[@]})"
echo "NODE_IP='${NODE_IPS[$i]}'"
echo "NODE_ID='$i'"
echo "NODE_IP='${MINION_IPS[$i]}'"
echo "NODE_IP='${NODE_IPS[$i]}'"
echo "MASTER_CONTAINER_SUBNET='${MASTER_CONTAINER_SUBNET}'"
echo "CONTAINER_ADDR='${NODE_CONTAINER_ADDRS[$i]}'"
echo "CONTAINER_NETMASK='${NODE_CONTAINER_NETMASKS[$i]}'"
Expand Down Expand Up @@ -242,13 +242,13 @@ function verify-cluster {

echo
echo "Waiting for each minion to be registered with cloud provider"
for (( i=0; i<${#MINION_IPS[@]}; i++)); do
local machine="${MINION_IPS[$i]}"
for (( i=0; i<${#NODE_IPS[@]}; i++)); do
local machine="${NODE_IPS[$i]}"
local count="0"
until [[ "$count" == "1" ]]; do
local minions
minions=$("${KUBE_ROOT}/cluster/kubectl.sh" get nodes -o go-template='{{range.items}}{{.metadata.name}}:{{end}}' --api-version=v1)
count=$(echo $minions | grep -c "${MINION_IPS[i]}") || {
count=$(echo $minions | grep -c "${NODE_IPS[i]}") || {
printf "."
sleep 2
count="0"
Expand Down Expand Up @@ -339,7 +339,7 @@ function test-teardown {
# Find the minion name based on the IP address
function find-vagrant-name-by-ip {
local ip="$1"
local ip_pattern="${MINION_IP_BASE}(.*)"
local ip_pattern="${NODE_IP_BASE}(.*)"

# This is subtle. We map 10.245.2.2 -> minion-1. We do this by matching a
# regexp and using the capture to construct the name.
Expand Down
4 changes: 2 additions & 2 deletions cluster/vsphere/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ MASTER_MEMORY_MB=1024
MASTER_CPU=1

MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}}))
MINION_IP_RANGES=($(eval echo "10.244.{1..${NUM_MINIONS}}.0/24"))
MINION_MEMORY_MB=2048
NODE_IP_RANGES=($(eval echo "10.244.{1..${NUM_MINIONS}}.0/24"))
NODE_MEMORY_MB=2048
NODE_CPU=1

SERVICE_CLUSTER_IP_RANGE="10.244.240.0/20" # formerly PORTAL_NET
Expand Down
4 changes: 2 additions & 2 deletions cluster/vsphere/config-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ MASTER_MEMORY_MB=1024
MASTER_CPU=1

MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}}))
MINION_IP_RANGES=($(eval echo "10.244.{1..${NUM_MINIONS}}.0/24"))
MINION_MEMORY_MB=1024
NODE_IP_RANGES=($(eval echo "10.244.{1..${NUM_MINIONS}}.0/24"))
NODE_MEMORY_MB=1024
NODE_CPU=1

SERVICE_CLUSTER_IP_RANGE="10.244.240.0/20" # formerly PORTAL_NET
Expand Down
2 changes: 1 addition & 1 deletion cluster/vsphere/templates/salt-minion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ grains:
roles:
- kubernetes-pool
- kubernetes-pool-vsphere
cbr-cidr: $MINION_IP_RANGE
cbr-cidr: $NODE_IP_RANGE
EOF

# Install Salt
Expand Down
4 changes: 2 additions & 2 deletions cluster/vsphere/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ function kube-up {
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/hostname.sh"
echo "KUBE_MASTER=${KUBE_MASTER}"
echo "KUBE_MASTER_IP=${KUBE_MASTER_IP}"
echo "MINION_IP_RANGE=${MINION_IP_RANGES[$i]}"
echo "NODE_IP_RANGE=${NODE_IP_RANGES[$i]}"
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/salt-minion.sh"
) > "${KUBE_TEMP}/minion-start-${i}.sh"

(
kube-up-vm "${MINION_NAMES[$i]}" -c ${NODE_CPU-1} -m ${MINION_MEMORY_MB-1024}
kube-up-vm "${MINION_NAMES[$i]}" -c ${NODE_CPU-1} -m ${NODE_MEMORY_MB-1024}
kube-run "${MINION_NAMES[$i]}" "${KUBE_TEMP}/minion-start-${i}.sh"
) &
done
Expand Down
2 changes: 1 addition & 1 deletion docs/design/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Example of GCE's advanced routing rules:
```sh
gcloud compute routes add "${MINION_NAMES[$i]}" \
--project "${PROJECT}" \
--destination-range "${MINION_IP_RANGES[$i]}" \
--destination-range "${NODE_IP_RANGES[$i]}" \
--network "${NETWORK}" \
--next-hop-instance "${MINION_NAMES[$i]}" \
--next-hop-instance-zone "${ZONE}" &
Expand Down

0 comments on commit 6fe68a7

Please sign in to comment.