Skip to content

Commit

Permalink
change minion to node for libvirt-coreos
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengguoyong committed Oct 26, 2015
1 parent e97483a commit 2a65559
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
26 changes: 13 additions & 13 deletions cluster/libvirt-coreos/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ export MASTER_IP="192.168.10.1"
export INSTANCE_PREFIX=kubernetes
export MASTER_NAME="${INSTANCE_PREFIX}-master"

# Map out the IPs, names and container subnets of each minion
export MINION_IP_BASE="192.168.10."
MINION_CONTAINER_SUBNET_BASE="10.10"
# Map out the IPs, names and container subnets of each node
export NODE_IP_BASE="192.168.10."
NODE_CONTAINER_SUBNET_BASE="10.10"
MASTER_CONTAINER_NETMASK="255.255.255.0"
MASTER_CONTAINER_ADDR="${MINION_CONTAINER_SUBNET_BASE}.0.1"
MASTER_CONTAINER_SUBNET="${MINION_CONTAINER_SUBNET_BASE}.0.1/24"
CONTAINER_SUBNET="${MINION_CONTAINER_SUBNET_BASE}.0.0/16"
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"
if [[ "$NUM_MINIONS" -gt 253 ]]; then
echo "ERROR: Because of how IPs are allocated in ${BASH_SOURCE}, you cannot create more than 253 minions"
echo "ERROR: Because of how IPs are allocated in ${BASH_SOURCE}, you cannot create more than 253 nodes"
exit 1
fi
for ((i=0; i < NUM_MINIONS; i++)) do
MINION_IPS[$i]="${MINION_IP_BASE}$((i+2))"
MINION_NAMES[$i]="${INSTANCE_PREFIX}-minion-$((i+1))"
MINION_CONTAINER_SUBNETS[$i]="${MINION_CONTAINER_SUBNET_BASE}.$((i+1)).1/24"
MINION_CONTAINER_ADDRS[$i]="${MINION_CONTAINER_SUBNET_BASE}.$((i+1)).1"
MINION_CONTAINER_NETMASKS[$i]="255.255.255.0"
NODE_IPS[$i]="${NODE_IP_BASE}$((i+2))"
NODE_NAMES[$i]="${INSTANCE_PREFIX}-node-$((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"
NODE_CONTAINER_NETMASKS[$i]="255.255.255.0"
done
MINION_CONTAINER_SUBNETS[$NUM_MINIONS]=$MASTER_CONTAINER_SUBNET
NODE_CONTAINER_SUBNETS[$NUM_MINIONS]=$MASTER_CONTAINER_SUBNET

SERVICE_CLUSTER_IP_RANGE=10.11.0.0/16 # formerly PORTAL_NET

Expand Down
4 changes: 2 additions & 2 deletions cluster/libvirt-coreos/user_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ coreos:
Name=cbr0
[Network]
Address=${MINION_CONTAINER_SUBNETS[$i]}
Address=${NODE_CONTAINER_SUBNETS[$i]}
[Route]
Destination=${CONTAINER_SUBNET}
Expand Down Expand Up @@ -113,4 +113,4 @@ coreos:
reboot-strategy: off

$( [[ ${type} =~ "master" ]] && render-template "$ROOT/user_data_master.yml" )
$( [[ ${type} =~ "minion" ]] && render-template "$ROOT/user_data_minion.yml" )
$( [[ ${type} =~ "node" ]] && render-template "$ROOT/user_data_minion.yml" )
2 changes: 1 addition & 1 deletion cluster/libvirt-coreos/user_data_minion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ coreos:
[Service]
ExecStart=/opt/kubernetes/bin/kubelet \
--address=0.0.0.0 \
--hostname-override=${MINION_IPS[$i]} \
--hostname-override=${NODE_IPS[$i]} \
--api-servers=http://${MASTER_IP}:8080 \
$( [[ "$ENABLE_CLUSTER_DNS" == "true" ]] && echo "--cluster-dns=${DNS_SERVER_IP}" ) \
$( [[ "$ENABLE_CLUSTER_DNS" == "true" ]] && echo "--cluster-domain=${DNS_DOMAIN}" ) \
Expand Down
32 changes: 16 additions & 16 deletions cluster/libvirt-coreos/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ function detect-master {
echo "KUBE_MASTER: $KUBE_MASTER"
}

# Get minion IP addresses and store in KUBE_MINION_IP_ADDRESSES[]
function detect-minions {
KUBE_MINION_IP_ADDRESSES=("${MINION_IPS[@]}")
# Get node IP addresses and store in KUBE_NODE_IP_ADDRESSES[]
function detect-nodes {
KUBE_NODE_IP_ADDRESSES=("${NODE_IPS[@]}")
}

# Verify prereqs on host machine
Expand Down Expand Up @@ -166,9 +166,9 @@ function wait-cluster-readiness {

local timeout=120
while [[ $timeout -ne 0 ]]; do
nb_ready_minions=$("${kubectl}" get nodes -o go-template="{{range.items}}{{range.status.conditions}}{{.type}}{{end}}:{{end}}" --api-version=v1 2>/dev/null | tr ':' '\n' | grep -c Ready || true)
echo "Nb ready minions: $nb_ready_minions / $NUM_MINIONS"
if [[ "$nb_ready_minions" -eq "$NUM_MINIONS" ]]; then
nb_ready_nodes=$("${kubectl}" get nodes -o go-template="{{range.items}}{{range.status.conditions}}{{.type}}{{end}}:{{end}}" --api-version=v1 2>/dev/null | tr ':' '\n' | grep -c Ready || true)
echo "Nb ready nodes: $nb_ready_nodes / $NUM_MINIONS"
if [[ "$nb_ready_nodes" -eq "$NUM_MINIONS" ]]; then
return 0
fi

Expand All @@ -182,7 +182,7 @@ function wait-cluster-readiness {
# Instantiate a kubernetes cluster
function kube-up {
detect-master
detect-minions
detect-nodes
gen-kube-bearertoken
initialize-pool keep_base_image
initialize-network
Expand All @@ -195,21 +195,21 @@ function kube-up {
if [[ $i -eq $NUM_MINIONS ]]; then
etcd2_initial_cluster[$i]="${MASTER_NAME}=http://${MASTER_IP}:2380"
else
etcd2_initial_cluster[$i]="${MINION_NAMES[$i]}=http://${MINION_IPS[$i]}:2380"
etcd2_initial_cluster[$i]="${NODE_NAMES[$i]}=http://${NODE_IPS[$i]}:2380"
fi
done
etcd2_initial_cluster=$(join , "${etcd2_initial_cluster[@]}")
readonly machines=$(join , "${KUBE_MINION_IP_ADDRESSES[@]}")
readonly machines=$(join , "${KUBE_NODE_IP_ADDRESSES[@]}")

for (( i = 0 ; i <= $NUM_MINIONS ; i++ )); do
if [[ $i -eq $NUM_MINIONS ]]; then
type=master
name=$MASTER_NAME
public_ip=$MASTER_IP
else
type=minion-$(printf "%02d" $i)
name=${MINION_NAMES[$i]}
public_ip=${MINION_IPS[$i]}
type=node-$(printf "%02d" $i)
name=${NODE_NAMES[$i]}
public_ip=${NODE_IPS[$i]}
fi
image=$name.img
config=kubernetes_config_$type
Expand Down Expand Up @@ -263,7 +263,7 @@ function kube-push {
kube-push-internal
ssh-to-node "$MASTER_NAME" "sudo systemctl restart kube-apiserver kube-controller-manager kube-scheduler"
for ((i=0; i < NUM_MINIONS; i++)); do
ssh-to-node "${MINION_NAMES[$i]}" "sudo systemctl restart kubelet kube-proxy"
ssh-to-node "${NODE_NAMES[$i]}" "sudo systemctl restart kubelet kube-proxy"
done
wait-cluster-readiness
}
Expand Down Expand Up @@ -312,14 +312,14 @@ function ssh-to-node {
local cmd="$2"
local machine

if [[ "$node" == "$MASTER_IP" ]] || [[ "$node" =~ ^"$MINION_IP_BASE" ]]; then
if [[ "$node" == "$MASTER_IP" ]] || [[ "$node" =~ ^"$NODE_IP_BASE" ]]; then
machine="$node"
elif [[ "$node" == "$MASTER_NAME" ]]; then
machine="$MASTER_IP"
else
for ((i=0; i < NUM_MINIONS; i++)); do
if [[ "$node" == "${MINION_NAMES[$i]}" ]]; then
machine="${MINION_IPS[$i]}"
if [[ "$node" == "${NODE_NAMES[$i]}" ]]; then
machine="${NODE_IPS[$i]}"
break
fi
done
Expand Down

0 comments on commit 2a65559

Please sign in to comment.