mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
parent
8d50977286
commit
b1f29c5073
|
|
@ -33,7 +33,7 @@ var addNodesCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
addCmd.AddCommand(addNodesCmd)
|
||||
addNodesCmd.Flags().StringVarP(&opt.ClusterCfgFile, "file", "f", "", "Path to a configuration file")
|
||||
addNodesCmd.Flags().StringVarP(&opt.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
|
||||
addNodesCmd.Flags().BoolVarP(&opt.SkipCheck, "yes", "y", false, "Skip pre-check of the installation")
|
||||
addNodesCmd.Flags().BoolVarP(&opt.SkipPullImages, "skip-pull-images", "", false, "Skip pre pull images")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ var clusterCmd = &cobra.Command{
|
|||
func init() {
|
||||
createCmd.AddCommand(clusterCmd)
|
||||
|
||||
clusterCmd.Flags().StringVarP(&opt.ClusterCfgFile, "file", "f", "", "Path to a configuration file")
|
||||
clusterCmd.Flags().StringVarP(&opt.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
|
||||
clusterCmd.Flags().StringVarP(&opt.Kubernetes, "with-kubernetes", "", "", "Specify a supported version of kubernetes")
|
||||
clusterCmd.Flags().BoolVarP(&opt.Kubesphere, "with-kubesphere", "", false, "Deploy a specific version of kubesphere (default v3.0.0)")
|
||||
clusterCmd.Flags().BoolVarP(&opt.SkipCheck, "yes", "y", false, "Skip pre-check of the installation")
|
||||
|
|
|
|||
|
|
@ -42,9 +42,8 @@ var configCmd = &cobra.Command{
|
|||
func init() {
|
||||
createCmd.AddCommand(configCmd)
|
||||
|
||||
//configCmd.Flags().StringVarP(&opt.Addons, "with-storage", "", "", "Add storage plugins")
|
||||
configCmd.Flags().StringVarP(&opt.Name, "name", "", "config-sample", "Specify a name of cluster object")
|
||||
configCmd.Flags().StringVarP(&opt.ClusterCfgPath, "file", "f", "", "Specify a configuration file path")
|
||||
configCmd.Flags().StringVarP(&opt.Name, "name", "", "sample", "Specify a name of cluster object")
|
||||
configCmd.Flags().StringVarP(&opt.ClusterCfgPath, "filename", "f", "", "Specify a configuration file path")
|
||||
configCmd.Flags().StringVarP(&opt.Kubernetes, "with-kubernetes", "", "", "Specify a supported version of kubernetes")
|
||||
configCmd.Flags().BoolVarP(&opt.Kubesphere, "with-kubesphere", "", false, "Deploy a specific version of kubesphere (default v3.0.0)")
|
||||
configCmd.Flags().BoolVarP(&opt.FromCluster, "from-cluster", "", false, "Create a configuration based on existing cluster")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
// deleteCmd represents the delete command
|
||||
var deleteCmd = &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "Delete a cluster",
|
||||
Short: "Delete nodes or cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ var deleteClusterCmd = &cobra.Command{
|
|||
func init() {
|
||||
deleteCmd.AddCommand(deleteClusterCmd)
|
||||
|
||||
deleteClusterCmd.Flags().StringVarP(&opt.ClusterCfgFile, "config", "f", "", "Path to a configuration file")
|
||||
deleteClusterCmd.Flags().StringVarP(&opt.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ var deleteNodeCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
deleteCmd.AddCommand(deleteNodeCmd)
|
||||
deleteNodeCmd.Flags().StringVarP(&opt.ClusterCfgFile, "config", "f", "", "Path to a config")
|
||||
deleteNodeCmd.Flags().StringVarP(&opt.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
Copyright 2020 The KubeSphere Authors.
|
||||
|
||||
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 (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// createCmd represents the create command
|
||||
var deployCmd = &cobra.Command{
|
||||
Use: "deploy",
|
||||
Short: "Deploy Software on the existing K8s",
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(deployCmd)
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
Copyright 2020 The KubeSphere Authors.
|
||||
|
||||
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 (
|
||||
"github.com/kubesphere/kubekey/pkg/deploy"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// clusterCmd represents the cluster command
|
||||
var deployKsCmd = &cobra.Command{
|
||||
Use: "kubesphere",
|
||||
Short: "Deploy KubeSphere on the existing K8s",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return deploy.DeployKubeSphere(opt.KsVersion, opt.Registry, opt.Kubeconfig)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
deployCmd.AddCommand(deployKsCmd)
|
||||
|
||||
deployKsCmd.Flags().StringVarP(&opt.Kubeconfig, "kubeconfig", "", "", "Specify a kubeconfig file")
|
||||
deployKsCmd.Flags().StringVarP(&opt.KsVersion, "version", "v", "v3.0.0", "Specify a supported version of kubesphere")
|
||||
deployKsCmd.Flags().StringVarP(&opt.Registry, "registry", "", "", "Specify a image registry address")
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ var upgradeCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
rootCmd.AddCommand(upgradeCmd)
|
||||
upgradeCmd.Flags().StringVarP(&opt.ClusterCfgFile, "file", "f", "", "Path to a configuration file")
|
||||
upgradeCmd.Flags().StringVarP(&opt.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
|
||||
upgradeCmd.Flags().StringVarP(&opt.Kubernetes, "with-kubernetes", "", "", "Specify a supported version of kubernetes")
|
||||
upgradeCmd.Flags().BoolVarP(&opt.Kubesphere, "with-kubesphere", "", false, "Deploy a specific version of kubesphere (default v3.0.0)")
|
||||
upgradeCmd.Flags().BoolVarP(&opt.SkipPullImages, "skip-pull-images", "", false, "Skip pre pull images")
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
Copyright 2020 The KubeSphere Authors.
|
||||
|
||||
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 (
|
||||
"github.com/kubesphere/kubekey/pkg/upgrade"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// clusterCmd represents the cluster command
|
||||
var upgradeKsCmd = &cobra.Command{
|
||||
Use: "kubesphere",
|
||||
Short: "Deploy KubeSphere on the existing K8s",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return upgrade.KsToV3(opt.KsVersion, opt.Registry, opt.Kubeconfig)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
upgradeCmd.AddCommand(upgradeKsCmd)
|
||||
|
||||
upgradeKsCmd.Flags().StringVarP(&opt.Kubeconfig, "kubeconfig", "", "", "Specify a kubeconfig file")
|
||||
upgradeKsCmd.Flags().StringVarP(&opt.KsVersion, "version", "v", "v3.0.0", "Specify a supported version of kubesphere")
|
||||
upgradeKsCmd.Flags().StringVarP(&opt.Registry, "registry", "", "", "Specify a image registry address")
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ metadata:
|
|||
spec:
|
||||
hosts:
|
||||
- {name: node1, address: 172.16.0.2, internalAddress: 172.16.0.2, user: ubuntu, password: Qcloud@123}
|
||||
- {name: node2, address: 172.16.0.2, internalAddress: 172.16.0.2, user: ubuntu, password: Qcloud@123}
|
||||
- {name: node2, address: 172.16.0.3, internalAddress: 172.16.0.3, user: ubuntu, password: Qcloud@123}
|
||||
roleGroups:
|
||||
etcd:
|
||||
- node1
|
||||
|
|
@ -74,17 +74,10 @@ spec:
|
|||
)
|
||||
|
||||
type Options struct {
|
||||
Name string
|
||||
KubeVersion string
|
||||
StorageNum int
|
||||
DefaultStorageClass string
|
||||
DefaultStorageClassName string
|
||||
LocalVolumeEnabled bool
|
||||
NfsClientEnabled bool
|
||||
CephRBDEnabled bool
|
||||
GlusterFSEnabled bool
|
||||
KubeSphereEnabled bool
|
||||
KubeSphereConfigMap string
|
||||
Name string
|
||||
KubeVersion string
|
||||
KubeSphereEnabled bool
|
||||
KubeSphereConfigMap string
|
||||
}
|
||||
|
||||
func GenerateClusterObjStr(opt *Options) (string, error) {
|
||||
|
|
@ -108,7 +101,7 @@ func GenerateClusterObj(k8sVersion, ksVersion, name, kubeconfig, clusterCfgPath
|
|||
output := strings.Split(name, ".")
|
||||
opt.Name = output[0]
|
||||
} else {
|
||||
opt.Name = "config-sample"
|
||||
opt.Name = "sample"
|
||||
}
|
||||
if len(k8sVersion) == 0 {
|
||||
opt.KubeVersion = kubekeyapi.DefaultKubeVersion
|
||||
|
|
@ -148,8 +141,8 @@ func GenerateClusterObj(k8sVersion, ksVersion, name, kubeconfig, clusterCfgPath
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get current dir")
|
||||
}
|
||||
CheckConfigFileStatus(fmt.Sprintf("%s/%s.yaml", currentDir, opt.Name))
|
||||
cmd := fmt.Sprintf("echo %s | base64 -d > %s/%s.yaml", ClusterObjStrBase64, currentDir, opt.Name)
|
||||
CheckConfigFileStatus(fmt.Sprintf("%s/config-%s.yaml", currentDir, opt.Name))
|
||||
cmd := fmt.Sprintf("echo %s | base64 -d > %s/config-%s.yaml", ClusterObjStrBase64, currentDir, opt.Name)
|
||||
err1 := exec.Command("/bin/sh", "-c", cmd).Run()
|
||||
if err1 != nil {
|
||||
return err1
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func getClusterInfo(mgr *manager.Manager, _ *kubekeyapi.HostCfg) error {
|
|||
return errors.Wrap(err, "Failed to get current kube-apiserver version")
|
||||
}
|
||||
|
||||
ksVersion, err := mgr.Runner.ExecuteCmd("sudo -E /bin/sh -c \"/usr/local/bin/kubectl get deploy -n kubesphere-system ks-console -o jsonpath='{.metadata.labels.version}'\"", 2, false)
|
||||
ksVersion, err := mgr.Runner.ExecuteCmd("sudo -E /bin/sh -c \"/usr/local/bin/kubectl get deploy -n kubesphere-system ks-console -o jsonpath='{.metadata.labels.version}'\"", 5, false)
|
||||
if err != nil {
|
||||
if mgr.Cluster.KubeSphere.Enabled {
|
||||
return errors.New("Failed to get kubesphere version")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ func ExecTasks(mgr *manager.Manager) error {
|
|||
{Task: GetCurrentVersions, ErrMsg: "Failed to get current version"},
|
||||
{Task: preinstall.InitOS, ErrMsg: "Failed to download kube binaries"},
|
||||
{Task: UpgradeKubeCluster, ErrMsg: "Failed to upgrade kube cluster"},
|
||||
//{Task: network.DeployNetworkPlugin, ErrMsg: "Failed to deploy network plugin"},
|
||||
{Task: SyncConfiguration, ErrMsg: "Failed to sync configuration"},
|
||||
{Task: kubesphere.DeployKubeSphere, ErrMsg: "Failed to upgrade kubesphere"},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue