You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This relies on the "RBAC for Users" documentation, and it generalizes those
steps a bit to make it easier to cut-n-paste them for the flux user case.
Signed-off-by: Dean Roehrich <dean.roehrich@hpe.com>
Copy file name to clipboardExpand all lines: docs/guides/rbac-for-users/readme.md
+72-19Lines changed: 72 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,15 @@ authors: Matt Richerson <matthew.richerson@hpe.com>
3
3
categories: setup
4
4
---
5
5
6
-
# RBAC for Users
6
+
# RBAC: Role-Based Access Control
7
7
8
-
This document shows how to create a kubeconfig file with RBAC set up to restrict access to view only for resources.
8
+
RBAC (Role Based Access Control) determines the operations a user or service can perform on a list of Kubernetes resources. RBAC affects everything that interacts with the kube-apiserver (both users and services internal or external to the cluster). More information about RBAC can be found in the Kubernetes [***documentation***](https://kubernetes.io/docs/reference/access-authn-authz/rbac/).
9
9
10
-
## Overview
10
+
## RBAC for Users
11
11
12
-
RBAC (Role Based Access Control) determines the operations a user or service can perform on a list of Kubernetes resources. RBAC affects everything that interacts with the kube-apiserver (both users and services internal or external to the cluster). More information about RBAC can be found in the Kubernetes [***documentation***](https://kubernetes.io/docs/reference/access-authn-authz/rbac/).
12
+
This section shows how to create a kubeconfig file with RBAC set up to restrict access to view only for resources.
13
+
14
+
### Overview
13
15
14
16
User access to a Kubernetes cluster is defined through a kubeconfig file. This file contains the address of the kube-apiserver as well as the key and certificate for the user. Typically this file is located in `~/.kube/config`. When a kubernetes cluster is created, a config file is generated for the admin that allows unrestricted access to all resources in the cluster. This is the equivalent of `root` on a Linux system.
15
17
@@ -19,46 +21,49 @@ The goal of this document is to create a new kubeconfig file that allows view on
19
21
- Creating a new kubeconfig file
20
22
- Adding RBAC rules for the "hpe" user to allow read access
21
23
22
-
## Generate a Key and Certificate
24
+
###Generate a Key and Certificate
23
25
24
26
The first step is to create a new key and certificate so that HPE employees can authenticate as the "hpe" user. This will likely be done on one of the master nodes. The `openssl` command needs access to the certificate authority file. This is typically located in `/etc/kubernetes/pki`.
25
27
26
28
```bash
27
29
28
30
# make a temporary work space
29
-
mkdir /tmp/hpe
30
-
cd /tmp/hpe
31
+
mkdir /tmp/rabbit
32
+
cd /tmp/rabbit
33
+
34
+
# Create this user
35
+
export USERNAME=hpe
31
36
32
37
# generate a new key
33
-
openssl genrsa -out hpe.key 2048
38
+
openssl genrsa -out rabbit.key 2048
34
39
35
-
# create a certificate signing request for the "hpe" user
After the keys have been generated, a new kubeconfig file can be created for the "hpe" user. The admin kubeconfig `/etc/kubernetes/admin.conf` can be used to determine the cluster name kube-apiserver address.
50
+
After the keys have been generated, a new kubeconfig file can be created for this user. The admin kubeconfig `/etc/kubernetes/admin.conf` can be used to determine the cluster name kube-apiserver address.
46
51
47
52
```bash
48
53
49
54
# create a new kubeconfig with the server information
The kubeconfig file should be placed in a location where HPE employees have read access to it.
60
65
61
-
## Create ClusterRole and ClusterRoleBinding
66
+
###Create ClusterRole and ClusterRoleBinding
62
67
63
68
The next step is to create ClusterRole and ClusterRoleBinding resources. The ClusterRole provided allows viewing all cluster and namespace scoped resources, but disallows creating, deleting, or modifying any resources.
64
69
@@ -92,10 +97,58 @@ roleRef:
92
97
93
98
Both of these resources can be created using the `kubectl apply` command.
94
99
95
-
## Testing
100
+
### Testing
96
101
97
102
Get, List, Create, Delete, and Modify operations can be tested as the "hpe" user by setting the KUBECONFIG environment variable to use the new kubeconfig file. Get and List should be the only allowed operations. Other operations should fail with a "forbidden" error.
98
103
99
104
```bash
100
105
export KUBECONFIG=/tmp/hpe/hpe.conf
101
106
```
107
+
108
+
## RBAC for Workload Manager (WLM)
109
+
110
+
**Note** This section assumes the reader has read and understood the steps described above for setting up `RBAC for Users`.
111
+
112
+
A workload manager (WLM) such as [Flux](https://github.com/flux-framework) or [Slurm](https://slurm.schedmd.com) will interact with [DataWorkflowServices](https://dataworkflowservices.github.io) as a privileged user. RBAC is used to limit the operations that a WLM can perform on a Rabbit system.
113
+
114
+
The following steps are required to create a user and a role for the WLM. In this case, we're creating a user to be used with the Flux WLM:
115
+
116
+
- Generate a new key/cert pair for a "flux" user
117
+
- Creating a new kubeconfig file
118
+
- Adding RBAC rules for the "flux" user to allow appropriate access to the DataWorkflowServices API.
119
+
120
+
### Generate a Key and Certificate
121
+
122
+
Generate a key and certificate for our "flux" user, similar to the way we created one for the "hpe" user above. Substitute "flux" in place of "hpe".
123
+
124
+
### Create a kubeconfig
125
+
126
+
After the keys have been generated, a new kubeconfig file can be created for the "flux" user, similar to the one for the "hpe" user above. Again, substitute "flux" in place of "hpe".
127
+
128
+
### Apply the provided ClusterRole and create a ClusterRoleBinding
129
+
130
+
DataWorkflowServices has already defined the role to be used with WLMs. Simply apply the `workload-manager` ClusterRole from DataWorkflowServices to the system:
0 commit comments