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 <m.praveen@ibm.com>
This commit is contained in:
Praveen M 2023-11-22 19:59:25 +05:30 committed by mergify[bot]
parent 7e262515a8
commit 878eef803e
22 changed files with 181 additions and 18 deletions

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"text/template" "text/template"
"github.com/ceph/ceph-csi/api/deploy/kubernetes"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
) )
@ -30,11 +31,13 @@ import (
var csiConfigMap string var csiConfigMap string
type CSIConfigMapValues struct { type CSIConfigMapValues struct {
Name string Name string
ClusterInfo []kubernetes.ClusterInfo
} }
var CSIConfigMapDefaults = CSIConfigMapValues{ var CSIConfigMapDefaults = CSIConfigMapValues{
Name: "ceph-csi-config", Name: "ceph-csi-config",
ClusterInfo: []kubernetes.ClusterInfo{},
} }
// NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces

View File

@ -5,4 +5,4 @@ metadata:
name: "{{ .Name }}" name: "{{ .Name }}"
data: data:
config.json: |- config.json: |-
[] {{ .ClusterInfo }}

View File

@ -7,3 +7,4 @@ spec:
attachRequired: false attachRequired: false
podInfoOnMount: false podInfoOnMount: false
fsGroupPolicy: File fsGroupPolicy: File
seLinuxMount: true

View File

@ -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
}

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"text/template" "text/template"
"github.com/ceph/ceph-csi/api/deploy/kubernetes"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
) )
@ -30,11 +31,13 @@ import (
var csiConfigMap string var csiConfigMap string
type CSIConfigMapValues struct { type CSIConfigMapValues struct {
Name string Name string
ClusterInfo []kubernetes.ClusterInfo
} }
var CSIConfigMapDefaults = CSIConfigMapValues{ var CSIConfigMapDefaults = CSIConfigMapValues{
Name: "ceph-csi-config", Name: "ceph-csi-config",
ClusterInfo: []kubernetes.ClusterInfo{},
} }
// NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces

View File

@ -5,4 +5,4 @@ metadata:
name: "{{ .Name }}" name: "{{ .Name }}"
data: data:
config.json: |- config.json: |-
[] {{ .ClusterInfo }}

View File

@ -6,5 +6,6 @@ metadata:
spec: spec:
attachRequired: false attachRequired: false
fsGroupPolicy: File fsGroupPolicy: File
seLinuxMount: true
volumeLifecycleModes: volumeLifecycleModes:
- Persistent - Persistent

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"text/template" "text/template"
"github.com/ceph/ceph-csi/api/deploy/kubernetes"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
) )
@ -30,11 +31,13 @@ import (
var csiConfigMap string var csiConfigMap string
type CSIConfigMapValues struct { type CSIConfigMapValues struct {
Name string Name string
ClusterInfo []kubernetes.ClusterInfo
} }
var CSIConfigMapDefaults = CSIConfigMapValues{ var CSIConfigMapDefaults = CSIConfigMapValues{
Name: "ceph-csi-config", Name: "ceph-csi-config",
ClusterInfo: []kubernetes.ClusterInfo{},
} }
// NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces

View File

@ -5,4 +5,4 @@ metadata:
name: "{{ .Name }}" name: "{{ .Name }}"
data: data:
config.json: |- config.json: |-
[] {{ .ClusterInfo }}

View File

@ -6,4 +6,5 @@ metadata:
spec: spec:
attachRequired: true attachRequired: true
podInfoOnMount: false podInfoOnMount: false
seLinuxMount: true
fsGroupPolicy: File fsGroupPolicy: File

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"text/template" "text/template"
"github.com/ceph/ceph-csi/api/deploy/kubernetes"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
) )
@ -30,11 +31,13 @@ import (
var csiConfigMap string var csiConfigMap string
type CSIConfigMapValues struct { type CSIConfigMapValues struct {
Name string Name string
ClusterInfo []kubernetes.ClusterInfo
} }
var CSIConfigMapDefaults = CSIConfigMapValues{ var CSIConfigMapDefaults = CSIConfigMapValues{
Name: "ceph-csi-config", Name: "ceph-csi-config",
ClusterInfo: []kubernetes.ClusterInfo{},
} }
// NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces

View File

@ -5,4 +5,4 @@ metadata:
name: "{{ .Name }}" name: "{{ .Name }}"
data: data:
config.json: |- config.json: |-
[] {{ .ClusterInfo }}

View File

@ -7,3 +7,4 @@ spec:
attachRequired: false attachRequired: false
podInfoOnMount: false podInfoOnMount: false
fsGroupPolicy: File fsGroupPolicy: File
seLinuxMount: true

View File

@ -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
}

View File

@ -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

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"text/template" "text/template"
"github.com/ceph/ceph-csi/api/deploy/kubernetes"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
) )
@ -30,11 +31,13 @@ import (
var csiConfigMap string var csiConfigMap string
type CSIConfigMapValues struct { type CSIConfigMapValues struct {
Name string Name string
ClusterInfo []kubernetes.ClusterInfo
} }
var CSIConfigMapDefaults = CSIConfigMapValues{ var CSIConfigMapDefaults = CSIConfigMapValues{
Name: "ceph-csi-config", Name: "ceph-csi-config",
ClusterInfo: []kubernetes.ClusterInfo{},
} }
// NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces

View File

@ -5,4 +5,4 @@ metadata:
name: "{{ .Name }}" name: "{{ .Name }}"
data: data:
config.json: |- config.json: |-
[] {{ .ClusterInfo }}

View File

@ -6,5 +6,6 @@ metadata:
spec: spec:
attachRequired: false attachRequired: false
fsGroupPolicy: File fsGroupPolicy: File
seLinuxMount: true
volumeLifecycleModes: volumeLifecycleModes:
- Persistent - Persistent

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"text/template" "text/template"
"github.com/ceph/ceph-csi/api/deploy/kubernetes"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
) )
@ -30,11 +31,13 @@ import (
var csiConfigMap string var csiConfigMap string
type CSIConfigMapValues struct { type CSIConfigMapValues struct {
Name string Name string
ClusterInfo []kubernetes.ClusterInfo
} }
var CSIConfigMapDefaults = CSIConfigMapValues{ var CSIConfigMapDefaults = CSIConfigMapValues{
Name: "ceph-csi-config", Name: "ceph-csi-config",
ClusterInfo: []kubernetes.ClusterInfo{},
} }
// NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces // NewCSIConfigMap takes a name from the CSIConfigMapValues struct and relaces

View File

@ -5,4 +5,4 @@ metadata:
name: "{{ .Name }}" name: "{{ .Name }}"
data: data:
config.json: |- config.json: |-
[] {{ .ClusterInfo }}

View File

@ -6,4 +6,5 @@ metadata:
spec: spec:
attachRequired: true attachRequired: true
podInfoOnMount: false podInfoOnMount: false
seLinuxMount: true
fsGroupPolicy: File fsGroupPolicy: File

1
vendor/modules.txt vendored
View File

@ -134,6 +134,7 @@ github.com/cenkalti/backoff/v3
github.com/cenkalti/backoff/v4 github.com/cenkalti/backoff/v4
# github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000 => ./api # github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000 => ./api
## explicit; go 1.18 ## 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/cephfs
github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs
github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd