change minion to node

This commit is contained in:
eulerzgy 2015-09-23 17:49:22 +08:00
parent 28585bc699
commit 6e92c9393a

View File

@ -21,7 +21,7 @@ SSH_OPTS="-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=E
MASTER=""
MASTER_IP=""
MINION_IPS=""
NODE_IPS=""
# Assumed Vars:
# KUBE_ROOT
@ -32,11 +32,11 @@ function test-build-release {
# From user input set the necessary k8s and etcd configuration information
function setClusterInfo() {
# Initialize MINION_IPS in setClusterInfo function
# MINION_IPS is defined as a global variable, and is concatenated with other nodeIP
# Initialize NODE_IPS in setClusterInfo function
# NODE_IPS is defined as a global variable, and is concatenated with other nodeIP
# When setClusterInfo is called for many times, this could cause potential problems
# Such as, you will have MINION_IPS=192.168.0.2,192.168.0.3,192.168.0.2,192.168.0.3 which is obviously wrong
MINION_IPS=""
# Such as, you will have NODE_IPS=192.168.0.2,192.168.0.3,192.168.0.2,192.168.0.3 which is obviously wrong
NODE_IPS=""
ii=0
for i in $nodes; do
@ -45,15 +45,15 @@ function setClusterInfo() {
if [[ "${roles[${ii}]}" == "ai" ]]; then
MASTER_IP=$nodeIP
MASTER=$i
MINION_IPS="$nodeIP"
NODE_IPS="$nodeIP"
elif [[ "${roles[${ii}]}" == "a" ]]; then
MASTER_IP=$nodeIP
MASTER=$i
elif [[ "${roles[${ii}]}" == "i" ]]; then
if [[ -z "${MINION_IPS}" ]];then
MINION_IPS="$nodeIP"
if [[ -z "${NODE_IPS}" ]];then
NODE_IPS="$nodeIP"
else
MINION_IPS="$MINION_IPS,$nodeIP"
NODE_IPS="$NODE_IPS,$nodeIP"
fi
else
echo "unsupported role for ${i}. please check"
@ -115,10 +115,10 @@ function verify-cluster {
if [ "${roles[${ii}]}" == "a" ]; then
verify-master
elif [ "${roles[${ii}]}" == "i" ]; then
verify-minion $i
verify-node $i
elif [ "${roles[${ii}]}" == "ai" ]; then
verify-master
verify-minion $i
verify-node $i
else
echo "unsupported role for ${i}. please check"
exit 1
@ -155,8 +155,8 @@ function verify-master(){
}
function verify-minion(){
# verify minion has all required daemons
function verify-node(){
# verify node has all required daemons
printf "Validating ${1}"
local -a required_daemon=("kube-proxy" "kubelet" "docker")
local validated="1"
@ -257,30 +257,30 @@ function detect-master {
echo "Using master $MASTER_IP"
}
# Detect the information about the minions
# Detect the information about the nodes
#
# Assumed vars:
# nodes
# Vars set:
# KUBE_MINION_IP_ADDRESS (array)
function detect-minions {
# KUBE_NODE_IP_ADDRESS (array)
function detect-nodes {
source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE-"config-default.sh"}"
KUBE_MINION_IP_ADDRESSES=()
KUBE_NODE_IP_ADDRESSES=()
setClusterInfo
ii=0
for i in ${nodes}
do
if [ "${roles[${ii}]}" == "i" ] || [ "${roles[${ii}]}" == "ai" ]; then
KUBE_MINION_IP_ADDRESSES+=("${i#*@}")
KUBE_NODE_IP_ADDRESSES+=("${i#*@}")
fi
((ii=ii+1))
done
if [[ -z "${KUBE_MINION_IP_ADDRESSES[@]}" ]]; then
echo "Could not detect Kubernetes minion nodes. Make sure you've launched a cluster with 'kube-up.sh'" >&2
if [[ -z "${KUBE_NODE_IP_ADDRESSES[@]}" ]]; then
echo "Could not detect Kubernetes node nodes. Make sure you've launched a cluster with 'kube-up.sh'" >&2
exit 1
fi
}
@ -304,9 +304,9 @@ function kube-up() {
if [ "${roles[${ii}]}" == "a" ]; then
provision-master
elif [ "${roles[${ii}]}" == "ai" ]; then
provision-masterandminion
provision-masterandnode
elif [ "${roles[${ii}]}" == "i" ]; then
provision-minion $i
provision-node $i
else
echo "unsupported role for ${i}. please check"
exit 1
@ -342,7 +342,7 @@ function provision-master() {
setClusterInfo; \
create-etcd-opts; \
create-kube-apiserver-opts "${SERVICE_CLUSTER_IP_RANGE}" "${ADMISSION_CONTROL}" "${SERVICE_NODE_PORT_RANGE}"; \
create-kube-controller-manager-opts "${MINION_IPS}"; \
create-kube-controller-manager-opts "${NODE_IPS}"; \
create-kube-scheduler-opts; \
create-flanneld-opts "127.0.0.1"; \
sudo -p '[sudo] password to start master: ' cp ~/kube/default/* /etc/default/ && sudo cp ~/kube/init_conf/* /etc/init/ && sudo cp ~/kube/init_scripts/* /etc/init.d/ ;\
@ -353,9 +353,9 @@ function provision-master() {
sudo FLANNEL_NET=${FLANNEL_NET} -b ~/kube/reconfDocker.sh "a";"
}
function provision-minion() {
# copy the binaries and scripts to the ~/kube directory on the minion
echo "Deploying minion on machine ${1#*@}"
function provision-node() {
# copy the binaries and scripts to the ~/kube directory on the node
echo "Deploying node on machine ${1#*@}"
echo
ssh $SSH_OPTS $1 "mkdir -p ~/kube/default"
scp -r $SSH_OPTS ubuntu/config-default.sh ubuntu/util.sh ubuntu/reconfDocker.sh ubuntu/minion/* ubuntu/binaries/minion "${1}:~/kube"
@ -372,9 +372,9 @@ function provision-minion() {
sudo -b ~/kube/reconfDocker.sh "i";"
}
function provision-masterandminion() {
function provision-masterandnode() {
# copy the binaries and scripts to the ~/kube directory on the master
echo "Deploying master and minion on machine ${MASTER_IP}"
echo "Deploying master and node on machine ${MASTER_IP}"
echo
ssh $SSH_OPTS $MASTER "mkdir -p ~/kube/default"
# scp order matters
@ -385,7 +385,7 @@ function provision-masterandminion() {
setClusterInfo; \
create-etcd-opts; \
create-kube-apiserver-opts "${SERVICE_CLUSTER_IP_RANGE}" "${ADMISSION_CONTROL}" "${SERVICE_NODE_PORT_RANGE}"; \
create-kube-controller-manager-opts "${MINION_IPS}"; \
create-kube-controller-manager-opts "${NODE_IPS}"; \
create-kube-scheduler-opts; \
create-kubelet-opts "${MASTER_IP}" "${MASTER_IP}" "${DNS_SERVER_IP}" "${DNS_DOMAIN}";
create-kube-proxy-opts "${MASTER_IP}";\
@ -475,7 +475,7 @@ function push-master {
sudo rm -rf /etc/init/kube* /etc/init/flanneld.conf /etc/init.d/kube* /etc/init.d/flanneld;
sudo rm -rf /etc/default/kube* /etc/default/flanneld;
sudo rm -rf ~/kube' || true
provision-masterandminion
provision-masterandnode
elif [[ "${roles[${ii}]}" == "i" ]]; then
((ii=ii+1))
continue
@ -509,7 +509,7 @@ function push-node() {
sudo rm -rf /etc/init/kube* /etc/init/flanneld.conf /etc/init.d/kube* /etc/init.d/flanneld;
sudo rm -rf /etc/default/kube* /etc/default/flanneld;
sudo rm -rf ~/kube' || true
provision-minion $i
provision-node $i
existing=true
elif [[ "${roles[${ii}]}" == "a" || "${roles[${ii}]}" == "ai" ]] && [[ ${i#*@} == $node_ip ]]; then
echo "${i} is master node, please try ./kube-push -m instead"
@ -570,9 +570,9 @@ function kube-push {
if [[ "${roles[${ii}]}" == "a" ]]; then
provision-master
elif [[ "${roles[${ii}]}" == "i" ]]; then
provision-minion $i
provision-node $i
elif [[ "${roles[${ii}]}" == "ai" ]]; then
provision-masterandminion
provision-masterandnode
else
echo "unsupported role for ${i}. please check"
exit 1