README, LICENSE
This commit is contained in:
parent
9c3eb75ae7
commit
03c4d86aa1
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Travis Glenn Hansen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
# Introduction
|
||||
|
||||
`democratic-csi` implements the `csi` (container storage interface) spec
|
||||
providing storage for various container orchestration systems (ie: Kubernetes).
|
||||
|
||||
The current focus is providing storage via iscsi/nfs from zfs-based storage
|
||||
systems, predominantly `FreeNAS / TrueNAS` and `ZoL` on `Ubuntu`.
|
||||
|
||||
The current drivers implement depth and breadth of the `csi` spec, so you have
|
||||
access to resizing, snapshots, etc, etc.
|
||||
|
||||
`democratic-csi` is 2 things:
|
||||
|
||||
- several implementations of `csi` drivers
|
||||
- freenas-nfs (manages zfs datasets to share over nfs)
|
||||
- freenas-iscsi (manages zfs zvols to share over iscsi)
|
||||
- zfs-generic-nfs (works with any ZoL installation...ie: Ubuntu)
|
||||
- zfs-generic-iscsi (works with any ZoL installation...ie: Ubuntu)
|
||||
- zfs-local-ephemeral-inline (provisions node-local zfs datasets)
|
||||
- framework for developing `csi` drivers
|
||||
|
||||
If you have any interest in providing a `csi` driver, simply open an issue to
|
||||
discuss. The project provides an extensive framework to build from making it
|
||||
relatively easy to implement new drivers.
|
||||
|
||||
# Installation
|
||||
|
||||
Predominantly 2 things are needed:
|
||||
|
||||
- node prep: https://netapp-trident.readthedocs.io/en/stable-v20.04/kubernetes/operations/tasks/worker.html
|
||||
- deploy the driver into the cluster (`helm` chart provided with sample
|
||||
`values.yaml`)
|
||||
|
||||
You should install/configure the requirements for both nfs and iscsi.
|
||||
|
||||
## Helm Installation
|
||||
|
||||
```
|
||||
helm repo add democratic-csi https://democratic-csi.github.io/charts/
|
||||
helm repo update
|
||||
helm search democratic-csi/
|
||||
|
||||
# copy proper values file from https://github.com/democratic-csi/charts/tree/master/stable/democratic-csi/examples
|
||||
# edit as appropriate
|
||||
# examples are from helm v2, alter as appropriate for v3
|
||||
|
||||
helm upgrade \
|
||||
--install \
|
||||
--values freenas-iscsi.yaml \
|
||||
--namespace democratic-csi \
|
||||
zfs-iscsi democratic-csi/democratic-csi
|
||||
|
||||
helm upgrade \
|
||||
--install \
|
||||
--values freenas-nfs.yaml \
|
||||
--namespace democratic-csi \
|
||||
zfs-nfs democratic-csi/democratic-csi
|
||||
```
|
||||
|
||||
## Multiple Deployments
|
||||
|
||||
You may install multiple deployments of each/any driver. It requires the following:
|
||||
|
||||
- Use a new helm release name for each deployment
|
||||
- Make sure you have a unique `csiDriver.name` in the values file
|
||||
- Use unqiue names for your storage classes (per cluster)
|
||||
- Use a unique parent dataset (ie: don't try to use the same parent across deployments or clusters)
|
||||
|
|
@ -18,9 +18,15 @@ const VOLUME_CONTEXT_PROVISIONER_INSTANCE_ID_PROPERTY_NAME =
|
|||
* https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/20190122-csi-inline-volumes.md
|
||||
* https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html
|
||||
*
|
||||
* Sample calls:
|
||||
* - https://gcsweb.k8s.io/gcs/kubernetes-jenkins/pr-logs/pull/92387/pull-kubernetes-e2e-gce/1280784994997899264/artifacts/_sig-storage_CSI_Volumes/_Driver_csi-hostpath_/_Testpattern_inline_ephemeral_CSI_volume_ephemeral/should_create_read_write_inline_ephemeral_volume/
|
||||
* - https://storage.googleapis.com/kubernetes-jenkins/pr-logs/pull/92387/pull-kubernetes-e2e-gce/1280784994997899264/artifacts/_sig-storage_CSI_Volumes/_Driver_csi-hostpath_/_Testpattern_inline_ephemeral_CSI_volume_ephemeral/should_create_read-only_inline_ephemeral_volume/csi-hostpathplugin-0-hostpath.log
|
||||
*
|
||||
* inline drivers are assumed to be mount only (no block support)
|
||||
* purposely there is no native support for size contraints
|
||||
*
|
||||
* TODO: support creating zvols and formatting and mounting locally instead of using zfs dataset?
|
||||
*
|
||||
*/
|
||||
class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
||||
constructor(ctx, options) {
|
||||
|
|
@ -127,7 +133,8 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
|||
}
|
||||
|
||||
assertCapabilities(capabilities) {
|
||||
const driverZfsResourceType = this.getDriverZfsResourceType();
|
||||
// hard code this for now
|
||||
const driverZfsResourceType = "filesystem";
|
||||
this.ctx.logger.verbose("validating capabilities: %j", capabilities);
|
||||
|
||||
let message = null;
|
||||
|
|
@ -142,20 +149,25 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
|||
|
||||
if (
|
||||
capability.mount.fs_type &&
|
||||
!["nfs"].includes(capability.mount.fs_type)
|
||||
!["zfs"].includes(capability.mount.fs_type)
|
||||
) {
|
||||
message = `invalid fs_type ${capability.mount.fs_type}`;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
capability.mount.mount_flags &&
|
||||
capability.mount.mount_flags.length > 0
|
||||
) {
|
||||
message = `invalid mount_flags ${capability.mount.mount_flags}`;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
![
|
||||
"UNKNOWN",
|
||||
"SINGLE_NODE_WRITER",
|
||||
"SINGLE_NODE_READER_ONLY",
|
||||
"MULTI_NODE_READER_ONLY",
|
||||
"MULTI_NODE_SINGLE_WRITER",
|
||||
"MULTI_NODE_MULTI_WRITER",
|
||||
].includes(capability.access_mode.mode)
|
||||
) {
|
||||
message = `invalid access_mode, ${capability.access_mode.mode}`;
|
||||
|
|
@ -181,8 +193,6 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
|||
"UNKNOWN",
|
||||
"SINGLE_NODE_WRITER",
|
||||
"SINGLE_NODE_READER_ONLY",
|
||||
"MULTI_NODE_READER_ONLY",
|
||||
"MULTI_NODE_SINGLE_WRITER",
|
||||
].includes(capability.access_mode.mode)
|
||||
) {
|
||||
message = `invalid access_mode, ${capability.access_mode.mode}`;
|
||||
|
|
@ -201,6 +211,27 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
|||
* the mountpoint is the target_path
|
||||
*
|
||||
* Any volume_context attributes starting with property.<name> will be set as zfs properties
|
||||
*
|
||||
* {
|
||||
"target_path": "/var/lib/kubelet/pods/f8b237db-19e8-44ae-b1d2-740c9aeea702/volumes/kubernetes.io~csi/my-volume-0/mount",
|
||||
"volume_capability": {
|
||||
"AccessType": {
|
||||
"Mount": {}
|
||||
},
|
||||
"access_mode": {
|
||||
"mode": 1
|
||||
}
|
||||
},
|
||||
"volume_context": {
|
||||
"csi.storage.k8s.io/ephemeral": "true",
|
||||
"csi.storage.k8s.io/pod.name": "inline-volume-tester-2ptb7",
|
||||
"csi.storage.k8s.io/pod.namespace": "ephemeral-468",
|
||||
"csi.storage.k8s.io/pod.uid": "f8b237db-19e8-44ae-b1d2-740c9aeea702",
|
||||
"csi.storage.k8s.io/serviceAccount.name": "default",
|
||||
"foo": "bar"
|
||||
},
|
||||
"volume_id": "csi-8228252978a824126924de00126e6aec7c989a48a39d577bd3ab718647df5555"
|
||||
}
|
||||
*
|
||||
* @param {*} call
|
||||
*/
|
||||
|
|
@ -240,6 +271,14 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
|||
);
|
||||
}
|
||||
|
||||
if (capability) {
|
||||
const result = this.assertCapabilities([capability]);
|
||||
|
||||
if (result.valid !== true) {
|
||||
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
|
||||
}
|
||||
}
|
||||
|
||||
const datasetName = datasetParentName + "/" + name;
|
||||
|
||||
// TODO: support arbitrary values from config
|
||||
|
|
@ -271,6 +310,11 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
|||
// NOTE: setting mountpoint will automatically create the full path as necessary so no need for mkdir etc
|
||||
volumeProperties["mountpoint"] = target_path;
|
||||
|
||||
// does not really make sense for ephemeral volumes..but we'll put it here in case
|
||||
if (readonly) {
|
||||
volumeProperties["readonly"] = "on";
|
||||
}
|
||||
|
||||
// set driver config properties
|
||||
if (this.options.zfs.properties) {
|
||||
Object.keys(driver.options.zfs.properties).forEach(function (key) {
|
||||
|
|
@ -296,6 +340,11 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
|
|||
|
||||
/**
|
||||
* This should destroy the dataset and remove target_path as appropriate
|
||||
*
|
||||
*{
|
||||
"target_path": "/var/lib/kubelet/pods/f8b237db-19e8-44ae-b1d2-740c9aeea702/volumes/kubernetes.io~csi/my-volume-0/mount",
|
||||
"volume_id": "csi-8228252978a824126924de00126e6aec7c989a48a39d577bd3ab718647df5555"
|
||||
}
|
||||
*
|
||||
* @param {*} call
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue