Skip to content

Commit

Permalink
[controller] Remove subDir parameter from NFSStorageClass (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Zimin <[email protected]>
  • Loading branch information
AleksZimin authored May 16, 2024
1 parent e4d9f58 commit 4cf0b35
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 1,053 deletions.
841 changes: 0 additions & 841 deletions crds/crd-csi-snapshot.yaml

This file was deleted.

60 changes: 0 additions & 60 deletions crds/doc-ru-crd-csi-snapshot.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions crds/doc-ru-nfsstorageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ spec:
share:
description: |
Путь к точке монтирования на NFS сервере
subDir:
description: |
Поддиректория в NFS разделе. Если поддиректория не существует, она будет создана. Если значение subDir содержит следующие строки, они будут преобразованы в соответствующее имя pv/pvc или пространство имен:
- ${pvc.metadata.name}
- ${pvc.metadata.namespace}
- ${pv.metadata.name}
nfsVersion:
description: |
Версия NFS сервера
Expand Down
11 changes: 0 additions & 11 deletions crds/nfsstorageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,6 @@ spec:
description: |
NFS server share path
minLength: 1
subDir:
type: string
x-kubernetes-validations:
- rule: self == oldSelf
message: Value is immutable.
description: |
Sub directory under nfs share. If sub directory does not exist, it will be created. If subDir value contains following strings, it would be converted into corresponding pv/pvc name or namespace:
- ${pvc.metadata.name}
- ${pvc.metadata.namespace}
- ${pv.metadata.name}
minLength: 1
nfsVersion:
type: string
x-kubernetes-validations:
Expand Down
57 changes: 0 additions & 57 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,3 @@ kubectl -n d8-csi-nfs get pod -owide -w
## Is it possible to change the parameters of an NFS server for already created PVs?

No, the connection data to the NFS server is stored directly in the PV manifest and cannot be changed. Changing the Storage Class also does not affect the connection settings in already existing PVs.

## How to use the `subDir` parameter?

The `subDir` parameter allows you to specify a subdirectory for each PV.

### Example with templates

You can use 3 templates:

- `${pvc.metadata.name}`
- `${pvc.metadata.namespace}`
- `${pv.metadata.name}`

```yaml
kubectl apply -f - <<'EOF'
apiVersion: storage.deckhouse.io/v1alpha1
kind: NFSStorageClass
metadata:
name: nfs-storage-class
spec:
connection:
host: 10.223.187.3
share: /
subDir: "${pvc.metadata.namespace}/${pvc.metadata.name}"
nfsVersion: "4.1"
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
EOF
```

In this example, a directory `/<namespace>/<PVC name>` will be created on the NFS server for each volume.

> **Caution!** The PVC name is set by the user. Such `subDir` settings may lead to a situation where the directory name for a newly created volume matches the directory name of a previously deleted volume. If `reclaimPolicy` is set to `Retain`, the data from the previously allocated volumes with the same PVC name will be available in the new volume.
### Example without templates

In addition to templates, you can specify a regular string as the subdirectory name.

```yaml
kubectl apply -f - <<'EOF'
apiVersion: storage.deckhouse.io/v1alpha1
kind: NFSStorageClass
metadata:
name: nfs-storage-class
spec:
connection:
host: 10.223.187.3
share: /
subDir: "shared-folder"
nfsVersion: "4.1"
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
```
In this example, all PVs of this StorageClass will use the same directory on the server: `/shared-folder`.

> **Caution!** If `reclaimPolicy` is set to `Delete`, deleting any PVC of this StorageClass will result in the deletion of the entire `/shared-folder` directory.
58 changes: 0 additions & 58 deletions docs/FAQ_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,3 @@ kubectl -n d8-csi-nfs get pod -owide -w
## Возможно ли изменение параметров NFS-сервера уже созданных PV?

Нет, данные для подключения к NFS-серверу сохраняются непосредственно в манифесте PV, и не подлежат изменению. Изменение Storage Class также не повлечет изменений настроек подключения в уже существующих PV.

## Как использовать параметр `subDir`?

`subDir` позволяет задавать подпапку для каждого PV.

### Пример с шаблонами

Можно использовать 3 шаблона:

- `${pvc.metadata.name}`
- `${pvc.metadata.namespace}`
- `${pv.metadata.name}`

```yaml
kubectl apply -f - <<'EOF'
apiVersion: storage.deckhouse.io/v1alpha1
kind: NFSStorageClass
metadata:
name: nfs-storage-class
spec:
connection:
host: 10.223.187.3
share: /
subDir: "${pvc.metadata.namespace}/${pvc.metadata.name}"
nfsVersion: "4.1"
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
EOF
```

В данном примере на NFS-сервере для каждого тома будет создаваться каталог `/<название namespace>/<название PVC>`.

> **Внимание!** Имя PVC задается пользователем. Такие настройки `subDir` могут привести к ситуации, когда имя каталога для вновь создаваемого тома совпадет с именем каталога ранее удаленного тома. Если `reclaimPolicy` установлен в значение `Retain`, то в новом томе будут доступны данные томов, выделенных ранее для PVC с таким же именем.
### Пример без шаблонов

Помимо шаблонов, можно указывать обычную строку - имя подпапки.

```yaml
kubectl apply -f - <<'EOF'
apiVersion: storage.deckhouse.io/v1alpha1
kind: NFSStorageClass
metadata:
name: nfs-storage-class
spec:
connection:
host: 10.223.187.3
share: /
subDir: "shared-folder"
nfsVersion: "4.1"
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
EOF
```

В данном примере все PV такого StorageClass будут использовать один и тот же каталог на сервере: `/shared-folder`.

> **Внимание!** Если `reclaimPolicy` выставлен в `Delete`, то удаление любой PVC такого StorageClass приведет к удалению всего каталога `/shared-folder`.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ spec:
EOF
```

In this example, `subDir` is not specified, so a directory `<directory from share>/<PV name>` will be created for each PV.
A directory `<directory from share>/<PV name>` will be created for each PV.

### Checking module health

You can check the module health [here](./faq.html#how-to-check-module-health)
You can verify the functionality of the module using the instructions [here](./faq.html#how-to-check-module-health)
2 changes: 1 addition & 1 deletion docs/README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ spec:
EOF
```

В данном примере не указан `subDir`, поэтому для каждой `PV` будет создаваться каталог `<директория из share>/<имя PV>`.
Для каждой `PV` будет создаваться каталог `<директория из share>/<имя PV>`.

### Проверка работоспособности модуля.

Expand Down
1 change: 0 additions & 1 deletion images/controller/api/v1alpha1/nfs_storage_class.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type NFSStorageClassConnection struct {
Host string `json:"host"`
Share string `json:"share"`
NFSVersion string `json:"nfsVersion"`
SubDir string `json:"subDir,omitempty"`
}

type NFSStorageClassMountOptions struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,6 @@ func GetSCParams(nsc *v1alpha1.NFSStorageClass, controllerNamespace string) map[
params[MountPermissionsParamKey] = nsc.Spec.ChmodPermissions
}

if nsc.Spec.Connection.SubDir != "" {
params[SubDirParamKey] = nsc.Spec.Connection.SubDir
}

return params
}

Expand Down
Loading

0 comments on commit 4cf0b35

Please sign in to comment.