mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 18:03:02 +00:00
* Support for custom OpenEBS base path * retest * rollback * Change the default value of basePath
81 lines
2.3 KiB
Go
81 lines
2.3 KiB
Go
/*
|
|
Copyright 2021 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 storage
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/kubesphere/kubekey/cmd/kk/pkg/common"
|
|
"github.com/kubesphere/kubekey/cmd/kk/pkg/core/action"
|
|
"github.com/kubesphere/kubekey/cmd/kk/pkg/core/prepare"
|
|
"github.com/kubesphere/kubekey/cmd/kk/pkg/core/task"
|
|
"github.com/kubesphere/kubekey/cmd/kk/pkg/core/util"
|
|
"github.com/kubesphere/kubekey/cmd/kk/pkg/images"
|
|
"github.com/kubesphere/kubekey/cmd/kk/pkg/plugins/storage/templates"
|
|
)
|
|
|
|
type DeployLocalVolumeModule struct {
|
|
common.KubeModule
|
|
Skip bool
|
|
}
|
|
|
|
func (d *DeployLocalVolumeModule) IsSkip() bool {
|
|
return d.Skip
|
|
}
|
|
|
|
func (d *DeployLocalVolumeModule) Init() {
|
|
d.Name = "DeployStorageClassModule"
|
|
d.Desc = "Deploy cluster storage-class"
|
|
|
|
generate := &task.RemoteTask{
|
|
Name: "GenerateOpenEBSManifest",
|
|
Desc: "Generate OpenEBS manifest",
|
|
Hosts: d.Runtime.GetHostsByRole(common.Master),
|
|
Prepare: &prepare.PrepareCollection{
|
|
new(common.OnlyFirstMaster),
|
|
new(CheckDefaultStorageClass),
|
|
},
|
|
Action: &action.Template{
|
|
Template: templates.OpenEBS,
|
|
Dst: filepath.Join(common.KubeAddonsDir, templates.OpenEBS.Name()),
|
|
Data: util.Data{
|
|
"ProvisionerLocalPVImage": images.GetImage(d.Runtime, d.KubeConf, "provisioner-localpv").ImageName(),
|
|
"LinuxUtilsImage": images.GetImage(d.Runtime, d.KubeConf, "linux-utils").ImageName(),
|
|
"BasePath": d.KubeConf.Cluster.Storage.OpenEBS.BasePath,
|
|
},
|
|
},
|
|
Parallel: true,
|
|
}
|
|
|
|
deploy := &task.RemoteTask{
|
|
Name: "DeployOpenEBS",
|
|
Desc: "Deploy OpenEBS as cluster default StorageClass",
|
|
Hosts: d.Runtime.GetHostsByRole(common.Master),
|
|
Prepare: &prepare.PrepareCollection{
|
|
new(common.OnlyFirstMaster),
|
|
new(CheckDefaultStorageClass),
|
|
},
|
|
Action: new(DeployLocalVolume),
|
|
Parallel: true,
|
|
}
|
|
|
|
d.Tasks = []task.Interface{
|
|
generate,
|
|
deploy,
|
|
}
|
|
}
|