Skip to content

Commit

Permalink
Merge pull request #192 from zyjhtangtang/master
Browse files Browse the repository at this point in the history
fix: yurtctl fail to convert minikube cluster.
  • Loading branch information
rambohe-ch authored Jan 8, 2021
2 parents e3edff8 + f7020d7 commit 3863756
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
26 changes: 2 additions & 24 deletions config/yurtctl-servant/setup_edgenode
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,14 @@ error() {

check_addr()
{
echo $1|grep "^\(https\|http\)\:\/\/[0-9]\{1,3\}\.\([0-9]\{1,3\}\.\)\{2\}[0-9]\{1,3\}\:[0-9]\{1,5\}$" > /dev/null;
echo $1|grep -E '^(http(s)?:\/\/)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:[0-9]{1,5})?$' > /dev/null;
if [ $? -ne 0 ]
then
log "apiserver addr $1 is error."
exit 1
fi
addr=`echo $1 | awk -F '://' '{print $2}'`
ipaddr=`echo $addr | awk -F ':' '{print $1}'`
port=`echo $addr | awk -F ':' '{print $2}'`

echo $ipaddr, $port
a=`echo $ipaddr|awk -F . '{print $1}'` #以"."分隔,取出每个列的值
b=`echo $ipaddr|awk -F . '{print $2}'`
c=`echo $ipaddr|awk -F . '{print $3}'`
d=`echo $ipaddr|awk -F . '{print $4}'`
for num in $a $b $c $d
do
if [ $num -gt 255 ] || [ $num -lt 0 ] #每个数值必须在0-255之间
then
log "apiserver addr $1 is error."
exit 1
fi
done

if [ $port -ge 65536 ];then
log "apiserver addr $1 is error."
exit 1
fi

log apiserver addr $1 is ok.
log "apiserver addr $1 is ok."
return 0
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/yurtctl/util/kubernetes/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
bootstraputil "k8s.io/cluster-bootstrap/token/util"
"k8s.io/klog"
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmcontants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
tokenphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/node"

"github.com/alibaba/openyurt/pkg/yurtctl/constants"
Expand Down Expand Up @@ -414,7 +415,7 @@ func GetOrCreateJoinTokenString(cliSet *kubernetes.Clientset) (string, error) {
}

klog.V(1).Infoln("[token] creating token")
if err := tokenphase.CreateNewTokens(cliSet, []kubeadmapi.BootstrapToken{{Token: token}}); err != nil {
if err := tokenphase.CreateNewTokens(cliSet, []kubeadmapi.BootstrapToken{{Token: token, Usages: kubeadmcontants.DefaultTokenUsages, Groups: kubeadmcontants.DefaultTokenGroups}}); err != nil {
return "", err
}
return tokenStr, nil
Expand Down

0 comments on commit 3863756

Please sign in to comment.