Skip to content

Commit

Permalink
[release-1.28] Add support to only run selected CSI services (#2670)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
1 parent 9e8f2aa commit 635f07e
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 88 deletions.
37 changes: 26 additions & 11 deletions cmd/cinder-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ import (
)

var (
endpoint string
nodeID string
cloudConfig []string
cluster string
httpEndpoint string
endpoint string
nodeID string
cloudConfig []string
cluster string
httpEndpoint string
provideControllerService bool
provideNodeService bool
)

func main() {
Expand Down Expand Up @@ -65,6 +67,10 @@ func main() {

cmd.PersistentFlags().StringVar(&cluster, "cluster", "", "The identifier of the cluster that the plugin is running in.")
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.")

cmd.PersistentFlags().BoolVar(&provideControllerService, "provide-controller-service", true, "If set to true then the CSI driver does provide the controller service (default: true)")
cmd.PersistentFlags().BoolVar(&provideNodeService, "provide-node-service", true, "If set to true then the CSI driver does provide the node service (default: true)")

openstack.AddExtraFlags(pflag.CommandLine)

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

func handle() {
// Initialize cloud
d := cinder.NewDriver(endpoint, cluster)
d := cinder.NewDriver(&cinder.DriverOpts{Endpoint: endpoint, ClusterID: cluster})

openstack.InitOpenStackProvider(cloudConfig, httpEndpoint)
cloud, err := openstack.GetOpenStackProvider()
if err != nil {
klog.Warningf("Failed to GetOpenStackProvider: %v", err)
return
}
//Initialize mount
mount := mount.GetMountProvider()

//Initialize Metadata
metadata := metadata.GetMetadataProvider(cloud.GetMetadataOpts().SearchOrder)
if provideControllerService {
d.SetupControllerService(cloud)
}

if provideNodeService {
//Initialize mount
mount := mount.GetMountProvider()

//Initialize Metadata
metadata := metadata.GetMetadataProvider(cloud.GetMetadataOpts().SearchOrder)

d.SetupNodeService(cloud, mount, metadata)
}

d.SetupDriver(cloud, mount, metadata)
d.Run()
}
62 changes: 40 additions & 22 deletions cmd/manila-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ var (
clusterID string

// Runtime options
endpoint string
runtimeConfigFile string
userAgentData []string
endpoint string
runtimeConfigFile string
userAgentData []string
provideControllerService bool
provideNodeService bool
)

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

d, err := manila.NewDriver(
&manila.DriverOpts{
DriverName: driverName,
NodeID: nodeID,
NodeAZ: nodeAZ,
WithTopology: withTopology,
ShareProto: protoSelector,
ServerCSIEndpoint: endpoint,
FwdCSIEndpoint: fwdEndpoint,
ManilaClientBuilder: manilaClientBuilder,
CSIClientBuilder: csiClientBuilder,
ClusterID: clusterID,
},
)
opts := &manila.DriverOpts{
DriverName: driverName,
WithTopology: withTopology,
ShareProto: protoSelector,
ServerCSIEndpoint: endpoint,
FwdCSIEndpoint: fwdEndpoint,
ManilaClientBuilder: manilaClientBuilder,
CSIClientBuilder: csiClientBuilder,
ClusterID: clusterID,
}

if provideNodeService {
opts.NodeID = nodeID
opts.NodeAZ = nodeAZ
}

d, err := manila.NewDriver(opts)
if err != nil {
klog.Fatalf("driver initialization failed: %v", err)
klog.Fatalf("Driver initialization failed: %v", err)
}

if provideControllerService {
err = d.SetupControllerService()
if err != nil {
klog.Fatalf("Driver controller service initialization failed: %v", err)
}
}

if provideNodeService {
err = d.SetupNodeService()
if err != nil {
klog.Fatalf("Driver node service initialization failed: %v", err)
}
}

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

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

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

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

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

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

cmd.PersistentFlags().BoolVar(&provideControllerService, "provide-controller-service", true, "If set to true then the CSI driver does provide the controller service (default: true)")
cmd.PersistentFlags().BoolVar(&provideNodeService, "provide-node-service", true, "If set to true then the CSI driver does provide the node service (default: true)")

code := cli.Run(cmd)
os.Exit(code)
}
27 changes: 20 additions & 7 deletions docs/cinder-csi-plugin/using-cinder-csi-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ In addition to the standard set of klog flags, `cinder-csi-plugin` accepts the f
The default is empty string, which means the server is disabled.
</dd>

<dt>--provide-controller-service &lt;enabled&gt;</dt>
<dd>
If set to true then the CSI driver does provide the controller service.

The default is to provide the controller service.
</dd>

<dt>--provide-node-service &lt;enabled&gt;</dt>
<dd>
If set to true then the CSI driver does provide the node service.

The default is to provide the node service.
</dd>
</dl>

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

### Global
### Global
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.

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

## Local Development
Expand All @@ -266,14 +279,14 @@ To build the plugin, run
```
$ export ARCH=amd64 # Defaults to amd64
$ make build-cmd-cinder-csi-plugin
```
```

To build cinder-csi-plugin image

```
$ export ARCH=amd64 # Defaults to amd64
$ make build-local-image-cinder-csi-plugin
```
```

### Testing

Expand All @@ -284,7 +297,7 @@ To run all unit tests:
$ make test
```
#### Sanity Tests
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)
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)

Run sanity tests for cinder CSI driver using:

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

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.

* 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.
* 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.
* 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
6 changes: 4 additions & 2 deletions docs/manila-csi-plugin/using-manila-csi-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Option | Default value | Description
`--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.
`--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.
`--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.
`--provide-controller-service` | `true` | If set to true then the CSI driver does provide the controller service.
`--provide-node-service` | `true` | If set to true then the CSI driver does provide the node service.

### Controller Service volume parameters

Expand All @@ -56,7 +58,7 @@ Parameter | Required | Description
`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.
`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.
`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).
`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.
`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.

### Node Service volume context

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

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

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

**Manual deployment**

Expand Down
Loading

0 comments on commit 635f07e

Please sign in to comment.