Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[internal] Add RPC-with-TLS #49

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b03e273
deleted hostNetwork
krpsh123 Nov 12, 2024
928f290
fix 0: deleted hostNetwork
krpsh123 Nov 12, 2024
6c24af7
fix 1: deleted hostNetwork
krpsh123 Nov 12, 2024
78ee518
csi-controller: livenessprobe: changed from HOST_IP to 127.0.0.1
krpsh123 Nov 13, 2024
aef7cee
csi-controller: livenessprobe: changed from HOST_IP to *
krpsh123 Nov 13, 2024
aec22af
v3support: added a Russian translation
krpsh123 Nov 13, 2024
0590c61
added tlsParameters
krpsh123 Nov 14, 2024
143dcb6
werf: disabled DEPRECATION WARNINGS
krpsh123 Nov 19, 2024
3ec3c61
added kmod, nfs-utils, rpcbind, tlshd images
krpsh123 Nov 27, 2024
29e4855
Merge branch 'main' into pkarpov-add-rpc-with-tls
krpsh123 Nov 27, 2024
a203356
changed nfsv3 support
krpsh123 Nov 28, 2024
a27c7c9
changed nfsv3 support 1
krpsh123 Nov 28, 2024
6b3da30
[crd] added tls and mtls
krpsh123 Nov 29, 2024
583a6d1
[charts] added support tlsParameters
krpsh123 Nov 29, 2024
5d985f7
[charts] added support tlsParameters (configmap)
krpsh123 Nov 29, 2024
29d9db8
[charts] added support tlsParameters (security)
krpsh123 Nov 29, 2024
b452aad
[charts] added support tlsParameters (fix configmap)
krpsh123 Nov 29, 2024
9315135
[charts] added support tlsParameters (fix cosmetic )
krpsh123 Dec 2, 2024
58b745b
[crd] added default values for tls and mtls
krpsh123 Dec 2, 2024
b3fc2e7
[crd] fix tls
krpsh123 Dec 2, 2024
705c3a0
get new api
krpsh123 Dec 2, 2024
5c5e12b
[crd] fix tls 1
krpsh123 Dec 2, 2024
a57b812
test1
krpsh123 Dec 2, 2024
972c5b8
[crd] fix tls 2
krpsh123 Dec 2, 2024
9efd2cc
[controller] add TLS
krpsh123 Dec 2, 2024
c84cb4a
[api] fix bool
krpsh123 Dec 2, 2024
ae1b5d4
[api] go get
krpsh123 Dec 2, 2024
105f980
fix: linter
krpsh123 Dec 2, 2024
709c64e
[charts] fix tlsParameters
krpsh123 Dec 3, 2024
b65d6df
[docs] fix v3support
krpsh123 Dec 3, 2024
eb09e61
[docs] add RPC-with-TLS
krpsh123 Dec 5, 2024
88b7969
fix: RU doc module settings
krpsh123 Dec 5, 2024
27397e8
validation test1
krpsh123 Dec 6, 2024
232aaba
test111
krpsh123 Dec 9, 2024
a47152b
NFSStorageClass validation has been removed
krpsh123 Dec 9, 2024
867a0dc
fix: NFSStorageClass validation has been removed
krpsh123 Dec 9, 2024
cd73bad
[charts] following the rules from lib-helm
krpsh123 Dec 10, 2024
10b6d59
[lib-helm] version 1.38.0
krpsh123 Dec 10, 2024
c0dc9e9
simplify
astef Dec 10, 2024
e23f863
add wait delay
astef Dec 10, 2024
3292cab
Revert "add wait delay"
krpsh123 Dec 10, 2024
1e59e6b
Revert "simplify"
krpsh123 Dec 10, 2024
f0e2b4b
[tlshd] terminate child processes gracefully
krpsh123 Dec 11, 2024
7132eaf
[tlshd] added -mode
krpsh123 Dec 11, 2024
8982d84
[controller] added a replacement in go.mo for the api
krpsh123 Dec 11, 2024
48f9a69
[controller] fixed a replacement in go.mo for the api
krpsh123 Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .werf/release.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release image, stored in your.registry.io/modules/<module-name>/release:<semver>
---
artifact: release-channel-version-artifact
image: release-channel-version-artifact
from: registry.deckhouse.io/base_images/alpine:3.16.3
final: false
shell:
beforeInstall:
- apk add --no-cache curl
Expand All @@ -14,7 +15,7 @@ shell:
image: release-channel-version
from: registry.deckhouse.io/base_images/scratch@sha256:b054705fcc9f2205777d80a558d920c0b4209efdc3163c22b5bfcb5dda1db5fc
import:
- artifact: release-channel-version-artifact
- image: release-channel-version-artifact
add: /
to: /
after: install
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/nfs_storage_class.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type NFSStorageClassConnection struct {
Host string `json:"host"`
Share string `json:"share"`
NFSVersion string `json:"nfsVersion"`
Tls bool `json:"tls"`
Mtls bool `json:"mtls"`
}

