mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
add glusterfs storage support
This commit is contained in:
parent
e65941baf1
commit
e2ceb69758
|
|
@ -17,22 +17,36 @@ apt install ceph-common
|
|||
yum install ceph-common
|
||||
```
|
||||
## GlusterFS
|
||||
|
||||
* The following kernel modules must be loaded:
|
||||
|
||||
1. dm_snapshot
|
||||
2. dm_mirror
|
||||
3. dm_thin_pool
|
||||
|
||||
For kernel modules, `lsmod | grep <name>` will show you if a given module is present, and `modprobe <name>` will load
|
||||
a given module.
|
||||
|
||||
* Each node requires that the `mount.glusterfs` command is available.
|
||||
|
||||
* GlusterFS client version installed on nodes should be as close as possible to the version of the server.
|
||||
* Take `glusterfs 7.x` as an example.
|
||||
```shell script
|
||||
# Debian
|
||||
wget -O - https://download.gluster.org/pub/gluster/glusterfs/01.old-releases/3.12/rsa.pub | apt-key add -
|
||||
DEBID=$(grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"') &&
|
||||
DEBVER=$(grep 'VERSION=' /etc/os-release | grep -Eo '[a-z]+') &&
|
||||
DEBARCH=$(dpkg --print-architecture) &&
|
||||
echo deb https://download.gluster.org/pub/gluster/glusterfs/01.old-releases/3.12/LATEST/Debian/${DEBID}/${DEBARCH}/apt ${DEBVER} main > /etc/apt/sources.list.d/gluster.list
|
||||
wget -O - https://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub | apt-key add -
|
||||
DEBID=$(grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"')
|
||||
DEBVER=$(grep 'VERSION=' /etc/os-release | grep -Eo '[a-z]+')
|
||||
DEBARCH=$(dpkg --print-architecture)
|
||||
echo deb https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/${DEBID}/${DEBARCH}/apt ${DEBVER} main > /etc/apt/sources.list.d/gluster.list
|
||||
apt update
|
||||
apt install glusterfs-client
|
||||
|
||||
# Ubuntu
|
||||
apt install software-properties-common
|
||||
add-apt-repository ppa:gluster/glusterfs-3.12
|
||||
add-apt-repository ppa:gluster/glusterfs-7
|
||||
apt update
|
||||
apt install glusterfs-server
|
||||
apt install glusterfs-client
|
||||
|
||||
# Centos / Redhat
|
||||
yum install glusterfs-client
|
||||
yum install glusterfs-fuse
|
||||
```
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package glusterfs
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"github.com/kubesphere/kubekey/pkg/util"
|
||||
"github.com/kubesphere/kubekey/pkg/util/manager"
|
||||
"github.com/lithammer/dedent"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var GlusterFSTempl = template.Must(template.New("glusterfs").Parse(
|
||||
dedent.Dedent(`---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: heketi-secret
|
||||
namespace: kube-system
|
||||
type: kubernetes.io/glusterfs
|
||||
data:
|
||||
key: {{ .JwtAdminKey }}
|
||||
|
||||
---
|
||||
apiVersion: storage.k8s.io/v1
|
||||
kind: StorageClass
|
||||
metadata:
|
||||
name: {{ .StorageClassName }}
|
||||
annotations:
|
||||
storageclass.kubesphere.io/supported_access_modes: '["ReadWriteOnce","ReadOnlyMany","ReadWriteMany"]'
|
||||
storageclass.beta.kubernetes.io/is-default-class: "{{ if .IsDefaultClass }}true{{ else }}false{{ end }}"
|
||||
provisioner: kubernetes.io/glusterfs
|
||||
parameters:
|
||||
resturl: "{{ .RestUrl }}"
|
||||
clusterid: "{{ .ClusterID }}"
|
||||
restauthenabled: "{{ if .RestAuthEnabled }}true{{ else }}false{{ end }}"
|
||||
restuser: "{{ .RestUser }}"
|
||||
secretNamespace: "kube-system"
|
||||
secretName: "{{ .SecretName }}"
|
||||
gidMin: "{{ .GidMin }}"
|
||||
gidMax: "{{ .GidMax }}"
|
||||
volumetype: "{{ .VolumeType }}"
|
||||
allowVolumeExpansion: true
|
||||
|
||||
`)))
|
||||
|
||||
func GenerateGlusterFSManifests(mgr *manager.Manager) (string, error) {
|
||||
|
||||
return util.Render(GlusterFSTempl, util.Data{
|
||||
"IsDefaultClass": mgr.Cluster.Storage.GlusterFS.IsDefaultClass,
|
||||
"StorageClassName": mgr.Cluster.Storage.GlusterFS.StorageClassName,
|
||||
"ClusterID": mgr.Cluster.Storage.GlusterFS.ClusterID,
|
||||
"RestAuthEnabled": mgr.Cluster.Storage.GlusterFS.RestAuthEnabled,
|
||||
"RestUrl": mgr.Cluster.Storage.GlusterFS.RestUrl,
|
||||
"RestUser": mgr.Cluster.Storage.GlusterFS.RestUser,
|
||||
"SecretName": mgr.Cluster.Storage.GlusterFS.SecretName,
|
||||
"GidMin": mgr.Cluster.Storage.GlusterFS.GidMin,
|
||||
"GidMax": mgr.Cluster.Storage.GlusterFS.GidMax,
|
||||
"VolumeType": mgr.Cluster.Storage.GlusterFS.VolumeType,
|
||||
"JwtAdminKey": base64.StdEncoding.EncodeToString([]byte(strings.TrimSpace(mgr.Cluster.Storage.GlusterFS.JwtAdminKey))),
|
||||
})
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
kubekeyapi "github.com/kubesphere/kubekey/pkg/apis/kubekey/v1alpha1"
|
||||
ceph_rbd "github.com/kubesphere/kubekey/pkg/plugins/storage/ceph-rbd"
|
||||
"github.com/kubesphere/kubekey/pkg/plugins/storage/glusterfs"
|
||||
local_volume "github.com/kubesphere/kubekey/pkg/plugins/storage/local-volume"
|
||||
nfs_client "github.com/kubesphere/kubekey/pkg/plugins/storage/nfs-client"
|
||||
"github.com/kubesphere/kubekey/pkg/util/manager"
|
||||
|
|
@ -36,6 +37,11 @@ func deployStoragePlugins(mgr *manager.Manager, node *kubekeyapi.HostCfg, conn s
|
|||
return err
|
||||
}
|
||||
}
|
||||
if mgr.Cluster.Storage.GlusterFS.Enabled {
|
||||
if err := DeployGlusterFS(mgr); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -99,3 +105,21 @@ func DeployRBDProvisioner(mgr *manager.Manager) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeployGlusterFS(mgr *manager.Manager) error {
|
||||
glusterfsFile, err := glusterfs.GenerateGlusterFSManifests(mgr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
glusterfsFileBase64 := base64.StdEncoding.EncodeToString([]byte(glusterfsFile))
|
||||
_, err1 := mgr.Runner.RunCmd(fmt.Sprintf("sudo -E /bin/sh -c \"echo %s | base64 -d > /etc/kubernetes/addons/glusterfs.yaml\"", glusterfsFileBase64))
|
||||
if err1 != nil {
|
||||
return errors.Wrap(errors.WithStack(err1), "Failed to generate glusterfs manifests")
|
||||
}
|
||||
|
||||
_, err2 := mgr.Runner.RunCmd("/usr/local/bin/kubectl apply -f /etc/kubernetes/addons/glusterfs.yaml -n kube-system")
|
||||
if err2 != nil {
|
||||
return errors.Wrap(errors.WithStack(err2), "Failed to deploy glusterfs.yaml")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue