mirror of
https://github.com/labring/sealos.git
synced 2026-09-24 15:46:19 +08:00
+1
-1
@@ -17,7 +17,7 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
"github.com/fanux/sealos/pkg/utils"
|
||||
|
||||
"github.com/fanux/sealos/pkg/install"
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
// Copyright © 2021 sealos.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/fanux/sealos/pkg/utils"
|
||||
|
||||
install "github.com/fanux/sealos/pkg/install"
|
||||
|
||||
"github.com/fanux/sealgate/cloud"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var p bool
|
||||
|
||||
// cloudCmd represents the cloud command
|
||||
var cloudCmd = &cobra.Command{
|
||||
Use: "cloud",
|
||||
Short: "sealos on cloud",
|
||||
Long: `sealos will create vms vpc switch security group on cloud and install kubernetes on it`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("install kubernetes on cloud...")
|
||||
var key, sec string
|
||||
if key = os.Getenv("ACCESS_KEY_ID"); key != "" {
|
||||
install.C.AccessKey = key
|
||||
}
|
||||
if sec = os.Getenv("ACCESS_KEY_SECRET"); sec != "" {
|
||||
install.C.AccessKey = sec
|
||||
}
|
||||
install.CloudInstall(&install.C)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(cloudCmd)
|
||||
cloudCmd.Flags().StringVar(&install.C.AccessKey, "accessKey", "", "cloud provider accessKey, like LTAIah2bOOcr0uuT")
|
||||
cloudCmd.Flags().StringVar(&install.C.AccessSecret, "accessSecret", "", "cloud provider accessSecret, like FN3FcvXUctbudisnHs89bcYlbsZuImh")
|
||||
cloudCmd.Flags().StringVar(&install.C.Provider, "provider", cloud.ALI, "cloud provider type,current support ali")
|
||||
cloudCmd.Flags().IntVar(&install.C.Master, "master", 1, "the number of master vms")
|
||||
cloudCmd.Flags().IntVar(&install.C.Node, "node", 1, "the number of node vms")
|
||||
cloudCmd.Flags().StringVar(&install.C.Version, "version", "v1.16.0", "kubernetes version")
|
||||
cloudCmd.Flags().StringVar(&install.C.Flavor, "flavor", "2C4G", "the type of vms")
|
||||
cloudCmd.Flags().StringVar(&install.C.Name, "name", "sealyun"+utils.RandString(8), "the name of your cluster")
|
||||
cloudCmd.Flags().StringVar(&install.C.Passwd, "passwd", "Fanux#123", "the passwd of your vm servers")
|
||||
cloudCmd.Flags().StringVar(&install.C.Region, "region", "cn-hongkong", "cloud provider region")
|
||||
cloudCmd.Flags().StringVar(&install.C.Zone, "zone", "cn-hongkong-b", "cloud provider region")
|
||||
cloudCmd.Flags().StringVar(&install.C.Image, "image", "centos_7_04_64_20G_alibase_201701015.vhd", "vm os image")
|
||||
cloudCmd.Flags().BoolVar(&p, "y", false, "prompt or not")
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// cloudCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// cloudCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
+5
-5
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
var cniType string
|
||||
var version string
|
||||
var cniVersion string
|
||||
|
||||
// cniCmd represents the cni command
|
||||
var cniCmd = &cobra.Command{
|
||||
@@ -35,15 +35,15 @@ var cniCmd = &cobra.Command{
|
||||
logger.Error("unsupport cni: ", cniType)
|
||||
return
|
||||
}
|
||||
if version == "" {
|
||||
logger.Error("cni version should not nil ", version)
|
||||
if cniVersion == "" {
|
||||
logger.Error("cni version should not nil ", cniVersion)
|
||||
return
|
||||
}
|
||||
yaml := cni.NewNetwork(cniType, cni.MetaData{
|
||||
Interface: "interface=eth.*|en.*|em.*",
|
||||
IPIP: true,
|
||||
MTU: "1440",
|
||||
Version: version,
|
||||
Version: cniVersion,
|
||||
}).Manifests("")
|
||||
fmt.Println(yaml)
|
||||
},
|
||||
@@ -53,7 +53,7 @@ func init() {
|
||||
rootCmd.AddCommand(cniCmd)
|
||||
|
||||
cniCmd.Flags().StringVarP(&cniType, "cni-type", "t", cni.CALICO, "print cni yaml, cni tpye just like, calico.flannel.cilium")
|
||||
cniCmd.Flags().StringVarP(&version, "version", "v", "", "calico version")
|
||||
cniCmd.Flags().StringVarP(&cniVersion, "version", "v", "", "calico version")
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
|
||||
install "github.com/fanux/sealos/pkg/install"
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
"github.com/fanux/sealos/pkg/utils"
|
||||
|
||||
install "github.com/fanux/sealos/pkg/install"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
"github.com/fanux/sealos/pkg/utils"
|
||||
|
||||
"github.com/fanux/sealos/pkg/cni"
|
||||
|
||||
+4
-4
@@ -17,7 +17,7 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
"github.com/fanux/sealos/pkg/utils"
|
||||
|
||||
install "github.com/fanux/sealos/pkg/install"
|
||||
@@ -29,12 +29,12 @@ import (
|
||||
|
||||
var (
|
||||
AppURL string
|
||||
installExample string = `
|
||||
installExample = `
|
||||
# when usr -f flag , you need add something to config file.
|
||||
# Apply the configuration in values.yaml to a kubernetes Cluster.
|
||||
# Apply the configuration in values.yaml to a kubernetes Infra.
|
||||
sealos install --pkg-url /root/dashboard.tar -f values.yaml
|
||||
|
||||
# Apply the yaml passed into stdin to a kubenertes Cluster.
|
||||
# Apply the yaml passed into stdin to a kubenertes Infra.
|
||||
cat values.yaml | sealos install --pkg-url /root/dashboard.tar -f -
|
||||
|
||||
# Set the WorkDir for your Package
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
"github.com/fanux/sealos/pkg/utils"
|
||||
|
||||
install "github.com/fanux/sealos/pkg/install"
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1"
|
||||
v1 "github.com/fanux/sealos/pkg/types/v1alpha1"
|
||||
"github.com/fanux/sealos/pkg/utils"
|
||||
|
||||
"github.com/fanux/sealos/pkg/utils/logger"
|
||||
|
||||
+27
-14
@@ -15,23 +15,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
extver "github.com/linuxsuren/cobra-extension/version"
|
||||
"github.com/fanux/sealos/pkg/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// it's possible to have multiple choices for users to choose GitHub or aliyun as their download source
|
||||
// see also https://github.com/LinuxSuRen/cobra-extension/issues/6
|
||||
const name = "sealos"
|
||||
verCmd := extver.NewVersionCmd("fanux", name, name, func(ver string) string {
|
||||
if strings.HasPrefix(ver, "v") {
|
||||
ver = strings.TrimPrefix(ver, "v")
|
||||
var shortPrint bool
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "version",
|
||||
Args: cobra.NoArgs,
|
||||
Example: `sealer version`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
marshalled, err := json.Marshal(version.Get())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return fmt.Sprintf("https://github.com/fanux/sealos/releases/download/v%s/%s_%s_%s_%s.tar.gz",
|
||||
ver, name, ver, runtime.GOOS, runtime.GOARCH)
|
||||
})
|
||||
rootCmd.AddCommand(verCmd)
|
||||
if shortPrint {
|
||||
fmt.Println(version.Get().String())
|
||||
} else {
|
||||
fmt.Println(string(marshalled))
|
||||
}
|
||||
return nil
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
versionCmd.Flags().BoolVar(&shortPrint, "short", false, "If true, print just the cniVersion number.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user