Files
my-rook-config/pkg/operator/ceph/csi/csi.go
T
rohan47 8c4ede1edc ceph: added support for multus for csi
CSI pods now utilize multus networking and connect to public
network specified in the CephCluster CR.

Closes: https://github.com/rook/rook/issues/5356
Signed-off-by: rohan47 <rohgupta@redhat.com>
2020-08-20 18:25:09 +05:30

109 lines
4.8 KiB
Go

/*
Copyright 2020 The Rook Authors. All rights reserved.
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 csi
import (
"strconv"
"github.com/pkg/errors"
rookclient "github.com/rook/rook/pkg/client/clientset/versioned"
controllerutil "github.com/rook/rook/pkg/operator/ceph/controller"
"github.com/rook/rook/pkg/operator/k8sutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/kubernetes"
)
func ValidateAndConfigureDrivers(clientset kubernetes.Interface, rookclientset rookclient.Interface, namespace, rookImage, securityAccount string, serverVersion *version.Info, ownerRef *metav1.OwnerReference) {
if !AllowUnsupported {
if err := validateCSIVersion(clientset, namespace, rookImage, securityAccount, ownerRef); err != nil {
logger.Errorf("invalid csi version. %+v", err)
return
}
} else {
logger.Info("Skipping csi version check, since unsupported versions are allowed")
}
if err := startDrivers(clientset, rookclientset, namespace, serverVersion, ownerRef); err != nil {
logger.Errorf("failed to start Ceph csi drivers. %v", err)
return
}
stopDrivers(clientset, namespace, serverVersion)
}
func SetParams(clientset kubernetes.Interface) error {
var err error
csiEnableRBD, err := k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_ENABLE_RBD", "true")
if err != nil {
return errors.Wrap(err, "unable to determine if CSI driver for RBD is enabled")
}
if EnableRBD, err = strconv.ParseBool(csiEnableRBD); err != nil {
return errors.Wrap(err, "unable to parse value for 'ROOK_CSI_ENABLE_RBD'")
}
csiEnableCephFS, err := k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_ENABLE_CEPHFS", "true")
if err != nil {
return errors.Wrap(err, "unable to determine if CSI driver for CephFS is enabled")
}
if EnableCephFS, err = strconv.ParseBool(csiEnableCephFS); err != nil {
return errors.Wrap(err, "unable to parse value for 'ROOK_CSI_ENABLE_CEPHFS'")
}
csiAllowUnsupported, err := k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_ALLOW_UNSUPPORTED_VERSION", "false")
if err != nil {
return errors.Wrap(err, "unable to determine if unsupported version is allowed")
}
if AllowUnsupported, err = strconv.ParseBool(csiAllowUnsupported); err != nil {
return errors.Wrap(err, "unable to parse value for 'ROOK_CSI_ALLOW_UNSUPPORTED_VERSION'")
}
csiEnableCSIGRPCMetrics, err := k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_ENABLE_GRPC_METRICS", "true")
if err != nil {
return errors.Wrap(err, "unable to determine if CSI GRPC metrics is enabled")
}
if EnableCSIGRPCMetrics, err = strconv.ParseBool(csiEnableCSIGRPCMetrics); err != nil {
return errors.Wrap(err, "unable to parse value for 'ROOK_CSI_ENABLE_GRPC_METRICS'")
}
CSIParam.CSIPluginImage, err = k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_CEPH_IMAGE", DefaultCSIPluginImage)
if err != nil {
return errors.Wrap(err, "unable to configure CSI plugin image")
}
CSIParam.RegistrarImage, err = k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_REGISTRAR_IMAGE", DefaultRegistrarImage)
if err != nil {
return errors.Wrap(err, "unable to configure CSI registrar image")
}
CSIParam.ProvisionerImage, err = k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_PROVISIONER_IMAGE", DefaultProvisionerImage)
if err != nil {
return errors.Wrap(err, "unable to configure CSI provisioner image")
}
CSIParam.AttacherImage, err = k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_ATTACHER_IMAGE", DefaultAttacherImage)
if err != nil {
return errors.Wrap(err, "unable to configure CSI attacher image")
}
CSIParam.SnapshotterImage, err = k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_SNAPSHOTTER_IMAGE", DefaultSnapshotterImage)
if err != nil {
return errors.Wrap(err, "unable to configure CSI snapshotter image")
}
CSIParam.KubeletDirPath, err = k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_KUBELET_DIR_PATH", DefaultKubeletDirPath)
if err != nil {
return errors.Wrap(err, "unable to configure CSI kubelet directory path")
}
return nil
}