mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 06:43:54 +00:00
Merge pull request #22845 from ZhangZhenhua/eliminate-roles-ambiguity
Auto commit by PR queue bot
This commit is contained in:
commit
d221649429
@ -20,11 +20,12 @@
|
|||||||
# And separated with blank space like <user_1@ip_1> <user_2@ip_2> <user_3@ip_3>
|
# And separated with blank space like <user_1@ip_1> <user_2@ip_2> <user_3@ip_3>
|
||||||
export nodes=${nodes:-"vcap@10.10.103.250 vcap@10.10.103.162 vcap@10.10.103.223"}
|
export nodes=${nodes:-"vcap@10.10.103.250 vcap@10.10.103.162 vcap@10.10.103.223"}
|
||||||
|
|
||||||
# Define all your nodes role: a(master) or i(minion) or ai(both master and minion), must be the order same
|
# Define all your nodes role: a(master) or i(minion) or ai(both master and minion),
|
||||||
role=${roles:-"ai i i"}
|
# Roles must be the same order with the nodes.
|
||||||
|
roles=${roles:-"ai i i"}
|
||||||
# If it practically impossible to set an array as an environment variable
|
# If it practically impossible to set an array as an environment variable
|
||||||
# from a script, so assume variable is a string then convert it to an array
|
# from a script, so assume variable is a string then convert it to an array
|
||||||
export roles=($role)
|
export roles_array=($roles)
|
||||||
|
|
||||||
# Define minion numbers
|
# Define minion numbers
|
||||||
export NUM_NODES=${NUM_NODES:-3}
|
export NUM_NODES=${NUM_NODES:-3}
|
||||||
|
@ -44,14 +44,14 @@ function setClusterInfo() {
|
|||||||
for i in $nodes; do
|
for i in $nodes; do
|
||||||
nodeIP=${i#*@}
|
nodeIP=${i#*@}
|
||||||
|
|
||||||
if [[ "${roles[${ii}]}" == "ai" ]]; then
|
if [[ "${roles_array[${ii}]}" == "ai" ]]; then
|
||||||
MASTER_IP=$nodeIP
|
MASTER_IP=$nodeIP
|
||||||
MASTER=$i
|
MASTER=$i
|
||||||
NODE_IPS="$nodeIP"
|
NODE_IPS="$nodeIP"
|
||||||
elif [[ "${roles[${ii}]}" == "a" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "a" ]]; then
|
||||||
MASTER_IP=$nodeIP
|
MASTER_IP=$nodeIP
|
||||||
MASTER=$i
|
MASTER=$i
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "i" ]]; then
|
||||||
if [[ -z "${NODE_IPS}" ]];then
|
if [[ -z "${NODE_IPS}" ]];then
|
||||||
NODE_IPS="$nodeIP"
|
NODE_IPS="$nodeIP"
|
||||||
else
|
else
|
||||||
@ -140,11 +140,11 @@ function verify-cluster() {
|
|||||||
|
|
||||||
for i in ${nodes}
|
for i in ${nodes}
|
||||||
do
|
do
|
||||||
if [ "${roles[${ii}]}" == "a" ]; then
|
if [ "${roles_array[${ii}]}" == "a" ]; then
|
||||||
verify-master
|
verify-master
|
||||||
elif [ "${roles[${ii}]}" == "i" ]; then
|
elif [ "${roles_array[${ii}]}" == "i" ]; then
|
||||||
verify-node "$i"
|
verify-node "$i"
|
||||||
elif [ "${roles[${ii}]}" == "ai" ]; then
|
elif [ "${roles_array[${ii}]}" == "ai" ]; then
|
||||||
verify-master
|
verify-master
|
||||||
verify-node "$i"
|
verify-node "$i"
|
||||||
else
|
else
|
||||||
@ -343,7 +343,7 @@ function detect-nodes() {
|
|||||||
local ii=0
|
local ii=0
|
||||||
for i in ${nodes}
|
for i in ${nodes}
|
||||||
do
|
do
|
||||||
if [ "${roles[${ii}]}" == "i" ] || [ "${roles[${ii}]}" == "ai" ]; then
|
if [ "${roles_array[${ii}]}" == "i" ] || [ "${roles_array[${ii}]}" == "ai" ]; then
|
||||||
KUBE_NODE_IP_ADDRESSES+=("${i#*@}")
|
KUBE_NODE_IP_ADDRESSES+=("${i#*@}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -378,11 +378,11 @@ function kube-up() {
|
|||||||
for i in ${nodes}
|
for i in ${nodes}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if [ "${roles[${ii}]}" == "a" ]; then
|
if [ "${roles_array[${ii}]}" == "a" ]; then
|
||||||
provision-master
|
provision-master
|
||||||
elif [ "${roles[${ii}]}" == "ai" ]; then
|
elif [ "${roles_array[${ii}]}" == "ai" ]; then
|
||||||
provision-masterandnode
|
provision-masterandnode
|
||||||
elif [ "${roles[${ii}]}" == "i" ]; then
|
elif [ "${roles_array[${ii}]}" == "i" ]; then
|
||||||
provision-node "$i"
|
provision-node "$i"
|
||||||
else
|
else
|
||||||
echo "unsupported role for ${i}. Please check"
|
echo "unsupported role for ${i}. Please check"
|
||||||
@ -698,7 +698,7 @@ function kube-down() {
|
|||||||
|
|
||||||
local ii=0
|
local ii=0
|
||||||
for i in ${nodes}; do
|
for i in ${nodes}; do
|
||||||
if [[ "${roles[${ii}]}" == "ai" || "${roles[${ii}]}" == "a" ]]; then
|
if [[ "${roles_array[${ii}]}" == "ai" || "${roles_array[${ii}]}" == "a" ]]; then
|
||||||
echo "Cleaning on master ${i#*@}"
|
echo "Cleaning on master ${i#*@}"
|
||||||
ssh $SSH_OPTS -t "$i" "
|
ssh $SSH_OPTS -t "$i" "
|
||||||
pgrep etcd && \
|
pgrep etcd && \
|
||||||
@ -716,11 +716,11 @@ function kube-down() {
|
|||||||
'
|
'
|
||||||
" || echo "Cleaning on master ${i#*@} failed"
|
" || echo "Cleaning on master ${i#*@} failed"
|
||||||
|
|
||||||
if [[ "${roles[${ii}]}" == "ai" ]]; then
|
if [[ "${roles_array[${ii}]}" == "ai" ]]; then
|
||||||
ssh $SSH_OPTS -t "$i" "sudo rm -rf /var/lib/kubelet"
|
ssh $SSH_OPTS -t "$i" "sudo rm -rf /var/lib/kubelet"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "i" ]]; then
|
||||||
echo "Cleaning on node ${i#*@}"
|
echo "Cleaning on node ${i#*@}"
|
||||||
ssh $SSH_OPTS -t "$i" "
|
ssh $SSH_OPTS -t "$i" "
|
||||||
pgrep flanneld && \
|
pgrep flanneld && \
|
||||||
@ -786,7 +786,7 @@ function push-master() {
|
|||||||
|
|
||||||
local ii=0
|
local ii=0
|
||||||
for i in ${nodes}; do
|
for i in ${nodes}; do
|
||||||
if [[ "${roles[${ii}]}" == "a" || "${roles[${ii}]}" == "ai" ]]; then
|
if [[ "${roles_array[${ii}]}" == "a" || "${roles_array[${ii}]}" == "ai" ]]; then
|
||||||
echo "Cleaning master ${i#*@}"
|
echo "Cleaning master ${i#*@}"
|
||||||
ssh $SSH_OPTS -t "$i" "
|
ssh $SSH_OPTS -t "$i" "
|
||||||
pgrep etcd && sudo -p '[sudo] stop the all process: ' -- /bin/bash -c '
|
pgrep etcd && sudo -p '[sudo] stop the all process: ' -- /bin/bash -c '
|
||||||
@ -811,11 +811,11 @@ function push-master() {
|
|||||||
'" || echo "Cleaning master ${i#*@} failed"
|
'" || echo "Cleaning master ${i#*@} failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${roles[${ii}]}" == "a" ]]; then
|
if [[ "${roles_array[${ii}]}" == "a" ]]; then
|
||||||
provision-master
|
provision-master
|
||||||
elif [[ "${roles[${ii}]}" == "ai" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "ai" ]]; then
|
||||||
provision-masterandnode
|
provision-masterandnode
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "i" ]]; then
|
||||||
((ii=ii+1))
|
((ii=ii+1))
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
@ -846,7 +846,7 @@ function push-node() {
|
|||||||
local existing=false
|
local existing=false
|
||||||
|
|
||||||
for i in ${nodes}; do
|
for i in ${nodes}; do
|
||||||
if [[ "${roles[${ii}]}" == "i" && ${i#*@} == "$node_ip" ]]; then
|
if [[ "${roles_array[${ii}]}" == "i" && ${i#*@} == "$node_ip" ]]; then
|
||||||
echo "Cleaning node ${i#*@}"
|
echo "Cleaning node ${i#*@}"
|
||||||
ssh $SSH_OPTS -t "$i" "
|
ssh $SSH_OPTS -t "$i" "
|
||||||
sudo -p '[sudo] stop the all process: ' -- /bin/bash -c '
|
sudo -p '[sudo] stop the all process: ' -- /bin/bash -c '
|
||||||
@ -869,10 +869,10 @@ function push-node() {
|
|||||||
'" || echo "Cleaning node ${i#*@} failed"
|
'" || echo "Cleaning node ${i#*@} failed"
|
||||||
provision-node "$i"
|
provision-node "$i"
|
||||||
existing=true
|
existing=true
|
||||||
elif [[ "${roles[${ii}]}" == "a" || "${roles[${ii}]}" == "ai" ]] && [[ ${i#*@} == "$node_ip" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "a" || "${roles_array[${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"
|
||||||
existing=true
|
existing=true
|
||||||
elif [[ "${roles[${ii}]}" == "i" || "${roles[${ii}]}" == "a" || "${roles[${ii}]}" == "ai" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "i" || "${roles_array[${ii}]}" == "a" || "${roles_array[${ii}]}" == "ai" ]]; then
|
||||||
((ii=ii+1))
|
((ii=ii+1))
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
@ -904,7 +904,7 @@ function kube-push() {
|
|||||||
#stop all the kube's process & etcd
|
#stop all the kube's process & etcd
|
||||||
local ii=0
|
local ii=0
|
||||||
for i in ${nodes}; do
|
for i in ${nodes}; do
|
||||||
if [[ "${roles[${ii}]}" == "ai" || "${roles[${ii}]}" == "a" ]]; then
|
if [[ "${roles_array[${ii}]}" == "ai" || "${roles_array[${ii}]}" == "a" ]]; then
|
||||||
echo "Cleaning on master ${i#*@}"
|
echo "Cleaning on master ${i#*@}"
|
||||||
ssh $SSH_OPTS -t "$i" "
|
ssh $SSH_OPTS -t "$i" "
|
||||||
pgrep etcd && \
|
pgrep etcd && \
|
||||||
@ -917,7 +917,7 @@ function kube-push() {
|
|||||||
/etc/init.d/etcd \
|
/etc/init.d/etcd \
|
||||||
/etc/default/etcd
|
/etc/default/etcd
|
||||||
'" || echo "Cleaning on master ${i#*@} failed"
|
'" || echo "Cleaning on master ${i#*@} failed"
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "i" ]]; then
|
||||||
echo "Cleaning on node ${i#*@}"
|
echo "Cleaning on node ${i#*@}"
|
||||||
ssh $SSH_OPTS -t $i "
|
ssh $SSH_OPTS -t $i "
|
||||||
pgrep flanneld && \
|
pgrep flanneld && \
|
||||||
@ -952,11 +952,11 @@ function kube-push() {
|
|||||||
|
|
||||||
local ii=0
|
local ii=0
|
||||||
for i in ${nodes}; do
|
for i in ${nodes}; do
|
||||||
if [[ "${roles[${ii}]}" == "a" ]]; then
|
if [[ "${roles_array[${ii}]}" == "a" ]]; then
|
||||||
provision-master
|
provision-master
|
||||||
elif [[ "${roles[${ii}]}" == "i" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "i" ]]; then
|
||||||
provision-node "$i"
|
provision-node "$i"
|
||||||
elif [[ "${roles[${ii}]}" == "ai" ]]; then
|
elif [[ "${roles_array[${ii}]}" == "ai" ]]; then
|
||||||
provision-masterandnode
|
provision-masterandnode
|
||||||
else
|
else
|
||||||
echo "unsupported role for ${i}. please check"
|
echo "unsupported role for ${i}. please check"
|
||||||
|
Loading…
Reference in New Issue
Block a user