Skip to content

Commit

Permalink
Merge pull request kubernetes-csi#49 from shiftstack/merge-bot-master
Browse files Browse the repository at this point in the history
  • Loading branch information
openshift-merge-robot authored Jul 13, 2021
2 parents b73e85f + ae8ceb3 commit 44ef1a1
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 86 deletions.
46 changes: 27 additions & 19 deletions charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
- [install Helm](https://helm.sh/docs/intro/quickstart/#install-helm)

### Tips
- `--set controller.runOnMaster=true` could make csi-nfs-controller only run on master node
- `--set feature.enableFSGroupPolicy=true` could enable `fsGroupPolicy` on a k8s 1.20+ cluster (this feature is in beta, check details [here](../deploy/example/fsgroup))
- `--set controller.replicas=1` could set replica of csi-nfs-controller as `1`
- make controller only run on master node: `--set controller.runOnMaster=true`
- set replica of controller as `1`: `--set controller.replicas=1`
- enable `fsGroupPolicy` on a k8s 1.20+ cluster (this feature is in beta, check details [here](../deploy/example/fsgroup)): `--set feature.enableFSGroupPolicy=true`

## install latest version
```console
Expand All @@ -20,6 +20,13 @@ helm repo add csi-driver-nfs https://raw.githubusercontent.com/kubernetes-csi/cs
helm install csi-driver-nfs csi-driver-nfs/csi-driver-nfs --namespace kube-system --version v3.0.0
```

### install driver with customized driver name, deployment name
> only supported from `v3.0.0`+
- following example would install a driver with name `nfs2`
```console
helm install csi-driver-nfs2 csi-driver-nfs/csi-driver-nfs --namespace kube-system --set driver.name="nfs2.csi.k8s.io" --set controller.name="csi-nfs2-controller" --set rbac.name=nfs2 --set serviceAccount.controller=csi-nfs2-controller-sa --set serviceAccount.node=csi-nfs2-node-sa --set node.name=csi-nfs2-node --set node.livenessProbe.healthPort=39653
```

### search for all available chart versions
```console
helm search repo -l csi-driver-nfs
Expand All @@ -36,24 +43,25 @@ The following table lists the configurable parameters of the latest NFS CSI Driv

| Parameter | Description | Default |
|---------------------------------------------------|------------------------------------------------------------|-------------------------------------------------------------------|
| `driver.name` | alternative driver name | `nfs.csi.k8s.io` |
| `feature.enableFSGroupPolicy` | enable `fsGroupPolicy` on a k8s 1.20+ cluster | `false` |
| `image.nfs.repository` | csi-driver-nfs docker image | gcr.io/k8s-staging-sig-storage/nfsplugin |
| `image.nfs.tag` | csi-driver-nfs docker image tag | amd64-linux-canary |
| `image.nfs.pullPolicy` | csi-driver-nfs image pull policy | IfNotPresent |
| `image.csiProvisioner.repository` | csi-provisioner docker image | k8s.gcr.io/sig-storage/csi-provisioner |
| `image.csiProvisioner.tag` | csi-provisioner docker image tag | v2.0.4 |
| `image.csiProvisioner.pullPolicy` | csi-provisioner image pull policy | IfNotPresent |
| `image.livenessProbe.repository` | liveness-probe docker image | k8s.gcr.io/sig-storage/livenessprobe |
| `image.livenessProbe.tag` | liveness-probe docker image tag | v2.3.0 |
| `image.livenessProbe.pullPolicy` | liveness-probe image pull policy | IfNotPresent |
| `image.nodeDriverRegistrar.repository` | csi-node-driver-registrar docker image | k8s.gcr.io/sig-storage/csi-node-driver-registrar |
| `image.nodeDriverRegistrar.tag` | csi-node-driver-registrar docker image tag | v2.2.0 |
| `image.nodeDriverRegistrar.pullPolicy` | csi-node-driver-registrar image pull policy | IfNotPresent |
| `image.nfs.repository` | csi-driver-nfs docker image | `gcr.io/k8s-staging-sig-storage/nfsplugin` |
| `image.nfs.tag` | csi-driver-nfs docker image tag | `amd64-linux-canary` |
| `image.nfs.pullPolicy` | csi-driver-nfs image pull policy | `IfNotPresent` |
| `image.csiProvisioner.repository` | csi-provisioner docker image | `k8s.gcr.io/sig-storage/csi-provisioner` |
| `image.csiProvisioner.tag` | csi-provisioner docker image tag | `v2.0.4` |
| `image.csiProvisioner.pullPolicy` | csi-provisioner image pull policy | `IfNotPresent` |
| `image.livenessProbe.repository` | liveness-probe docker image | `k8s.gcr.io/sig-storage/livenessprobe` |
| `image.livenessProbe.tag` | liveness-probe docker image tag | `v2.3.0` |
| `image.livenessProbe.pullPolicy` | liveness-probe image pull policy | `IfNotPresent` |
| `image.nodeDriverRegistrar.repository` | csi-node-driver-registrar docker image | `k8s.gcr.io/sig-storage/csi-node-driver-registrar` |
| `image.nodeDriverRegistrar.tag` | csi-node-driver-registrar docker image tag | `v2.2.0` |
| `image.nodeDriverRegistrar.pullPolicy` | csi-node-driver-registrar image pull policy | `IfNotPresent` |
| `imagePullSecrets` | Specify docker-registry secret names as an array | [] (does not add image pull secrets to deployed pods) |
| `serviceAccount.create` | whether create service account of csi-nfs-controller | true |
| `rbac.create` | whether create rbac of csi-nfs-controller | true |
| `controller.replicas` | the replicas of csi-nfs-controller | 2 |
| `controller.runOnMaster` | run controller on master node | false |
| `serviceAccount.create` | whether create service account of csi-nfs-controller | `true` |
| `rbac.create` | whether create rbac of csi-nfs-controller | `true` |
| `controller.replicas` | the replicas of csi-nfs-controller | `2` |
| `controller.runOnMaster` | run controller on master node | `false` |
| `controller.logLevel` | controller driver log level |`5` |
| `controller.tolerations` | controller pod tolerations | |
| `node.logLevel` | node driver log level |`5` |
Expand Down
Binary file modified charts/latest/csi-driver-nfs-v3.0.0.tgz
Binary file not shown.
13 changes: 7 additions & 6 deletions charts/latest/csi-driver-nfs/templates/csi-nfs-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: csi-nfs-controller
name: {{ .Values.controller.name }}
namespace: {{ .Release.Namespace }}
{{ include "nfs.labels" . | indent 2 }}
spec:
replicas: {{ .Values.controller.replicas }}
selector:
matchLabels:
app: csi-nfs-controller
app: {{ .Values.controller.name }}
template:
metadata:
{{ include "nfs.labels" . | indent 6 }}
app: csi-nfs-controller
app: {{ .Values.controller.name }}
spec:
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{- end }}
hostNetwork: true # controller also needs to mount nfs to create dir
dnsPolicy: ClusterFirstWithHostNet
serviceAccountName: csi-nfs-controller-sa
serviceAccountName: {{ .Values.serviceAccount.controller }}
nodeSelector:
kubernetes.io/os: linux
{{- if .Values.controller.runOnMaster}}
Expand Down Expand Up @@ -58,7 +58,7 @@ spec:
args:
- --csi-address=/csi/csi.sock
- --probe-timeout=3s
- --health-port=29652
- --health-port={{ .Values.controller.livenessProbe.healthPort }}
- --v=2
imagePullPolicy: {{ .Values.image.livenessProbe.pullPolicy }}
volumeMounts:
Expand All @@ -83,6 +83,7 @@ spec:
- "--v={{ .Values.controller.logLevel }}"
- "--nodeid=$(NODE_ID)"
- "--endpoint=$(CSI_ENDPOINT)"
- "--drivername={{ .Values.driver.name }}"
env:
- name: NODE_ID
valueFrom:
Expand All @@ -91,7 +92,7 @@ spec:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
ports:
- containerPort: 29652
- containerPort: {{ .Values.controller.livenessProbe.healthPort }}
name: healthz
protocol: TCP
livenessProbe:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: storage.k8s.io/v1beta1
kind: CSIDriver
metadata:
name: nfs.csi.k8s.io
name: {{ .Values.driver.name }}
spec:
attachRequired: false
volumeLifecycleModes:
Expand Down
9 changes: 5 additions & 4 deletions charts/latest/csi-driver-nfs/templates/csi-nfs-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-nfs-node
name: {{ .Values.node.name }}
namespace: {{ .Release.Namespace }}
{{ include "nfs.labels" . | indent 2 }}
spec:
selector:
matchLabels:
app: csi-nfs-node
app: {{ .Values.node.name }}
template:
metadata:
{{ include "nfs.labels" . | indent 6 }}
app: csi-nfs-node
app: {{ .Values.node.name }}
spec:
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -78,6 +78,7 @@ spec:
- "--v={{ .Values.node.logLevel }}"
- "--nodeid=$(NODE_ID)"
- "--endpoint=$(CSI_ENDPOINT)"
- "--drivername={{ .Values.driver.name }}"
env:
- name: NODE_ID
valueFrom:
Expand All @@ -86,7 +87,7 @@ spec:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
ports:
- containerPort: 29653
- containerPort: {{ .Values.node.livenessProbe.healthPort }}
name: healthz
protocol: TCP
livenessProbe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-nfs-controller-sa
name: csi-{{ .Values.rbac.name }}-controller-sa
namespace: {{ .Release.Namespace }}
{{ include "nfs.labels" . | indent 2 }}
---
Expand All @@ -13,7 +13,7 @@ metadata:
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-external-provisioner-role
name: {{ .Values.rbac.name }}-external-provisioner-role
{{ include "nfs.labels" . | indent 2 }}
rules:
- apiGroups: [""]
Expand Down Expand Up @@ -41,14 +41,14 @@ rules:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-csi-provisioner-binding
name: {{ .Values.rbac.name }}-csi-provisioner-binding
{{ include "nfs.labels" . | indent 2 }}
subjects:
- kind: ServiceAccount
name: csi-nfs-controller-sa
name: csi-{{ .Values.rbac.name }}-controller-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: nfs-external-provisioner-role
name: {{ .Values.rbac.name }}-external-provisioner-role
apiGroup: rbac.authorization.k8s.io
{{- end -}}
19 changes: 14 additions & 5 deletions charts/latest/csi-driver-nfs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,32 @@ image:
repository: k8s.gcr.io/sig-storage/csi-node-driver-registrar
tag: v2.2.0
pullPolicy: IfNotPresent

serviceAccount:
create: true
create: true # When true, service accounts will be created for you. Set to false if you want to use your own.
controller: csi-nfs-controller-sa # Name of Service Account to be created or used

rbac:
create: true
name: nfs

controller:
name: csi-nfs-controller
replicas: 2
runOnMaster: false
livenessProbe:
healthPort: 29652
logLevel: 5
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Equal"
value: "true"
operator: "Exists"
effect: "NoSchedule"
- key: "node-role.kubernetes.io/controlplane"
operator: "Equal"
value: "true"
operator: "Exists"
effect: "NoSchedule"

node:
name: csi-nfs-node
logLevel: 5
livenessProbe:
healthPort: 29653
Expand All @@ -44,6 +50,9 @@ node:
feature:
enableFSGroupPolicy: false

driver:
name: nfs.csi.k8s.io

## Reference to one or more secrets to be used when pulling images
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
Expand Down
9 changes: 5 additions & 4 deletions cmd/nfsplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import (
)

var (
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
nodeID = flag.String("nodeid", "", "node id")
perm = flag.String("mount-permissions", "", "mounted folder permissions")
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
nodeID = flag.String("nodeid", "", "node id")
perm = flag.String("mount-permissions", "", "mounted folder permissions")
driverName = flag.String("drivername", nfs.DefaultDriverName, "name of the driver")
)

func init() {
Expand Down Expand Up @@ -61,6 +62,6 @@ func handle() {
parsedPerm = &permu32
}

d := nfs.NewNFSdriver(*nodeID, *endpoint, parsedPerm)
d := nfs.NewNFSdriver(*nodeID, *driverName, *endpoint, parsedPerm)
d.Run(false)
}
6 changes: 2 additions & 4 deletions deploy/csi-nfs-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ spec:
priorityClassName: system-cluster-critical
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Equal"
value: "true"
operator: "Exists"
effect: "NoSchedule"
- key: "node-role.kubernetes.io/controlplane"
operator: "Equal"
value: "true"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: csi-provisioner
Expand Down
5 changes: 5 additions & 0 deletions docs/csi-debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ csi-nfs-node-dr4s4 3/3 Running 0 7m4s 1
- get csi driver logs
```console
$ kubectl logs csi-nfs-node-cvgbs -c nfs -n kube-system > csi-nfs-node.log
```

- check nfs mount inside driver
```console
kubectl exec -it csi-nfs-node-cvgbss -n kube-system -c nfs -- mount | grep nfs
```

### troubleshooting connection failure on agent node
Expand Down
36 changes: 23 additions & 13 deletions hack/verify-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,35 @@

set -euo pipefail

rollout_and_wait() {
echo "Applying config \"$1\""
trap "echo \"Failed to apply config \\\"$1\\\"\" >&2" err

APPNAME=$(kubectl apply -f $1 | grep -E "^(:?daemonset|deployment|statefulset|pod)" | awk '{printf $1}')
if [[ -n $(expr "${APPNAME}" : "\(daemonset\|deployment\|statefulset\)" || true) ]]; then
kubectl rollout status $APPNAME --watch --timeout=5m
else
kubectl wait "${APPNAME}" --for condition=ready --timeout=5m
fi
}

echo "begin to create deployment examples ..."

kubectl apply -f ./deploy/example/storageclass-nfs.yaml
kubectl apply -f ./deploy/example/deployment.yaml
kubectl apply -f ./deploy/example/statefulset.yaml
if [[ "$#" -gt 0 ]]&&[[ "$1" == *"ephemeral"* ]]; then
kubectl apply -f ./deploy/example/daemonset-nfs-ephemeral.yaml
fi

echo "sleep 60s ..."
sleep 60

echo "begin to check pod status ..."
kubectl get pods -o wide
EXAMPLES+=(\
deploy/example/deployment.yaml \
deploy/example/statefulset.yaml \
)

kubectl get pods --field-selector status.phase=Running | grep deployment-nfs
kubectl get pods --field-selector status.phase=Running | grep statefulset-nfs-0
if [[ "$#" -gt 0 ]]&&[[ "$1" == *"ephemeral"* ]]; then
kubectl get pods --field-selector status.phase=Running | grep daemonset-nfs-ephemeral
EXAMPLES+=(\
deploy/example/daemonset-nfs-ephemeral.yaml \
)
fi

for EXAMPLE in "${EXAMPLES[@]}"; do
rollout_and_wait $EXAMPLE
done

echo "deployment examples running completed."
2 changes: 1 addition & 1 deletion pkg/nfs/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
func initTestController(t *testing.T) *ControllerServer {
var perm *uint32
mounter := &mount.FakeMounter{MountPoints: []mount.MountPoint{}}
driver := NewNFSdriver("", "", perm)
driver := NewNFSdriver("", "", "", perm)
driver.ns = NewNodeServer(driver, mounter)
cs := NewControllerServer(driver)
cs.workingMountDir = "/tmp"
Expand Down
10 changes: 5 additions & 5 deletions pkg/nfs/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Driver struct {
}

const (
DriverName = "nfs.csi.k8s.io"
DefaultDriverName = "nfs.csi.k8s.io"
// Address of the NFS server
paramServer = "server"
// Base directory of the NFS server to create volumes under.
Expand All @@ -56,11 +56,11 @@ var (
version = "3.0.0"
)

func NewNFSdriver(nodeID, endpoint string, perm *uint32) *Driver {
klog.Infof("Driver: %v version: %v", DriverName, version)
func NewNFSdriver(nodeID, driverName, endpoint string, perm *uint32) *Driver {
klog.Infof("Driver: %v version: %v", driverName, version)

n := &Driver{
name: DriverName,
name: driverName,
version: version,
nodeID: nodeID,
endpoint: endpoint,
Expand Down Expand Up @@ -100,7 +100,7 @@ func NewNodeServer(n *Driver, mounter mount.Interface) *NodeServer {
}

func (n *Driver) Run(testMode bool) {
versionMeta, err := GetVersionYAML()
versionMeta, err := GetVersionYAML(n.name)
if err != nil {
klog.Fatalf("%v", err)
}
Expand Down
Loading

0 comments on commit 44ef1a1

Please sign in to comment.