csi: add nfs provisioner deployment
This commit adds nfs provisioner deployment.
This will allow rook to deploy nfs provisioner
which can create backend cephfs subvolumes to be
exported as nfs volumes.
refer:
https://github.com/ceph/ceph-csi/blob/devel/docs/design/proposals/nfs.md
Signed-off-by: Rakshith R <rar@redhat.com>
(cherry picked from commit 5f48ad8026)
This commit is contained in:
1 parent
7eead51c6f
commit
d402f8b286
11 files changed
+357
-7
No files matched your search
@@ -138,6 +138,8 @@ var (
|
||||
// Local package template path for NFS
|
||||
//go:embed template/nfs/csi-nfsplugin.yaml
|
||||
NFSPluginTemplatePath string
|
||||
//go:embed template/nfs/csi-nfsplugin-provisioner-dep.yaml
|
||||
NFSProvisionerDepTemplatePath string
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -160,8 +162,10 @@ const (
|
||||
cephFSPluginNodeAffinityEnv = "CSI_CEPHFS_PLUGIN_NODE_AFFINITY"
|
||||
|
||||
// NFS tolerations and node affinity
|
||||
nfsPluginTolerationsEnv = "CSI_NFS_PLUGIN_TOLERATIONS"
|
||||
nfsPluginNodeAffinityEnv = "CSI_NFS_PLUGIN_NODE_AFFINITY"
|
||||
nfsProvisionerTolerationsEnv = "CSI_NFS_PROVISIONER_TOLERATIONS"
|
||||
nfsProvisionerNodeAffinityEnv = "CSI_NFS_PROVISIONER_NODE_AFFINITY"
|
||||
nfsPluginTolerationsEnv = "CSI_NFS_PLUGIN_TOLERATIONS"
|
||||
nfsPluginNodeAffinityEnv = "CSI_NFS_PLUGIN_NODE_AFFINITY"
|
||||
|
||||
// RBD tolerations and node affinity
|
||||
rbdProvisionerTolerationsEnv = "CSI_RBD_PROVISIONER_TOLERATIONS"
|
||||
@@ -176,7 +180,8 @@ const (
|
||||
cephFSProvisionerResource = "CSI_CEPHFS_PROVISIONER_RESOURCE"
|
||||
cephFSPluginResource = "CSI_CEPHFS_PLUGIN_RESOURCE"
|
||||
|
||||
nfsPluginResource = "CSI_NFS_PLUGIN_RESOURCE"
|
||||
nfsProvisionerResource = "CSI_NFS_PROVISIONER_RESOURCE"
|
||||
nfsPluginResource = "CSI_NFS_PLUGIN_RESOURCE"
|
||||
|
||||
// kubelet directory path
|
||||
DefaultKubeletDirPath = "/var/lib/kubelet"
|
||||
@@ -233,10 +238,10 @@ func validateCSIParam() error {
|
||||
|
||||
func (r *ReconcileCSI) startDrivers(ver *version.Info, ownerInfo *k8sutil.OwnerInfo, v *CephCSIVersion) error {
|
||||
var (
|
||||
err error
|
||||
rbdPlugin, cephfsPlugin, nfsPlugin *apps.DaemonSet
|
||||
rbdProvisionerDeployment, cephfsProvisionerDeployment *apps.Deployment
|
||||
rbdService, cephfsService *corev1.Service
|
||||
err error
|
||||
rbdPlugin, cephfsPlugin, nfsPlugin *apps.DaemonSet
|
||||
rbdProvisionerDeployment, cephfsProvisionerDeployment, nfsProvisionerDeployment *apps.Deployment
|
||||
rbdService, cephfsService *corev1.Service
|
||||
)
|
||||
|
||||
tp := templateParam{
|
||||
@@ -442,6 +447,11 @@ func (r *ReconcileCSI) startDrivers(ver *version.Info, ownerInfo *k8sutil.OwnerI
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load nfs plugin template")
|
||||
}
|
||||
|
||||
nfsProvisionerDeployment, err = templateToDeployment("nfs-provisioner", NFSProvisionerDepTemplatePath, tp)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load nfs provisioner deployment template")
|
||||
}
|
||||
}
|
||||
|
||||
// get common provisioner tolerations and node affinity
|
||||
@@ -612,6 +622,37 @@ func (r *ReconcileCSI) startDrivers(ver *version.Info, ownerInfo *k8sutil.OwnerI
|
||||
k8sutil.AddRookVersionLabelToDaemonSet(nfsPlugin)
|
||||
}
|
||||
|
||||
if nfsProvisionerDeployment != nil {
|
||||
// get NFS provisioner tolerations and node affinity, defaults to common tolerations and node affinity if not specified
|
||||
nfsProvisionerTolerations := getToleration(r.opConfig.Parameters, nfsProvisionerTolerationsEnv, provisionerTolerations)
|
||||
nfsProvisionerNodeAffinity := getNodeAffinity(r.opConfig.Parameters, nfsProvisionerNodeAffinityEnv, provisionerNodeAffinity)
|
||||
// apply NFS provisioner tolerations and node affinity
|
||||
applyToPodSpec(&nfsProvisionerDeployment.Spec.Template.Spec, nfsProvisionerNodeAffinity, nfsProvisionerTolerations)
|
||||
// get resource details for nfs provisioner
|
||||
// apply resource request and limit to nfs provisioner containers
|
||||
applyResourcesToContainers(r.opConfig.Parameters, nfsProvisionerResource, &nfsProvisionerDeployment.Spec.Template.Spec)
|
||||
err = ownerInfo.SetControllerReference(nfsProvisionerDeployment)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to set owner reference to nfs provisioner deployment %q", nfsProvisionerDeployment.Name)
|
||||
}
|
||||
antiAffinity := GetPodAntiAffinity("app", csiNFSProvisioner)
|
||||
nfsProvisionerDeployment.Spec.Template.Spec.Affinity.PodAntiAffinity = &antiAffinity
|
||||
nfsProvisionerDeployment.Spec.Strategy = apps.DeploymentStrategy{
|
||||
Type: apps.RecreateDeploymentStrategyType,
|
||||
}
|
||||
|
||||
_, err = r.applyCephClusterNetworkConfig(r.opManagerContext, &nfsProvisionerDeployment.Spec.Template.ObjectMeta)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to apply network config to nfs provisioner deployment %q", nfsProvisionerDeployment.Name)
|
||||
}
|
||||
_, err = k8sutil.CreateOrUpdateDeployment(r.opManagerContext, r.context.Clientset, nfsProvisionerDeployment)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to start nfs provisioner deployment %q", nfsProvisionerDeployment.Name)
|
||||
}
|
||||
k8sutil.AddRookVersionLabelToDeployment(nfsProvisionerDeployment)
|
||||
logger.Info("successfully started CSI NFS driver")
|
||||
}
|
||||
|
||||
if EnableRBD {
|
||||
err = csiDriverobj.createCSIDriverInfo(r.opManagerContext, r.context.Clientset, RBDDriverName, k8sutil.GetValue(r.opConfig.Parameters, "CSI_RBD_FSGROUPPOLICY", string(k8scsi.ReadWriteOnceWithFSTypeFSGroupPolicy)), true)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: csi-nfsplugin-provisioner
|
||||
namespace: {{ .Namespace }}
|
||||
spec:
|
||||
replicas: {{ .ProvisionerReplicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: csi-nfsplugin-provisioner
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: csi-nfsplugin-provisioner
|
||||
{{ range $key, $value := .CSINFSPodLabels }}
|
||||
{{ $key }}: "{{ $value }}"
|
||||
{{ end }}
|
||||
spec:
|
||||
serviceAccountName: rook-csi-nfs-provisioner-sa
|
||||
{{ if .ProvisionerPriorityClassName }}
|
||||
priorityClassName: {{ .ProvisionerPriorityClassName }}
|
||||
{{ end }}
|
||||
containers:
|
||||
- name: csi-provisioner
|
||||
image: {{ .ProvisionerImage }}
|
||||
args:
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
- "--v={{ .LogLevel }}"
|
||||
- "--timeout=150s"
|
||||
- "--retry-interval-start=500ms"
|
||||
- "--leader-election=true"
|
||||
- "--leader-election-namespace={{ .Namespace }}"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: unix:///csi/csi-provisioner.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /csi
|
||||
- name: csi-nfsplugin
|
||||
image: {{ .CSIPluginImage }}
|
||||
args:
|
||||
- "--nodeid=$(NODE_ID)"
|
||||
- "--type=nfs"
|
||||
- "--endpoint=$(CSI_ENDPOINT)"
|
||||
- "--v={{ .LogLevel }}"
|
||||
- "--controllerserver=true"
|
||||
- "--drivername={{ .DriverNamePrefix }}nfs.csi.ceph.com"
|
||||
- "--pidlimit=-1"
|
||||
env:
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.podIP
|
||||
- name: NODE_ID
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CSI_ENDPOINT
|
||||
value: unix:///csi/csi-provisioner.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /csi
|
||||
- name: host-sys
|
||||
mountPath: /sys
|
||||
- name: lib-modules
|
||||
mountPath: /lib/modules
|
||||
readOnly: true
|
||||
- name: host-dev
|
||||
mountPath: /dev
|
||||
- name: ceph-csi-config
|
||||
mountPath: /etc/ceph-csi-config/
|
||||
- name: keys-tmp-dir
|
||||
mountPath: /tmp/csi/keys
|
||||
{{ if .MountCustomCephConf }}
|
||||
- name: ceph-config
|
||||
mountPath: /etc/ceph/ceph.conf
|
||||
subPath: ceph.conf
|
||||
{{ end }}
|
||||
volumes:
|
||||
- name: socket-dir
|
||||
emptyDir: {
|
||||
medium: "Memory"
|
||||
}
|
||||
- name: host-sys
|
||||
hostPath:
|
||||
path: /sys
|
||||
- name: lib-modules
|
||||
hostPath:
|
||||
path: /lib/modules
|
||||
- name: host-dev
|
||||
hostPath:
|
||||
path: /dev
|
||||
- name: ceph-csi-config
|
||||
configMap:
|
||||
name: rook-ceph-csi-config
|
||||
items:
|
||||
- key: csi-cluster-config-json
|
||||
path: config.json
|
||||
- name: keys-tmp-dir
|
||||
emptyDir: {
|
||||
medium: "Memory"
|
||||
}
|
||||
{{ if .MountCustomCephConf }}
|
||||
- name: ceph-config
|
||||
configMap:
|
||||
name: csi-ceph-conf-override
|
||||
items:
|
||||
- key: ceph.conf
|
||||
path: ceph.conf
|
||||
{{ end }}
|
||||
Reference in new issue
Block a user