Distribute Role+Rolebinding everywhere instead of giving cluster-scoped endpoints r/w
(cherry picked from commit 7df14ef767)
			
			
This commit is contained in:
		
							parent
							
								
									4a7e7c46a2
								
							
						
					
					
						commit
						c4a7e76517
					
				
							
								
								
									
										20
									
								
								README.md
								
								
								
								
							
							
						
						
									
										20
									
								
								README.md
								
								
								
								
							|  | @ -14,15 +14,15 @@ To note again, you must *already* have an NFS Server. | ||||||
| 
 | 
 | ||||||
| Get all of the files in the [deploy](https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client/deploy) directory of this repository. These instructions assume that you have cloned the [external-storage](https://github.com/kubernetes-incubator/external-storage) repository and have a bash-shell open in the ``nfs-client`` directory. | Get all of the files in the [deploy](https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client/deploy) directory of this repository. These instructions assume that you have cloned the [external-storage](https://github.com/kubernetes-incubator/external-storage) repository and have a bash-shell open in the ``nfs-client`` directory. | ||||||
| 
 | 
 | ||||||
| **Step 3: Setup authorization**. If your cluster has RBAC enabled or you are running OpenShift you must authorize the provisioner. If you are in a namespace/project other than "default" either edit `deploy/auth/clusterrolebinding.yaml` or edit the `oadm policy` command accordingly. | **Step 3: Setup authorization**. If your cluster has RBAC enabled or you are running OpenShift you must authorize the provisioner. If you are in a namespace/project other than "default" edit `deploy/rbac.yaml`. | ||||||
| 
 | 
 | ||||||
| Kubernetes: | Kubernetes: | ||||||
| 
 | 
 | ||||||
| ```sh | ```sh | ||||||
| $ kubectl create -f deploy/auth/serviceaccount.yaml -f deploy/auth/clusterrole.yaml -f deploy/auth/clusterrolebinding.yaml | # Set the subject of the RBAC objects to the current namespace where the provisioner is being deployed | ||||||
| serviceaccount "nfs-client-provisioner" created | $ NAMESPACE=`oc project -q` | ||||||
| clusterrole "nfs-client-provisioner-runner" created | $ sed -i'' "s/namespace:.*/namespace: $NAMESPACE/g" ./deploy/rbac.yaml | ||||||
| clusterrolebinding "run-nfs-client-provisioner" created | $ kubectl create -f deploy/rbac.yaml | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| OpenShift: | OpenShift: | ||||||
|  | @ -30,11 +30,11 @@ OpenShift: | ||||||
| On some installations of OpenShift the default admin user does not have cluster-admin permissions. If these commands fail refer to the OpenShift documentation for **User and Role Management** or contact your OpenShift provider to help you grant the right permissions to your admin user.  | On some installations of OpenShift the default admin user does not have cluster-admin permissions. If these commands fail refer to the OpenShift documentation for **User and Role Management** or contact your OpenShift provider to help you grant the right permissions to your admin user.  | ||||||
| 
 | 
 | ||||||
| ```sh | ```sh | ||||||
| $ oc create -f deploy/auth/openshift-clusterrole.yaml -f deploy/auth/serviceaccount.yaml | # Set the subject of the RBAC objects to the current namespace where the provisioner is being deployed | ||||||
| serviceaccount "nfs-client-provisioner" created | $ NAMESPACE=`oc project -q` | ||||||
| clusterrole "nfs-client-provisioner-runner" created | $ sed -i'' "s/namespace:.*/namespace: $NAMESPACE/g" ./deploy/rbac.yaml | ||||||
| $ oadm policy add-scc-to-user hostmount-anyuid system:serviceaccount:default:nfs-client-provisioner | $ oc create -f deploy/rbac.yaml | ||||||
| $ oadm policy add-cluster-role-to-user nfs-client-provisioner-runner system:serviceaccount:default:nfs-client-provisioner | $ oadm policy add-scc-to-user hostmount-anyuid system:serviceaccount:$NAMESPACE:nfs-client-provisioner | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| **Step 4: Configure the NFS-Client provisioner** | **Step 4: Configure the NFS-Client provisioner** | ||||||
|  |  | ||||||
|  | @ -1,20 +0,0 @@ | ||||||
| kind: ClusterRole |  | ||||||
| apiVersion: rbac.authorization.k8s.io/v1 |  | ||||||
| metadata: |  | ||||||
|   name: nfs-client-provisioner-runner |  | ||||||
| rules: |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["persistentvolumes"] |  | ||||||
|     verbs: ["get", "list", "watch", "create", "delete"] |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["persistentvolumeclaims"] |  | ||||||
|     verbs: ["get", "list", "watch", "update"] |  | ||||||
|   - apiGroups: ["storage.k8s.io"] |  | ||||||
|     resources: ["storageclasses"] |  | ||||||
|     verbs: ["get", "list", "watch"] |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["events"] |  | ||||||
|     verbs: ["create", "update", "patch"] |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["endpoints"] |  | ||||||
|     verbs: ["get", "list", "watch", "create", "update", "patch"] |  | ||||||
|  | @ -1,12 +0,0 @@ | ||||||
| kind: ClusterRoleBinding |  | ||||||
| apiVersion: rbac.authorization.k8s.io/v1 |  | ||||||
| metadata: |  | ||||||
|   name: run-nfs-client-provisioner |  | ||||||
| subjects: |  | ||||||
|   - kind: ServiceAccount |  | ||||||
|     name: nfs-client-provisioner |  | ||||||
|     namespace: default |  | ||||||
| roleRef: |  | ||||||
|   kind: ClusterRole |  | ||||||
|   name: nfs-client-provisioner-runner |  | ||||||
|   apiGroup: rbac.authorization.k8s.io |  | ||||||
|  | @ -1,20 +0,0 @@ | ||||||
| kind: ClusterRole |  | ||||||
| apiVersion: v1 |  | ||||||
| metadata: |  | ||||||
|   name: nfs-client-provisioner-runner |  | ||||||
| rules: |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["persistentvolumes"] |  | ||||||
|     verbs: ["get", "list", "watch", "create", "delete"] |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["persistentvolumeclaims"] |  | ||||||
|     verbs: ["get", "list", "watch", "update"] |  | ||||||
|   - apiGroups: ["storage.k8s.io"] |  | ||||||
|     resources: ["storageclasses"] |  | ||||||
|     verbs: ["get", "list", "watch"] |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["events"] |  | ||||||
|     verbs: ["create", "update", "patch"] |  | ||||||
|   - apiGroups: [""] |  | ||||||
|     resources: ["endpoints"] |  | ||||||
|     verbs: ["get", "list", "watch", "create", "update", "patch"] |  | ||||||
|  | @ -1,4 +0,0 @@ | ||||||
| apiVersion: v1 |  | ||||||
| kind: ServiceAccount |  | ||||||
| metadata: |  | ||||||
|   name: nfs-client-provisioner |  | ||||||
|  | @ -1,3 +1,8 @@ | ||||||
|  | apiVersion: v1 | ||||||
|  | kind: ServiceAccount | ||||||
|  | metadata: | ||||||
|  |   name: nfs-client-provisioner | ||||||
|  | --- | ||||||
| kind: Deployment | kind: Deployment | ||||||
| apiVersion: extensions/v1beta1 | apiVersion: extensions/v1beta1 | ||||||
| metadata: | metadata: | ||||||
|  |  | ||||||
|  | @ -1,3 +1,8 @@ | ||||||
|  | apiVersion: v1 | ||||||
|  | kind: ServiceAccount | ||||||
|  | metadata: | ||||||
|  |   name: nfs-client-provisioner | ||||||
|  | --- | ||||||
| kind: Deployment | kind: Deployment | ||||||
| apiVersion: extensions/v1beta1 | apiVersion: extensions/v1beta1 | ||||||
| metadata: | metadata: | ||||||
|  |  | ||||||
|  | @ -0,0 +1,54 @@ | ||||||
|  | kind: ClusterRole | ||||||
|  | apiVersion: rbac.authorization.k8s.io/v1 | ||||||
|  | metadata: | ||||||
|  |   name: nfs-client-provisioner-runner | ||||||
|  | rules: | ||||||
|  |   - apiGroups: [""] | ||||||
|  |     resources: ["persistentvolumes"] | ||||||
|  |     verbs: ["get", "list", "watch", "create", "delete"] | ||||||
|  |   - apiGroups: [""] | ||||||
|  |     resources: ["persistentvolumeclaims"] | ||||||
|  |     verbs: ["get", "list", "watch", "update"] | ||||||
|  |   - apiGroups: ["storage.k8s.io"] | ||||||
|  |     resources: ["storageclasses"] | ||||||
|  |     verbs: ["get", "list", "watch"] | ||||||
|  |   - apiGroups: [""] | ||||||
|  |     resources: ["events"] | ||||||
|  |     verbs: ["create", "update", "patch"] | ||||||
|  |   - apiGroups: [""] | ||||||
|  | --- | ||||||
|  | kind: ClusterRoleBinding | ||||||
|  | apiVersion: rbac.authorization.k8s.io/v1 | ||||||
|  | metadata: | ||||||
|  |   name: run-nfs-client-provisioner | ||||||
|  | subjects: | ||||||
|  |   - kind: ServiceAccount | ||||||
|  |     name: nfs-client-provisioner | ||||||
|  |     namespace: default | ||||||
|  | roleRef: | ||||||
|  |   kind: ClusterRole | ||||||
|  |   name: nfs-client-provisioner-runner | ||||||
|  |   apiGroup: rbac.authorization.k8s.io | ||||||
|  | --- | ||||||
|  | kind: Role | ||||||
|  | apiVersion: rbac.authorization.k8s.io/v1 | ||||||
|  | metadata: | ||||||
|  |   name: leader-locking-nfs-client-provisioner | ||||||
|  | rules: | ||||||
|  |   - apiGroups: [""] | ||||||
|  |     resources: ["endpoints"] | ||||||
|  |     verbs: ["get", "list", "watch", "create", "update", "patch"] | ||||||
|  | --- | ||||||
|  | kind: RoleBinding | ||||||
|  | apiVersion: rbac.authorization.k8s.io/v1 | ||||||
|  | metadata: | ||||||
|  |   name: leader-locking-nfs-client-provisioner | ||||||
|  | subjects: | ||||||
|  |   - kind: ServiceAccount | ||||||
|  |     name: nfs-client-provisioner | ||||||
|  |     # replace with namespace where provisioner is deployed | ||||||
|  |     namespace: default | ||||||
|  | roleRef: | ||||||
|  |   kind: Role | ||||||
|  |   name: leader-locking-nfs-client-provisioner | ||||||
|  |   apiGroup: rbac.authorization.k8s.io | ||||||
		Loading…
	
		Reference in New Issue