From 39eddc703b2660554643d67f22231cc978538093 Mon Sep 17 00:00:00 2001 From: Praveen M Date: Wed, 22 Nov 2023 19:59:25 +0530 Subject: [PATCH] deploy: API for CSI Config Struct This commit exposes CSI ConfigMap over an API. This will allow projects like Rook to consume CSI configMap directly from Ceph-CSI. Signed-off-by: Praveen M --- .../kubernetes/cephfs/csi-config-map.go | 7 ++- .../kubernetes/cephfs/csi-config-map.yaml | 2 +- api/deploy/kubernetes/cephfs/csidriver.yaml | 1 + api/deploy/kubernetes/csi-config-map.go | 59 +++++++++++++++++++ api/deploy/kubernetes/nfs/csi-config-map.go | 7 ++- api/deploy/kubernetes/nfs/csi-config-map.yaml | 2 +- api/deploy/kubernetes/nfs/csidriver.yaml | 1 + api/deploy/kubernetes/rbd/csi-config-map.go | 7 ++- api/deploy/kubernetes/rbd/csi-config-map.yaml | 2 +- api/deploy/kubernetes/rbd/csidriver.yaml | 1 + .../kubernetes/cephfs/csi-config-map.go | 7 ++- .../kubernetes/cephfs/csi-config-map.yaml | 2 +- .../deploy/kubernetes/cephfs/csidriver.yaml | 1 + .../api/deploy/kubernetes/csi-config-map.go | 59 +++++++++++++++++++ .../ceph-csi/api/deploy/kubernetes/doc.go | 20 +++++++ .../deploy/kubernetes/nfs/csi-config-map.go | 7 ++- .../deploy/kubernetes/nfs/csi-config-map.yaml | 2 +- .../api/deploy/kubernetes/nfs/csidriver.yaml | 1 + .../deploy/kubernetes/rbd/csi-config-map.go | 7 ++- .../deploy/kubernetes/rbd/csi-config-map.yaml | 2 +- .../api/deploy/kubernetes/rbd/csidriver.yaml | 1 + vendor/modules.txt | 1 + 22 files changed, 181 insertions(+), 18 deletions(-) create mode 100644 api/deploy/kubernetes/csi-config-map.go create mode 100644 vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/csi-config-map.go create mode 100644 vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/doc.go diff --git a/api/deploy/kubernetes/cephfs/csi-config-map.go b/api/deploy/kubernetes/cephfs/csi-config-map.go index 966606872014..c60083312345 100644 --- a/api/deploy/kubernetes/cephfs/csi-config-map.go +++ b/api/deploy/kubernetes/cephfs/csi-config-map.go @@ -22,6 +22,7 @@ import ( "fmt" "text/template" + "github.com/ceph/ceph-csi/api/deploy/kubernetes" "github.com/ghodss/yaml" v1 "k8s.io/api/core/v1" ) @@ -30,11 +31,13 @@ import ( var csiConfigMap string type CSIConfigMapValues struct { - Name string + Name string + ClusterInfo []kubernetes.ClusterInfo } var CSIConfigMapDefaults = CSIConfigMapValues{ - Name: "ceph-csi-config", + Name: "ceph-csi-config", + ClusterInfo: []kubernetes.ClusterInfo{}, } // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces diff --git a/api/deploy/kubernetes/cephfs/csi-config-map.yaml b/api/deploy/kubernetes/cephfs/csi-config-map.yaml index c8a48eb4a458..eff25bd3b0e3 100644 --- a/api/deploy/kubernetes/cephfs/csi-config-map.yaml +++ b/api/deploy/kubernetes/cephfs/csi-config-map.yaml @@ -5,4 +5,4 @@ metadata: name: "{{ .Name }}" data: config.json: |- - [] + {{ .ClusterInfo }} diff --git a/api/deploy/kubernetes/cephfs/csidriver.yaml b/api/deploy/kubernetes/cephfs/csidriver.yaml index 20cfd051f8fe..3d92e3a57319 100644 --- a/api/deploy/kubernetes/cephfs/csidriver.yaml +++ b/api/deploy/kubernetes/cephfs/csidriver.yaml @@ -7,3 +7,4 @@ spec: attachRequired: false podInfoOnMount: false fsGroupPolicy: File + seLinuxMount: true diff --git a/api/deploy/kubernetes/csi-config-map.go b/api/deploy/kubernetes/csi-config-map.go new file mode 100644 index 000000000000..5114e666057a --- /dev/null +++ b/api/deploy/kubernetes/csi-config-map.go @@ -0,0 +1,59 @@ +/* +Copyright 2023 The Ceph-CSI 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 kubernetes + +type ClusterInfo struct { + // ClusterID is used for unique identification + ClusterID string + // Monitors is monitor list for corresponding cluster ID + Monitors []string + // CephFS contains CephFS specific options + CephFS CephFS + // RBD Contains RBD specific options + RBD RBD + // NFS contains NFS specific options + NFS NFS + // Read affinity map options + ReadAffinity ReadAffinity +} + +type CephFS struct { + // symlink filepath for the network namespace where we need to execute commands. + NetNamespaceFilePath string + // SubvolumeGroup contains the name of the SubvolumeGroup for CSI volumes + SubvolumeGroup string + // KernelMountOptions contains the kernel mount options for CephFS volumes + KernelMountOptions string + // FuseMountOptions contains the fuse mount options for CephFS volumes + FuseMountOptions string +} +type RBD struct { + // symlink filepath for the network namespace where we need to execute commands. + NetNamespaceFilePath string + // RadosNamespace is a rados namespace in the pool + RadosNamespace string +} + +type NFS struct { + // symlink filepath for the network namespace where we need to execute commands. + NetNamespaceFilePath string +} + +type ReadAffinity struct { + Enabled bool + CrushLocationLabels []string +} diff --git a/api/deploy/kubernetes/nfs/csi-config-map.go b/api/deploy/kubernetes/nfs/csi-config-map.go index 5a057518e906..3c32c9879dff 100644 --- a/api/deploy/kubernetes/nfs/csi-config-map.go +++ b/api/deploy/kubernetes/nfs/csi-config-map.go @@ -22,6 +22,7 @@ import ( "fmt" "text/template" + "github.com/ceph/ceph-csi/api/deploy/kubernetes" "github.com/ghodss/yaml" v1 "k8s.io/api/core/v1" ) @@ -30,11 +31,13 @@ import ( var csiConfigMap string type CSIConfigMapValues struct { - Name string + Name string + ClusterInfo []kubernetes.ClusterInfo } var CSIConfigMapDefaults = CSIConfigMapValues{ - Name: "ceph-csi-config", + Name: "ceph-csi-config", + ClusterInfo: []kubernetes.ClusterInfo{}, } // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces diff --git a/api/deploy/kubernetes/nfs/csi-config-map.yaml b/api/deploy/kubernetes/nfs/csi-config-map.yaml index c8a48eb4a458..eff25bd3b0e3 100644 --- a/api/deploy/kubernetes/nfs/csi-config-map.yaml +++ b/api/deploy/kubernetes/nfs/csi-config-map.yaml @@ -5,4 +5,4 @@ metadata: name: "{{ .Name }}" data: config.json: |- - [] + {{ .ClusterInfo }} diff --git a/api/deploy/kubernetes/nfs/csidriver.yaml b/api/deploy/kubernetes/nfs/csidriver.yaml index 21f2d79f4ea1..2bc314a59199 100644 --- a/api/deploy/kubernetes/nfs/csidriver.yaml +++ b/api/deploy/kubernetes/nfs/csidriver.yaml @@ -6,5 +6,6 @@ metadata: spec: attachRequired: false fsGroupPolicy: File + seLinuxMount: true volumeLifecycleModes: - Persistent diff --git a/api/deploy/kubernetes/rbd/csi-config-map.go b/api/deploy/kubernetes/rbd/csi-config-map.go index 13012ee4ee9c..bcc4bfd229cc 100644 --- a/api/deploy/kubernetes/rbd/csi-config-map.go +++ b/api/deploy/kubernetes/rbd/csi-config-map.go @@ -22,6 +22,7 @@ import ( "fmt" "text/template" + "github.com/ceph/ceph-csi/api/deploy/kubernetes" "github.com/ghodss/yaml" v1 "k8s.io/api/core/v1" ) @@ -30,11 +31,13 @@ import ( var csiConfigMap string type CSIConfigMapValues struct { - Name string + Name string + ClusterInfo []kubernetes.ClusterInfo } var CSIConfigMapDefaults = CSIConfigMapValues{ - Name: "ceph-csi-config", + Name: "ceph-csi-config", + ClusterInfo: []kubernetes.ClusterInfo{}, } // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces diff --git a/api/deploy/kubernetes/rbd/csi-config-map.yaml b/api/deploy/kubernetes/rbd/csi-config-map.yaml index c8a48eb4a458..eff25bd3b0e3 100644 --- a/api/deploy/kubernetes/rbd/csi-config-map.yaml +++ b/api/deploy/kubernetes/rbd/csi-config-map.yaml @@ -5,4 +5,4 @@ metadata: name: "{{ .Name }}" data: config.json: |- - [] + {{ .ClusterInfo }} diff --git a/api/deploy/kubernetes/rbd/csidriver.yaml b/api/deploy/kubernetes/rbd/csidriver.yaml index 63569181aacb..4140b6656ae6 100644 --- a/api/deploy/kubernetes/rbd/csidriver.yaml +++ b/api/deploy/kubernetes/rbd/csidriver.yaml @@ -6,4 +6,5 @@ metadata: spec: attachRequired: true podInfoOnMount: false + seLinuxMount: true fsGroupPolicy: File diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.go b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.go index 966606872014..c60083312345 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.go +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.go @@ -22,6 +22,7 @@ import ( "fmt" "text/template" + "github.com/ceph/ceph-csi/api/deploy/kubernetes" "github.com/ghodss/yaml" v1 "k8s.io/api/core/v1" ) @@ -30,11 +31,13 @@ import ( var csiConfigMap string type CSIConfigMapValues struct { - Name string + Name string + ClusterInfo []kubernetes.ClusterInfo } var CSIConfigMapDefaults = CSIConfigMapValues{ - Name: "ceph-csi-config", + Name: "ceph-csi-config", + ClusterInfo: []kubernetes.ClusterInfo{}, } // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.yaml b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.yaml index c8a48eb4a458..eff25bd3b0e3 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.yaml +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csi-config-map.yaml @@ -5,4 +5,4 @@ metadata: name: "{{ .Name }}" data: config.json: |- - [] + {{ .ClusterInfo }} diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csidriver.yaml b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csidriver.yaml index 20cfd051f8fe..3d92e3a57319 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csidriver.yaml +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs/csidriver.yaml @@ -7,3 +7,4 @@ spec: attachRequired: false podInfoOnMount: false fsGroupPolicy: File + seLinuxMount: true diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/csi-config-map.go b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/csi-config-map.go new file mode 100644 index 000000000000..5114e666057a --- /dev/null +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/csi-config-map.go @@ -0,0 +1,59 @@ +/* +Copyright 2023 The Ceph-CSI 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 kubernetes + +type ClusterInfo struct { + // ClusterID is used for unique identification + ClusterID string + // Monitors is monitor list for corresponding cluster ID + Monitors []string + // CephFS contains CephFS specific options + CephFS CephFS + // RBD Contains RBD specific options + RBD RBD + // NFS contains NFS specific options + NFS NFS + // Read affinity map options + ReadAffinity ReadAffinity +} + +type CephFS struct { + // symlink filepath for the network namespace where we need to execute commands. + NetNamespaceFilePath string + // SubvolumeGroup contains the name of the SubvolumeGroup for CSI volumes + SubvolumeGroup string + // KernelMountOptions contains the kernel mount options for CephFS volumes + KernelMountOptions string + // FuseMountOptions contains the fuse mount options for CephFS volumes + FuseMountOptions string +} +type RBD struct { + // symlink filepath for the network namespace where we need to execute commands. + NetNamespaceFilePath string + // RadosNamespace is a rados namespace in the pool + RadosNamespace string +} + +type NFS struct { + // symlink filepath for the network namespace where we need to execute commands. + NetNamespaceFilePath string +} + +type ReadAffinity struct { + Enabled bool + CrushLocationLabels []string +} diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/doc.go b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/doc.go new file mode 100644 index 000000000000..e4bd824b1b48 --- /dev/null +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2021 The Ceph-CSI 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 kubernetes contains functions to obtain standard and recommended +// deployment artifacts for Kubernetes. These artifacts can be used by +// automation tools that want to deploy Ceph-CSI. +package kubernetes diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.go b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.go index 5a057518e906..3c32c9879dff 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.go +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.go @@ -22,6 +22,7 @@ import ( "fmt" "text/template" + "github.com/ceph/ceph-csi/api/deploy/kubernetes" "github.com/ghodss/yaml" v1 "k8s.io/api/core/v1" ) @@ -30,11 +31,13 @@ import ( var csiConfigMap string type CSIConfigMapValues struct { - Name string + Name string + ClusterInfo []kubernetes.ClusterInfo } var CSIConfigMapDefaults = CSIConfigMapValues{ - Name: "ceph-csi-config", + Name: "ceph-csi-config", + ClusterInfo: []kubernetes.ClusterInfo{}, } // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.yaml b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.yaml index c8a48eb4a458..eff25bd3b0e3 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.yaml +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csi-config-map.yaml @@ -5,4 +5,4 @@ metadata: name: "{{ .Name }}" data: config.json: |- - [] + {{ .ClusterInfo }} diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csidriver.yaml b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csidriver.yaml index 21f2d79f4ea1..2bc314a59199 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csidriver.yaml +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs/csidriver.yaml @@ -6,5 +6,6 @@ metadata: spec: attachRequired: false fsGroupPolicy: File + seLinuxMount: true volumeLifecycleModes: - Persistent diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.go b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.go index 13012ee4ee9c..bcc4bfd229cc 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.go +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.go @@ -22,6 +22,7 @@ import ( "fmt" "text/template" + "github.com/ceph/ceph-csi/api/deploy/kubernetes" "github.com/ghodss/yaml" v1 "k8s.io/api/core/v1" ) @@ -30,11 +31,13 @@ import ( var csiConfigMap string type CSIConfigMapValues struct { - Name string + Name string + ClusterInfo []kubernetes.ClusterInfo } var CSIConfigMapDefaults = CSIConfigMapValues{ - Name: "ceph-csi-config", + Name: "ceph-csi-config", + ClusterInfo: []kubernetes.ClusterInfo{}, } // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.yaml b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.yaml index c8a48eb4a458..eff25bd3b0e3 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.yaml +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csi-config-map.yaml @@ -5,4 +5,4 @@ metadata: name: "{{ .Name }}" data: config.json: |- - [] + {{ .ClusterInfo }} diff --git a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csidriver.yaml b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csidriver.yaml index 63569181aacb..4140b6656ae6 100644 --- a/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csidriver.yaml +++ b/vendor/github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd/csidriver.yaml @@ -6,4 +6,5 @@ metadata: spec: attachRequired: true podInfoOnMount: false + seLinuxMount: true fsGroupPolicy: File diff --git a/vendor/modules.txt b/vendor/modules.txt index 6cc7d9a3c37d..62a1c941e3ac 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -134,6 +134,7 @@ github.com/cenkalti/backoff/v3 github.com/cenkalti/backoff/v4 # github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000 => ./api ## explicit; go 1.18 +github.com/ceph/ceph-csi/api/deploy/kubernetes github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd