From 4008fe5487ec6748c534e2bfa3adc038c8f0fb4a Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sun, 13 Sep 2020 12:08:38 +0000 Subject: [PATCH] fix: deployment script/doc issues fix test error set kube-system namespace --- README.md | 12 +++---- ...lugin-nfsplugin.yaml => csi-nfs-node.yaml} | 8 ++--- deploy/kubernetes/csi-nodeplugin-rbac.yaml | 34 ------------------- examples/kubernetes/nginx.yaml | 2 +- test/nfs-testdriver.go | 11 ++---- 5 files changed, 14 insertions(+), 53 deletions(-) rename deploy/kubernetes/{csi-nodeplugin-nfsplugin.yaml => csi-nfs-node.yaml} (93%) delete mode 100644 deploy/kubernetes/csi-nodeplugin-rbac.yaml diff --git a/README.md b/README.md index d8025ab8..c38b616b 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ and working NFS server (e.g. https://github.com/rootfs/nfs-ganesha-docker) #### Deploy Deploy the NFS plugin along with the `CSIDriver` info. -``` -kubectl -f deploy/kubernetes create +```console +kubectl create -f deploy/kubernetes ``` #### Example Nginx application @@ -53,22 +53,22 @@ NFS server public end point and configuration. You can also provide additional `mountOptions`, such as protocol version, in the `PersistentVolume` `spec` relevant for your NFS Server. -``` -kubectl -f examples/kubernetes/nginx.yaml create +```console +kubectl create -f examples/kubernetes/nginx.yaml ``` ## Running Kubernetes End To End tests on an NFS Driver First, stand up a local cluster `ALLOW_PRIVILEGED=1 hack/local-up-cluster.sh` (from your Kubernetes repo) For Fedora/RHEL clusters, the following might be required: -``` +```console sudo chown -R $USER:$USER /var/run/kubernetes/ sudo chown -R $USER:$USER /var/lib/kubelet sudo chcon -R -t svirt_sandbox_file_t /var/lib/kubelet ``` If you are plannig to test using your own private image, you could either install your nfs driver using your own set of YAML files, or edit the existing YAML files to use that private image. -When using the [existing set of YAML files](https://github.com/kubernetes-csi/csi-driver-nfs/tree/master/deploy/kubernetes), you would edit the [csi-attacher-nfsplugin.yaml](https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/deploy/kubernetes/csi-attacher-nfsplugin.yaml#L46) and [csi-nodeplugin-nfsplugin.yaml](https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/deploy/kubernetes/csi-nodeplugin-nfsplugin.yaml#L45) files to include your private image instead of the default one. After editing these files, skip to step 3 of the following steps. +When using the [existing set of YAML files](https://github.com/kubernetes-csi/csi-driver-nfs/tree/master/deploy/kubernetes), you would edit [csi-nfs-node.yaml](https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/deploy/kubernetes/csi-nfs-node.yaml#L45) files to include your private image instead of the default one. After editing these files, skip to step 3 of the following steps. If you already have a driver installed, skip to step 4 of the following steps. diff --git a/deploy/kubernetes/csi-nodeplugin-nfsplugin.yaml b/deploy/kubernetes/csi-nfs-node.yaml similarity index 93% rename from deploy/kubernetes/csi-nodeplugin-nfsplugin.yaml rename to deploy/kubernetes/csi-nfs-node.yaml index dd08461b..c4a29ba8 100644 --- a/deploy/kubernetes/csi-nodeplugin-nfsplugin.yaml +++ b/deploy/kubernetes/csi-nfs-node.yaml @@ -3,17 +3,17 @@ kind: DaemonSet apiVersion: apps/v1 metadata: - name: csi-nodeplugin-nfsplugin + name: csi-nfs-node + namespace: kube-system spec: selector: matchLabels: - app: csi-nodeplugin-nfsplugin + app: csi-nfs-node template: metadata: labels: - app: csi-nodeplugin-nfsplugin + app: csi-nfs-node spec: - serviceAccount: csi-nodeplugin containers: - name: node-driver-registrar image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2 diff --git a/deploy/kubernetes/csi-nodeplugin-rbac.yaml b/deploy/kubernetes/csi-nodeplugin-rbac.yaml deleted file mode 100644 index 530e067b..00000000 --- a/deploy/kubernetes/csi-nodeplugin-rbac.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# This YAML defines all API objects to create RBAC roles for CSI node plugin -apiVersion: v1 -kind: ServiceAccount -metadata: - name: csi-nodeplugin - ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: csi-nodeplugin -rules: - - apiGroups: [""] - resources: ["persistentvolumes"] - verbs: ["get", "list", "watch", "update"] - - apiGroups: [""] - resources: ["nodes"] - verbs: ["get", "list", "watch", "update"] - - apiGroups: ["storage.k8s.io"] - resources: ["volumeattachments"] - verbs: ["get", "list", "watch", "update"] ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: csi-nodeplugin -subjects: - - kind: ServiceAccount - name: csi-nodeplugin - namespace: default -roleRef: - kind: ClusterRole - name: csi-nodeplugin - apiGroup: rbac.authorization.k8s.io diff --git a/examples/kubernetes/nginx.yaml b/examples/kubernetes/nginx.yaml index 20615ee4..813b8696 100644 --- a/examples/kubernetes/nginx.yaml +++ b/examples/kubernetes/nginx.yaml @@ -38,7 +38,7 @@ metadata: name: nginx spec: containers: - - image: maersk/nginx + - image: nginx name: nginx ports: - containerPort: 80 diff --git a/test/nfs-testdriver.go b/test/nfs-testdriver.go index 22a7d6ae..34755038 100644 --- a/test/nfs-testdriver.go +++ b/test/nfs-testdriver.go @@ -14,7 +14,7 @@ limitations under the License. package test import ( - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/storage/testpatterns" @@ -52,14 +52,9 @@ func initNFSDriver(name string, manifests ...string) testsuites.TestDriver { } } +// InitNFSDriver initialize NFS driver for test func InitNFSDriver() testsuites.TestDriver { - - return initNFSDriver("nfs.csi.k8s.io", - "csi-attacher-nfsplugin.yaml", - "csi-attacher-rbac.yaml", - "csi-nodeplugin-nfsplugin.yaml", - "csi-nodeplugin-rbac.yaml") - + return initNFSDriver("nfs.csi.k8s.io", "csi-nfs-node.yaml") } var _ testsuites.TestDriver = &nfsDriver{}