Skip to content

Commit

Permalink
feat(update): update k3s version
Browse files Browse the repository at this point in the history
update k3s version

Signed-off-by: ysicing <i@ysicing.me>
  • Loading branch information
ysicing committed Mar 18, 2022
1 parent ff68f78 commit 456df2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
23 changes: 1 addition & 22 deletions cmd/kube/k3s.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
es "github.com/ysicing/ergo/pkg/daemon/service"
"github.com/ysicing/ergo/pkg/downloader"
"github.com/ysicing/ergo/pkg/util/factory"
"github.com/ysicing/ergo/pkg/util/ssh"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -79,7 +78,7 @@ func getbin() (string, error) {
filebin, err := exec.LookPath(common.K3sBinName)
if err != nil {
klog.Infof("not found k3s bin, will down k3s %v", common.K3sBinVersion)
if _, err := downloader.Download(common.K3sBinURL, common.K3sBinPath); err != nil {
if _, err := downloader.Download(common.GetK3SURL(), common.K3sBinPath); err != nil {
return "", err
}
os.Chmod(common.K3sBinPath, common.FileMode0755)
Expand Down Expand Up @@ -196,9 +195,6 @@ func initAction(cmd *cobra.Command, args []string) error {
}
klog.Donef("%v get nodes", kubectlbin)
klog.WriteString(string(getnodesoutput))
if err := checkhelm(); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -293,20 +289,3 @@ func checkBin(cmd string) bool {
_, err := exec.LookPath(cmd)
return err == nil
}

// checkhelm check helm
func checkhelm() error {
cmdArgs := os.Args
klog := log.GetInstance()
if checkBin("helm") {
return nil
}
klog.Infof("helm not found, will try to install")
// Download helm
klog.Debug("Download helm")
if err := ssh.RunCmd(cmdArgs[0], "addons", "ysicing/helm"); err != nil {
klog.Errorf("install helm err: %v", err)
return err
}
return nil
}
5 changes: 5 additions & 0 deletions common/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ func GetDefaultErgoCfg() string {
home := GetDefaultCfgDir()
return home + "/ergo.yml"
}

// GetK3SURL 获取k3s地址
func GetK3SURL() string {
return fmt.Sprintf("%s/%s/k3s", K3sBinURL, K3sBinVersion)
}
2 changes: 1 addition & 1 deletion common/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
K3sBinName = "k3s"
K3sBinPath = "/usr/local/bin/k3s"
K3sBinVersion = "v1.23.4+k3s1"
K3sBinURL = "https://github.com/k3s-io/k3s/releases/download/v1.23.1%2Bk3s2/k3s"
K3sBinURL = "https://github.com/k3s-io/k3s/releases/download"
K3sAgentEnv = "/etc/systemd/system/k3s-agent.service.env"
K3sKubeConfig = "/etc/rancher/k3s/k3s.yaml"
CiliumName = "cilium"
Expand Down

0 comments on commit 456df2d

Please sign in to comment.