type NFSStorageClassMountOptions struct {
Expand Down
Binary file removed charts/deckhouse_lib_helm-1.31.0.tgz
Binary file not shown.
Binary file added charts/deckhouse_lib_helm-1.38.0.tgz
Binary file not shown.
6 changes: 6 additions & 0 deletions crds/doc-ru-nfsstorageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ spec:
nfsVersion:
description: |
Версия NFS сервера
tls:
description: |
Использовать ли tls для подключения.
mtls:
description: |
Использовать ли mtls; требует, чтобы tls был включён.
mountOptions:
description: |
Опции монтирования
Expand Down
19 changes: 19 additions & 0 deletions crds/nfsstorageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ spec:
- spec
properties:
spec:
x-kubernetes-validations:
- rule: "!(self.connection.mtls == true) || (self.connection.tls == true)"
message: "If mtls is true, tls must also be true."
type: object
description: |
Defines a Kubernetes Storage class configuration.
Expand Down Expand Up @@ -76,6 +79,22 @@ spec:
- "3"
- "4.1"
- "4.2"
tls:
type: boolean
x-kubernetes-validations:
- rule: self == oldSelf
message: Value is immutable.
description: |
Whether to use tls for connection.
default: false
mtls:
type: boolean
x-kubernetes-validations:
- rule: self == oldSelf
message: Value is immutable.
description: |
Whether to use mtls; requires tls to be enabled.
default: false
mountOptions:
type: object
description: |
Expand Down
40 changes: 40 additions & 0 deletions docs/EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "The csi-nfs module: examples"
description: examples of configuring the CSI NFS
---

## Configuration of the module with RPC-with-TLS support

```yaml
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: csi-nfs
spec:
enabled: true
version: 1
settings:
tlsParameters:
ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZFVENDQXZtZ...
mtls:
clientCert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1J...
clientKey: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUpRd0lCQ...
```

## Creating a StorageClass with RPC-with-TLS support

```yaml
apiVersion: storage.deckhouse.io/v1alpha1
kind: NFSStorageClass
metadata:
name: nfs-storage-class
spec:
connection:
host: nfs-server-name.io
share: /
nfsVersion: "4.1"
tls: true
mtls: true
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
```
40 changes: 40 additions & 0 deletions docs/EXAMPLES_RU.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "Модуль csi-nfs: примеры"
description: примеры конфигурации CSI NFS
---

## Конфигурация модуля с поддержкой RPC-with-TLS

```yaml
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: csi-nfs
spec:
enabled: true
version: 1
settings:
tlsParameters:
ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZFVENDQXZtZ...
mtls:
clientCert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1J...
clientKey: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUpRd0lCQ...
```

## Создание StorageClass с поддержкой RPC-with-TLS

```yaml
apiVersion: storage.deckhouse.io/v1alpha1
kind: NFSStorageClass
metadata:
name: nfs-storage-class
spec:
connection:
host: nfs-server-name.io
share: /
nfsVersion: "4.1"
tls: true
mtls: true
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
```
8 changes: 8 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ kubectl get volumesnapshot
```

This command will display a list of all snapshots and their current status.

## Why are PVs created in a StorageClass with RPC-with-TLS support not being deleted, along with their `<PV name>` directories on the NFS server?

If the resource [NFSStorageClass](./cr.html#nfsstorageclass) was created with RPC-with-TLS support,
a situation may arise where a `PV` cannot be deleted.
This happens because the secret (e.g., after the `NFSStorageClass` was deleted) storing the mount options was removed.
As a result, the controller cannot mount the NFS folder to delete the `<PV name>` directory inside it.

8 changes: 8 additions & 0 deletions docs/FAQ_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ kubectl get volumesnapshot
```

Эта команда покажет список всех снимков и их текущее состояние.

## Почему не удаляются `PV` созданные в StorageClass с поддержкой RPC-with-TLS, а вместе с ними и каталоги `<имя PV>` на NFS сервере?

Если ресурс [NFSStorageClass](./cr.html#nfsstorageclass) был создан с поддержкой RPC-with-TLS,
то может произойти ситуация при которой `PV` не удалится. Это происходит из-за того,
что был удален секрет (например удалили `NFSStorageClass`), который хранит опции монтирования.
Поэтому контроллер не может смонтировать NFS папку, чтобы удалить в ней папку `<имя PV>`.

12 changes: 12 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ This module provides CSI that manages volumes based on `NFS`. The module allows
### Requirements
- Stock kernels shipped with the [supported distributions](https://deckhouse.io/documentation/v1/supported_versions.html#linux).
- Presence of a deployed and configured NFS server.
- Enabling RPC-with-TLS requires the Linux kernel to have `CONFIG_TLS` and `CONFIG_NET_HANDSHAKE` options enabled.

### Recommendations

- For the module pods to restart when the `tlsParameters` parameter in the module settings is changed,
the [pod-reloader](https://deckhouse.io/products/kubernetes-platform/documentation/v1/modules/pod-reloader) module must be enabled (enabled by default).

## Limitations of RPC-with-TLS

- Only a single CA is supported.
- For the `mtls` security policy, only one client certificate is supported.
- A single `NFS` server cannot simultaneously use different security policies such as `tls`, `mtls`, and the standard (no TLS) mode.

## Quickstart guide

Expand Down
12 changes: 12 additions & 0 deletions docs/README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ moduleStatus: experimental

- Использование стоковых ядер, поставляемых вместе с [поддерживаемыми дистрибутивами](https://deckhouse.ru/documentation/v1/supported_versions.html#linux);
- Наличие развернутого и настроенного `NFS` сервера.
- Для поддержки RPC-with-TLS необходимо чтобы в ядре Linux были включены две опции `CONFIG_TLS` и `CONFIG_NET_HANDSHAKE`.

### Рекомендации

- Для того чтобы поды модуля перезапускались при изменении `tlsParameters` параметра в настройках модуля,
необходим включенный модуль [pod-reloader](https://deckhouse.ru/products/kubernetes-platform/documentation/v1/modules/pod-reloader) (включен по умолчанию).

## Ограничения режима RPC-with-TLS

- Поддерживается только один центр сертификации (CA).
- Для политики безопасности `mtls` поддерживается только один сертификат клиента.
- Один `NFS` сервер не может одновременно использовать разные политики безопасности `tls`, `mtls` и стандартный режим (без TLS).

## Быстрый старт

Expand Down
3 changes: 2 additions & 1 deletion images/controller/src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
"d8-controller/pkg/kubutils"
"d8-controller/pkg/logger"
"fmt"
cn "github.com/deckhouse/csi-nfs/api/v1alpha1"
"os"
goruntime "runtime"

cn "github.com/deckhouse/csi-nfs/api/v1alpha1"

"sigs.k8s.io/controller-runtime/pkg/cache"

v1 "k8s.io/api/core/v1"
Expand Down
4 changes: 3 additions & 1 deletion images/controller/src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module d8-controller
go 1.22.2

require (
github.com/deckhouse/csi-nfs/api v0.0.0-20240803013516-738ee1ca87bc
github.com/deckhouse/csi-nfs/api v0.0.0-20241202135517-c84cb4afb179
github.com/go-logr/logr v1.4.1
github.com/onsi/ginkgo/v2 v2.15.0
github.com/onsi/gomega v1.31.0
Expand Down Expand Up @@ -70,3 +70,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/deckhouse/csi-nfs/api => ../../../api
2 changes: 0 additions & 2 deletions images/controller/src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckhouse/csi-nfs/api v0.0.0-20240803013516-738ee1ca87bc h1:FRil0A1OjAHQl5Hkf2eVcU6/jrtLKMVfIOo5RDQf5NM=
github.com/deckhouse/csi-nfs/api v0.0.0-20240803013516-738ee1ca87bc/go.mod h1:/vXhdSgMvU4dP2MvOHOFZua9MvJoAPLM/hk6p7rE+Jc=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"d8-controller/pkg/logger"
"errors"
"fmt"
v1alpha1 "github.com/deckhouse/csi-nfs/api/v1alpha1"
"reflect"
"time"

v1alpha1 "github.com/deckhouse/csi-nfs/api/v1alpha1"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/storage/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -102,6 +103,8 @@ func RunNFSStorageClassWatcherController(
return reconcile.Result{}, nil
}

// TODO added validateNFSStorageClass

scList := &v1.StorageClassList{}
err = cl.List(ctx, scList)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"d8-controller/pkg/logger"
"errors"
"fmt"
v1alpha1 "github.com/deckhouse/csi-nfs/api/v1alpha1"
"reflect"
"strconv"
"strings"

v1alpha1 "github.com/deckhouse/csi-nfs/api/v1alpha1"

"slices"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -592,6 +593,12 @@ func GetSCMountOptions(nsc *v1alpha1.NFSStorageClass) []string {
mountOptions = append(mountOptions, "nfsvers="+nsc.Spec.Connection.NFSVersion)
}

if nsc.Spec.Connection.Mtls {
mountOptions = append(mountOptions, "xprtsec=mtls")
} else if nsc.Spec.Connection.Tls {
mountOptions = append(mountOptions, "xprtsec=tls")
}

if nsc.Spec.MountOptions != nil {

if nsc.Spec.MountOptions.MountMode != "" {
Expand Down
9 changes: 7 additions & 2 deletions images/controller/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ final: false

git:
- add: /images/controller/src
to: /src
to: /csi-nfs/images/controller/src
stageDependencies:
setup:
- "**/*"
- add: /api
to: /csi-nfs/api
stageDependencies:
setup:
- "**/*"
Expand All @@ -17,7 +22,7 @@ mount:
to: /go/pkg
shell:
setup:
- cd /src/cmd
- cd /csi-nfs/images/controller/src/cmd
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o controller
- mv controller /controller
- chmod +x /controller
Expand Down
Loading
Loading