Multi-user MicroK8s
In some circumstances, it may be desirable to have a degree of user-isolation, e.g. when multiple users are accessing a MicroK8s cluster. MicroK8s is a full implementation of Kubernetes, and therefore any existing strategy for handling multiple users can be applied. There is extensive upstream documentation relating to managing users.
As a guide though, the following steps are recommended.
- Enable Role Based Access Control (RBAC):
- If required, create a specific namespace for the user (in this case, ‘alice’) by generating and applying a namespace object such as:
namespace.json:
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"name": "alice",
"labels": {
}
}
}
- Create and apply a rolebinding
E.g to access pods:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["get", "watch", "list"]
To bind role this role to the user, run:
- Install
kubectl
This installs a standalone version of the kubectl
command, which can be used
instead of the built-in MicroK8s version of kubectl.
- Authenticate the user.
- Create a local kubectl config
You can run the command:
…to output the contents of the configuration file used by MicroK8s. This can be used as the basis for a user config file - bear in mind that the user information and the authentication should be matched to the user and the authentication method used.
Last updated 8 months ago. .