In this step we are going to prepare a user space composed by a kubernetes namespace, some role bindings that allow to deploy containers and finally a configuration file containing the connection data to this user space in the cluster.
- Create the namespace:
kubectl create namespace sample-psp
- Create
role
androlebinding
to allowdefault
service account atsample-psp
namespace to deploy applications in:kubectl apply -f rbac/default-sa-at-example-psp-namespace.yaml
- Create the kubeconfig file to the serviceaccount
default
in thesample-psp
namespace:helper/create_sa_kubeconfig.sh default sample-psp
.
Now you should have the following outputs:
$ ls -a .kube-*
.kube-default-kube-system-conf .kube-default-sample-psp-conf .kube-insecure
$ kubectl get role.rbac.authorization.k8s.io/developer -o yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"rbac.authorization.k8s.io/v1","kind":"Role","metadata":{"annotations":{},"name":"developer","namespace":"default"},"rules":[{"apiGroups":["extensions","apps"],"resources":["deployments","replicasets","ingresses"],"verbs":["*"]},{"apiGroups":[""],"resources":["pods","services"],"verbs":["*"]},{"apiGroups":[""],"resources":["events"],"verbs":["GET","LIST"]}]}
creationTimestamp: "2019-01-23T16:58:29Z"
name: developer
namespace: default
resourceVersion: "26183"
selfLink: /apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/developer
uid: 1bed50f0-1f30-11e9-af0b-9cb6d0e7e121
rules:
- apiGroups:
- extensions
- apps
resources:
- deployments
- replicasets
- ingresses
verbs:
- '*'
- apiGroups:
- ""
resources:
- pods
- services
verbs:
- '*'
- apiGroups:
- ""
resources:
- events
verbs:
- GET
- LIST
$ kubectl get rolebinding.rbac.authorization.k8s.io/developer-at-sample-psp -o yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"rbac.authorization.k8s.io/v1","kind":"RoleBinding","metadata":{"annotations":{},"name":"developer-at-sample-psp","namespace":"default"},"roleRef":{"apiGroup":"","kind":"Role","name":"developer"},"subjects":[{"kind":"ServiceAccount","name":"default"}]}
creationTimestamp: "2019-01-23T16:58:29Z"
name: developer-at-sample-psp
namespace: default
resourceVersion: "26184"
selfLink: /apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/developer-at-sample-psp
uid: 1beeeec3-1f30-11e9-af0b-9cb6d0e7e121
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: developer
subjects:
- kind: ServiceAccount
name: default