mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
Experiment: change /bin/sh to /bin/bash
Signed-off-by: 24sama <leo@kubesphere.io>
This commit is contained in:
parent
2a8e074b31
commit
174e54406e
|
|
@ -19,6 +19,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/kubesphere/kubekey/apis/kubekey/v1alpha1"
|
||||
"github.com/kubesphere/kubekey/pkg/pipelines"
|
||||
"github.com/kubesphere/kubekey/pkg/pipelines/common"
|
||||
"github.com/kubesphere/kubekey/version"
|
||||
"github.com/spf13/cobra"
|
||||
"time"
|
||||
|
|
@ -49,8 +50,20 @@ var clusterCmd = &cobra.Command{
|
|||
} else {
|
||||
ksVersion = ""
|
||||
}
|
||||
return pipelines.CreateCluster(opt.ClusterCfgFile, opt.Kubernetes, ksVersion, opt.Kubesphere, opt.Verbose,
|
||||
opt.SkipCheck, opt.SkipPullImages, opt.InCluster, opt.LocalStorage, opt.DownloadCmd)
|
||||
|
||||
arg := common.Argument{
|
||||
FilePath: opt.ClusterCfgFile,
|
||||
KubernetesVersion: opt.Kubernetes,
|
||||
KsEnable: opt.Kubesphere,
|
||||
KsVersion: ksVersion,
|
||||
SkipCheck: opt.SkipCheck,
|
||||
SkipPullImages: opt.SkipPullImages,
|
||||
InCluster: opt.InCluster,
|
||||
DeployLocalStorage: opt.LocalStorage,
|
||||
Debug: opt.Verbose,
|
||||
}
|
||||
|
||||
return pipelines.CreateCluster(arg, opt.DownloadCmd)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -265,12 +265,11 @@ type KubeadmInit struct {
|
|||
}
|
||||
|
||||
func (k *KubeadmInit) Execute(runtime connector.Runtime) error {
|
||||
if _, err := runtime.GetRunner().Cmd("sudo env PATH=$PATH /bin/sh -c \""+
|
||||
"/usr/local/bin/kubeadm init "+
|
||||
if _, err := runtime.GetRunner().SudoCmd("/usr/local/bin/kubeadm init "+
|
||||
"--config=/etc/kubernetes/kubeadm-config.yaml "+
|
||||
"--ignore-preflight-errors=FileExisting-crictl\"", true); err != nil {
|
||||
"--ignore-preflight-errors=FileExisting-crictl", true); err != nil {
|
||||
// kubeadm reset and then retry
|
||||
_, _ = runtime.GetRunner().Cmd("sudo env PATH=$PATH /bin/sh -c \"/usr/local/bin/kubeadm reset -f\"", true)
|
||||
_, _ = runtime.GetRunner().SudoCmd("/usr/local/bin/kubeadm reset -f", true)
|
||||
return errors.Wrap(errors.WithStack(err), "init kubernetes cluster failed")
|
||||
}
|
||||
return nil
|
||||
|
|
@ -378,10 +377,10 @@ func (a *AddMasterNode) Execute(runtime connector.Runtime) error {
|
|||
host := runtime.RemoteHost()
|
||||
if v, ok := a.RootCache.Get(ClusterStatus); ok {
|
||||
cluster := v.(*KubernetesStatus)
|
||||
if _, err := runtime.GetRunner().Cmd(fmt.Sprintf(
|
||||
"sudo env PATH=$PATH /bin/sh -c \"%s\"", fmt.Sprintf("%s --apiserver-advertise-address %s", cluster.JoinMasterCmd, host.GetInternalAddress())),
|
||||
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf(
|
||||
fmt.Sprintf("%s --apiserver-advertise-address %s", cluster.JoinMasterCmd, host.GetInternalAddress())),
|
||||
true); err != nil {
|
||||
_, _ = runtime.GetRunner().Cmd("sudo env PATH=$PATH /bin/sh -c \"/usr/local/bin/kubeadm reset -f\"", true)
|
||||
_, _ = runtime.GetRunner().SudoCmd("/usr/local/bin/kubeadm reset -f", true)
|
||||
return errors.Wrap(errors.WithStack(err), "join master failed")
|
||||
}
|
||||
}
|
||||
|
|
@ -395,8 +394,8 @@ type AddWorkerNode struct {
|
|||
func (a *AddWorkerNode) Execute(runtime connector.Runtime) error {
|
||||
if v, ok := a.RootCache.Get(ClusterStatus); ok {
|
||||
cluster := v.(*KubernetesStatus)
|
||||
if _, err := runtime.GetRunner().Cmd(fmt.Sprintf("sudo env PATH=$PATH /bin/sh -c \"%s\"", cluster.JoinWorkerCmd), true); err != nil {
|
||||
_, _ = runtime.GetRunner().Cmd("sudo env PATH=$PATH /bin/sh -c \"/usr/local/bin/kubeadm reset -f\"", true)
|
||||
if _, err := runtime.GetRunner().SudoCmd(cluster.JoinWorkerCmd, true); err != nil {
|
||||
_, _ = runtime.GetRunner().SudoCmd("/usr/local/bin/kubeadm reset -f", true)
|
||||
return errors.Wrap(errors.WithStack(err), "join master failed")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue