Skip to content

Commit 635f07e

Browse files
[release-1.28] Add support to only run selected CSI services (kubernetes#2670)
* Add support to only run selected CSI services of the cinder CSI driver * Add support to only run selected CSI services of the manila CSI driver * Clean up source files to successfully complete linting * Update description of the `nodeid` command line parameter * Update documentation for the CSI service parameters This commit updates the documentation for the CSI controller and node service providing parameters. --------- Co-authored-by: Tobias Wolf <[email protected]>
1 parent 9e8f2aa commit 635f07e

File tree

13 files changed

+167
-88
lines changed

13 files changed

+167
-88
lines changed

cmd/cinder-csi-plugin/main.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ import (
3131
)
3232

3333
var (
34-
endpoint string
35-
nodeID string
36-
cloudConfig []string
37-
cluster string
38-
httpEndpoint string
34+
endpoint string
35+
nodeID string
36+
cloudConfig []string
37+
cluster string
38+
httpEndpoint string
39+
provideControllerService bool
40+
provideNodeService bool
3941
)
4042

4143
func main() {
@@ -65,6 +67,10 @@ func main() {
6567

6668
cmd.PersistentFlags().StringVar(&cluster, "cluster", "", "The identifier of the cluster that the plugin is running in.")
6769
cmd.PersistentFlags().StringVar(&httpEndpoint, "http-endpoint", "", "The TCP network address where the HTTP server for providing metrics for diagnostics, will listen (example: `:8080`). The default is empty string, which means the server is disabled.")
70+
71+
cmd.PersistentFlags().BoolVar(&provideControllerService, "provide-controller-service", true, "If set to true then the CSI driver does provide the controller service (default: true)")
72+
cmd.PersistentFlags().BoolVar(&provideNodeService, "provide-node-service", true, "If set to true then the CSI driver does provide the node service (default: true)")
73+
6874
openstack.AddExtraFlags(pflag.CommandLine)
6975

7076
code := cli.Run(cmd)
@@ -73,19 +79,28 @@ func main() {
7379

7480
func handle() {
7581
// Initialize cloud
76-
d := cinder.NewDriver(endpoint, cluster)
82+
d := cinder.NewDriver(&cinder.DriverOpts{Endpoint: endpoint, ClusterID: cluster})
83+
7784
openstack.InitOpenStackProvider(cloudConfig, httpEndpoint)
7885
cloud, err := openstack.GetOpenStackProvider()
7986
if err != nil {
8087
klog.Warningf("Failed to GetOpenStackProvider: %v", err)
8188
return
8289
}
83-
//Initialize mount
84-
mount := mount.GetMountProvider()
8590

86-
//Initialize Metadata
87-
metadata := metadata.GetMetadataProvider(cloud.GetMetadataOpts().SearchOrder)
91+
if provideControllerService {
92+
d.SetupControllerService(cloud)
93+
}
94+
95+
if provideNodeService {
96+
//Initialize mount
97+
mount := mount.GetMountProvider()
98+
99+
//Initialize Metadata
100+
metadata := metadata.GetMetadataProvider(cloud.GetMetadataOpts().SearchOrder)
101+
102+
d.SetupNodeService(cloud, mount, metadata)
103+
}
88104

89-
d.SetupDriver(cloud, mount, metadata)
90105
d.Run()
91106
}

cmd/manila-csi-plugin/main.go

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ var (
4545
clusterID string
4646

4747
// Runtime options
48-
endpoint string
49-
runtimeConfigFile string
50-
userAgentData []string
48+
endpoint string
49+
runtimeConfigFile string
50+
userAgentData []string
51+
provideControllerService bool
52+
provideNodeService bool
5153
)
5254

5355
func validateShareProtocolSelector(v string) error {
@@ -75,23 +77,39 @@ func main() {
7577
manilaClientBuilder := &manilaclient.ClientBuilder{UserAgent: "manila-csi-plugin", ExtraUserAgentData: userAgentData}
7678
csiClientBuilder := &csiclient.ClientBuilder{}
7779

78-
d, err := manila.NewDriver(
79-
&manila.DriverOpts{
80-
DriverName: driverName,
81-
NodeID: nodeID,
82-
NodeAZ: nodeAZ,
83-
WithTopology: withTopology,
84-
ShareProto: protoSelector,
85-
ServerCSIEndpoint: endpoint,
86-
FwdCSIEndpoint: fwdEndpoint,
87-
ManilaClientBuilder: manilaClientBuilder,
88-
CSIClientBuilder: csiClientBuilder,
89-
ClusterID: clusterID,
90-
},
91-
)
80+
opts := &manila.DriverOpts{
81+
DriverName: driverName,
82+
WithTopology: withTopology,
83+
ShareProto: protoSelector,
84+
ServerCSIEndpoint: endpoint,
85+
FwdCSIEndpoint: fwdEndpoint,
86+
ManilaClientBuilder: manilaClientBuilder,
87+
CSIClientBuilder: csiClientBuilder,
88+
ClusterID: clusterID,
89+
}
90+
91+
if provideNodeService {
92+
opts.NodeID = nodeID
93+
opts.NodeAZ = nodeAZ
94+
}
9295

96+
d, err := manila.NewDriver(opts)
9397
if err != nil {
94-
klog.Fatalf("driver initialization failed: %v", err)
98+
klog.Fatalf("Driver initialization failed: %v", err)
99+
}
100+
101+
if provideControllerService {
102+
err = d.SetupControllerService()
103+
if err != nil {
104+
klog.Fatalf("Driver controller service initialization failed: %v", err)
105+
}
106+
}
107+
108+
if provideNodeService {
109+
err = d.SetupNodeService()
110+
if err != nil {
111+
klog.Fatalf("Driver node service initialization failed: %v", err)
112+
}
95113
}
96114

97115
runtimeconfig.RuntimeConfigFilename = runtimeConfigFile
@@ -105,10 +123,7 @@ func main() {
105123

106124
cmd.PersistentFlags().StringVar(&driverName, "drivername", "manila.csi.openstack.org", "name of the driver")
107125

108-
cmd.PersistentFlags().StringVar(&nodeID, "nodeid", "", "this node's ID")
109-
if err := cmd.MarkPersistentFlagRequired("nodeid"); err != nil {
110-
klog.Fatalf("Unable to mark flag nodeid to be required: %v", err)
111-
}
126+
cmd.PersistentFlags().StringVar(&nodeID, "nodeid", "", "this node's ID. This value is required if the node service is provided by this CSI driver instance.")
112127

113128
cmd.PersistentFlags().StringVar(&nodeAZ, "nodeaz", "", "this node's availability zone")
114129

@@ -132,6 +147,9 @@ func main() {
132147

133148
cmd.PersistentFlags().StringVar(&clusterID, "cluster-id", "", "The identifier of the cluster that the plugin is running in.")
134149

150+
cmd.PersistentFlags().BoolVar(&provideControllerService, "provide-controller-service", true, "If set to true then the CSI driver does provide the controller service (default: true)")
151+
cmd.PersistentFlags().BoolVar(&provideNodeService, "provide-node-service", true, "If set to true then the CSI driver does provide the node service (default: true)")
152+
135153
code := cli.Run(cmd)
136154
os.Exit(code)
137155
}

docs/cinder-csi-plugin/using-cinder-csi-plugin.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ In addition to the standard set of klog flags, `cinder-csi-plugin` accepts the f
9898
The default is empty string, which means the server is disabled.
9999
</dd>
100100

101+
<dt>--provide-controller-service &lt;enabled&gt;</dt>
102+
<dd>
103+
If set to true then the CSI driver does provide the controller service.
104+
105+
The default is to provide the controller service.
106+
</dd>
107+
108+
<dt>--provide-node-service &lt;enabled&gt;</dt>
109+
<dd>
110+
If set to true then the CSI driver does provide the node service.
111+
112+
The default is to provide the node service.
113+
</dd>
101114
</dl>
102115

103116
## Driver Config
@@ -114,7 +127,7 @@ Implementation of `cinder-csi-plugin` relies on following OpenStack services.
114127
For Driver configuration, parameters must be passed via configuration file specified in `$CLOUD_CONFIG` environment variable.
115128
The following sections are supported in configuration file.
116129

117-
### Global
130+
### Global
118131
For Cinder CSI Plugin to authenticate with OpenStack Keystone, required parameters needs to be passed in `[Global]` section of the file. For all supported parameters, please refer [Global](../openstack-cloud-controller-manager/using-openstack-cloud-controller-manager.md#global) section.
119132

120133
### Block Storage
@@ -196,7 +209,7 @@ cinder.csi.openstack.org true true false <
196209
mountPath: /etc/cacert
197210
readOnly: true
198211
199-
volumes:
212+
volumes:
200213
....
201214
- name: cacert
202215
hostPath:
@@ -254,7 +267,7 @@ helm install --namespace kube-system --name cinder-csi ./charts/cinder-csi-plugi
254267
| StorageClass `parameters` | `availability` | `nova` | String. Volume Availability Zone |
255268
| StorageClass `parameters` | `type` | Empty String | String. Name/ID of Volume type. Corresponding volume type should exist in cinder |
256269
| VolumeSnapshotClass `parameters` | `force-create` | `false` | Enable to support creating snapshot for a volume in in-use status |
257-
| Inline Volume `volumeAttributes` | `capacity` | `1Gi` | volume size for creating inline volumes|
270+
| Inline Volume `volumeAttributes` | `capacity` | `1Gi` | volume size for creating inline volumes|
258271
| Inline Volume `VolumeAttributes` | `type` | Empty String | Name/ID of Volume type. Corresponding volume type should exist in cinder |
259272

260273
## Local Development
@@ -266,14 +279,14 @@ To build the plugin, run
266279
```
267280
$ export ARCH=amd64 # Defaults to amd64
268281
$ make build-cmd-cinder-csi-plugin
269-
```
282+
```
270283

271284
To build cinder-csi-plugin image
272285

273286
```
274287
$ export ARCH=amd64 # Defaults to amd64
275288
$ make build-local-image-cinder-csi-plugin
276-
```
289+
```
277290

278291
### Testing
279292

@@ -284,7 +297,7 @@ To run all unit tests:
284297
$ make test
285298
```
286299
#### Sanity Tests
287-
Sanity tests ensures the CSI spec conformance of the driver. For more info, refer [Sanity check](https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity)
300+
Sanity tests ensures the CSI spec conformance of the driver. For more info, refer [Sanity check](https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity)
288301

289302
Run sanity tests for cinder CSI driver using:
290303

@@ -298,5 +311,5 @@ Optionally, to test the driver csc tool could be used. please refer, [usage guid
298311

299312
Starting from Kubernetes 1.21, OpenStack Cinder CSI migration is supported as beta feature and is `ON` by default. Cinder CSI driver must be installed on clusters on OpenStack for Cinder volumes to work. If you have persistence volumes that are created with in-tree `kubernetes.io/cinder` plugin, you could migrate to use `cinder.csi.openstack.org` Container Storage Interface (CSI) Driver.
300313

301-
* The CSI Migration feature for Cinder, when enabled, shims all plugin operations from the existing in-tree plugin to the `cinder.csi.openstack.org` CSI Driver.
314+
* The CSI Migration feature for Cinder, when enabled, shims all plugin operations from the existing in-tree plugin to the `cinder.csi.openstack.org` CSI Driver.
302315
* For more info, please refer [Migrate to CCM with CSI Migration](../openstack-cloud-controller-manager/migrate-to-ccm-with-csimigration.md#migrate-from-in-tree-cloud-provider-to-openstack-cloud-controller-manager-and-enable-csimigration) guide

docs/manila-csi-plugin/using-manila-csi-plugin.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Option | Default value | Description
4040
`--share-protocol-selector` | _none_ | Specifies which Manila share protocol to use for this instance of the driver. See [supported protocols](#share-protocol-support-matrix) for valid values.
4141
`--fwdendpoint` | _none_ | [CSI Node Plugin](https://github.com/container-storage-interface/spec/blob/master/spec.md#rpc-interface) endpoint to which all Node Service RPCs are forwarded. Must be able to handle the file-system specified in `share-protocol-selector`. Check out the [Deployment](#deployment) section to see why this is necessary.
4242
`--cluster-id` | _none_ | The identifier of the cluster that the plugin is running in. If set then the plugin will add "manila.csi.openstack.org/cluster: \<clusterID\>" to metadata of created shares.
43+
`--provide-controller-service` | `true` | If set to true then the CSI driver does provide the controller service.
44+
`--provide-node-service` | `true` | If set to true then the CSI driver does provide the node service.
4345

4446
### Controller Service volume parameters
4547

@@ -56,7 +58,7 @@ Parameter | Required | Description
5658
`cephfs-kernelMountOptions` | _no_ | Relevant for CephFS Manila shares. Specifies mount options for CephFS kernel client. See [CSI CephFS docs](https://github.com/ceph/ceph-csi/blob/csi-v1.0/docs/deploy-cephfs.md#configuration) for further information.
5759
`cephfs-fuseMountOptions` | _no_ | Relevant for CephFS Manila shares. Specifies mount options for CephFS FUSE client. See [CSI CephFS docs](https://github.com/ceph/ceph-csi/blob/csi-v1.0/docs/deploy-cephfs.md#configuration) for further information.
5860
`cephfs-clientID` | _no_ | Relevant for CephFS Manila shares. Specifies the cephx client ID when creating an access rule for the provisioned share. The same cephx client ID may be shared with multiple Manila shares. If no value is provided, client ID for the provisioned Manila share will be set to some unique value (PersistentVolume name).
59-
`nfs-shareClient` | _no_ | Relevant for NFS Manila shares. Specifies what address has access to the NFS share. Defaults to `0.0.0.0/0`, i.e. anyone.
61+
`nfs-shareClient` | _no_ | Relevant for NFS Manila shares. Specifies what address has access to the NFS share. Defaults to `0.0.0.0/0`, i.e. anyone.
6062

6163
### Node Service volume context
6264

@@ -199,7 +201,7 @@ CSI Manila Helm chart is located in `charts/manila-csi-plugin`.
199201

200202
First, modify `values.yaml` to suite your environment, and then simply install the Helm chart with `$ helm install ./charts/manila-csi-plugin`.
201203

202-
Note that the release name generated by `helm install` may not be suitable due to their length. The chart generates object names with the release name included in them, which may cause the names to exceed 63 characters and result in chart installation failure. You may use `--name` flag to set the release name manually. See [helm installation docs](https://helm.sh/docs/helm/#helm-install) for more info. Alternatively, you may also use `nameOverride` or `fullnameOverride` variables in `values.yaml` to override the respective names.
204+
Note that the release name generated by `helm install` may not be suitable due to their length. The chart generates object names with the release name included in them, which may cause the names to exceed 63 characters and result in chart installation failure. You may use `--name` flag to set the release name manually. See [helm installation docs](https://helm.sh/docs/helm/#helm-install) for more info. Alternatively, you may also use `nameOverride` or `fullnameOverride` variables in `values.yaml` to override the respective names.
203205

204206
**Manual deployment**
205207

0 commit comments

Comments
 (0)