mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
change minion to node
This commit is contained in:
parent
28585bc699
commit
6e92c9393a
@ -21,7 +21,7 @@ SSH_OPTS="-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=E
|
|||||||
|
|
||||||
MASTER=""
|
MASTER=""
|
||||||
MASTER_IP=""
|
MASTER_IP=""
|
||||||
MINION_IPS=""
|
NODE_IPS=""
|
||||||
|
|
||||||
# Assumed Vars:
|
# Assumed Vars:
|
||||||
# KUBE_ROOT
|
# KUBE_ROOT
|
||||||
@ -32,11 +32,11 @@ function test-build-release {
|
|||||||
|
|
||||||
# From user input set the necessary k8s and etcd configuration information
|
# From user input set the necessary k8s and etcd configuration information
|
||||||
function setClusterInfo() {
|
function setClusterInfo() {
|
||||||
# Initialize MINION_IPS in setClusterInfo function
|
# Initialize NODE_IPS in setClusterInfo function
|
||||||
# MINION_IPS is defined as a global variable, and is concatenated with other nodeIP
|
# 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
|
# 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
|
# 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
|
||||||
MINION_IPS=""
|
NODE_IPS=""
|
||||||
|
|
||||||
ii=0
|
ii=0
|
||||||
for i in $nodes; do
|
for i in $nodes; do
|
||||||
@ -45,15 +45,15 @@ function setClusterInfo() {
|
|||||||
if [[ "${roles[${ii}]}" == "ai" ]]; then
|
if [[ "${roles[${ii}]}" == "ai" ]]; then
|
||||||
MASTER_IP=$nodeIP
|
MASTER_IP=$nodeIP
|
||||||
MASTER=$i
|
MASTER=$i
|
||||||
MINION_IPS="$nodeIP"
|
NODE_IPS="$nodeIP"
|
||||||
elif [[ "${roles[${ii}]}" == "a" ]]; then
|
elif [[ "${roles[${ii}]}" == "a" ]]; then
|
||||||
MASTER_IP=$nodeIP
|
MASTER_IP=$nodeIP
|
||||||
MASTER=$i
|
MASTER=$i
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
||||||
if [[ -z "${MINION_IPS}" ]];then
|
if [[ -z "${NODE_IPS}" ]];then
|
||||||
MINION_IPS="$nodeIP"
|
NODE_IPS="$nodeIP"
|
||||||
else
|
else
|
||||||
MINION_IPS="$MINION_IPS,$nodeIP"
|
NODE_IPS="$NODE_IPS,$nodeIP"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "unsupported role for ${i}. please check"
|
echo "unsupported role for ${i}. please check"
|
||||||
@ -115,10 +115,10 @@ function verify-cluster {
|
|||||||
if [ "${roles[${ii}]}" == "a" ]; then
|
if [ "${roles[${ii}]}" == "a" ]; then
|
||||||
verify-master
|
verify-master
|
||||||
elif [ "${roles[${ii}]}" == "i" ]; then
|
elif [ "${roles[${ii}]}" == "i" ]; then
|
||||||
verify-minion $i
|
verify-node $i
|
||||||
elif [ "${roles[${ii}]}" == "ai" ]; then
|
elif [ "${roles[${ii}]}" == "ai" ]; then
|
||||||
verify-master
|
verify-master
|
||||||
verify-minion $i
|
verify-node $i
|
||||||
else
|
else
|
||||||
echo "unsupported role for ${i}. please check"
|
echo "unsupported role for ${i}. please check"
|
||||||
exit 1
|
exit 1
|
||||||
@ -155,8 +155,8 @@ function verify-master(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function verify-minion(){
|
function verify-node(){
|
||||||
# verify minion has all required daemons
|
# verify node has all required daemons
|
||||||
printf "Validating ${1}"
|
printf "Validating ${1}"
|
||||||
local -a required_daemon=("kube-proxy" "kubelet" "docker")
|
local -a required_daemon=("kube-proxy" "kubelet" "docker")
|
||||||
local validated="1"
|
local validated="1"
|
||||||
@ -257,30 +257,30 @@ function detect-master {
|
|||||||
echo "Using master $MASTER_IP"
|
echo "Using master $MASTER_IP"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Detect the information about the minions
|
# Detect the information about the nodes
|
||||||
#
|
#
|
||||||
# Assumed vars:
|
# Assumed vars:
|
||||||
# nodes
|
# nodes
|
||||||
# Vars set:
|
# Vars set:
|
||||||
# KUBE_MINION_IP_ADDRESS (array)
|
# KUBE_NODE_IP_ADDRESS (array)
|
||||||
function detect-minions {
|
function detect-nodes {
|
||||||
source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE-"config-default.sh"}"
|
source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE-"config-default.sh"}"
|
||||||
|
|
||||||
KUBE_MINION_IP_ADDRESSES=()
|
KUBE_NODE_IP_ADDRESSES=()
|
||||||
setClusterInfo
|
setClusterInfo
|
||||||
|
|
||||||
ii=0
|
ii=0
|
||||||
for i in ${nodes}
|
for i in ${nodes}
|
||||||
do
|
do
|
||||||
if [ "${roles[${ii}]}" == "i" ] || [ "${roles[${ii}]}" == "ai" ]; then
|
if [ "${roles[${ii}]}" == "i" ] || [ "${roles[${ii}]}" == "ai" ]; then
|
||||||
KUBE_MINION_IP_ADDRESSES+=("${i#*@}")
|
KUBE_NODE_IP_ADDRESSES+=("${i#*@}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
((ii=ii+1))
|
((ii=ii+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "${KUBE_MINION_IP_ADDRESSES[@]}" ]]; then
|
if [[ -z "${KUBE_NODE_IP_ADDRESSES[@]}" ]]; then
|
||||||
echo "Could not detect Kubernetes minion nodes. Make sure you've launched a cluster with 'kube-up.sh'" >&2
|
echo "Could not detect Kubernetes node nodes. Make sure you've launched a cluster with 'kube-up.sh'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -304,9 +304,9 @@ function kube-up() {
|
|||||||
if [ "${roles[${ii}]}" == "a" ]; then
|
if [ "${roles[${ii}]}" == "a" ]; then
|
||||||
provision-master
|
provision-master
|
||||||
elif [ "${roles[${ii}]}" == "ai" ]; then
|
elif [ "${roles[${ii}]}" == "ai" ]; then
|
||||||
provision-masterandminion
|
provision-masterandnode
|
||||||
elif [ "${roles[${ii}]}" == "i" ]; then
|
elif [ "${roles[${ii}]}" == "i" ]; then
|
||||||
provision-minion $i
|
provision-node $i
|
||||||
else
|
else
|
||||||
echo "unsupported role for ${i}. please check"
|
echo "unsupported role for ${i}. please check"
|
||||||
exit 1
|
exit 1
|
||||||
@ -342,7 +342,7 @@ function provision-master() {
|
|||||||
setClusterInfo; \
|
setClusterInfo; \
|
||||||
create-etcd-opts; \
|
create-etcd-opts; \
|
||||||
create-kube-apiserver-opts "${SERVICE_CLUSTER_IP_RANGE}" "${ADMISSION_CONTROL}" "${SERVICE_NODE_PORT_RANGE}"; \
|
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-kube-scheduler-opts; \
|
||||||
create-flanneld-opts "127.0.0.1"; \
|
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/ ;\
|
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";"
|
sudo FLANNEL_NET=${FLANNEL_NET} -b ~/kube/reconfDocker.sh "a";"
|
||||||
}
|
}
|
||||||
|
|
||||||
function provision-minion() {
|
function provision-node() {
|
||||||
# copy the binaries and scripts to the ~/kube directory on the minion
|
# copy the binaries and scripts to the ~/kube directory on the node
|
||||||
echo "Deploying minion on machine ${1#*@}"
|
echo "Deploying node on machine ${1#*@}"
|
||||||
echo
|
echo
|
||||||
ssh $SSH_OPTS $1 "mkdir -p ~/kube/default"
|
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"
|
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";"
|
sudo -b ~/kube/reconfDocker.sh "i";"
|
||||||
}
|
}
|
||||||
|
|
||||||
function provision-masterandminion() {
|
function provision-masterandnode() {
|
||||||
# copy the binaries and scripts to the ~/kube directory on the master
|
# 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
|
echo
|
||||||
ssh $SSH_OPTS $MASTER "mkdir -p ~/kube/default"
|
ssh $SSH_OPTS $MASTER "mkdir -p ~/kube/default"
|
||||||
# scp order matters
|
# scp order matters
|
||||||
@ -385,7 +385,7 @@ function provision-masterandminion() {
|
|||||||
setClusterInfo; \
|
setClusterInfo; \
|
||||||
create-etcd-opts; \
|
create-etcd-opts; \
|
||||||
create-kube-apiserver-opts "${SERVICE_CLUSTER_IP_RANGE}" "${ADMISSION_CONTROL}" "${SERVICE_NODE_PORT_RANGE}"; \
|
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-kube-scheduler-opts; \
|
||||||
create-kubelet-opts "${MASTER_IP}" "${MASTER_IP}" "${DNS_SERVER_IP}" "${DNS_DOMAIN}";
|
create-kubelet-opts "${MASTER_IP}" "${MASTER_IP}" "${DNS_SERVER_IP}" "${DNS_DOMAIN}";
|
||||||
create-kube-proxy-opts "${MASTER_IP}";\
|
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/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 /etc/default/kube* /etc/default/flanneld;
|
||||||
sudo rm -rf ~/kube' || true
|
sudo rm -rf ~/kube' || true
|
||||||
provision-masterandminion
|
provision-masterandnode
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
||||||
((ii=ii+1))
|
((ii=ii+1))
|
||||||
continue
|
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/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 /etc/default/kube* /etc/default/flanneld;
|
||||||
sudo rm -rf ~/kube' || true
|
sudo rm -rf ~/kube' || true
|
||||||
provision-minion $i
|
provision-node $i
|
||||||
existing=true
|
existing=true
|
||||||
elif [[ "${roles[${ii}]}" == "a" || "${roles[${ii}]}" == "ai" ]] && [[ ${i#*@} == $node_ip ]]; then
|
elif [[ "${roles[${ii}]}" == "a" || "${roles[${ii}]}" == "ai" ]] && [[ ${i#*@} == $node_ip ]]; then
|
||||||
echo "${i} is master node, please try ./kube-push -m instead"
|
echo "${i} is master node, please try ./kube-push -m instead"
|
||||||
@ -570,9 +570,9 @@ function kube-push {
|
|||||||
if [[ "${roles[${ii}]}" == "a" ]]; then
|
if [[ "${roles[${ii}]}" == "a" ]]; then
|
||||||
provision-master
|
provision-master
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
||||||
provision-minion $i
|
provision-node $i
|
||||||
elif [[ "${roles[${ii}]}" == "ai" ]]; then
|
elif [[ "${roles[${ii}]}" == "ai" ]]; then
|
||||||
provision-masterandminion
|
provision-masterandnode
|
||||||
else
|
else
|
||||||
echo "unsupported role for ${i}. please check"
|
echo "unsupported role for ${i}. please check"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user