Chapter 6 – Securing Kubernetes
You have two virtual machines: master-0
and worker-0
, please complete the following mock scenarios.
Scenario 1
Create a new service account named packt-sa
in a new namespace called packt-ns
.
Use the following command to create a new service account in the targeting namespace:
kubectl create sa packt-sa -n packt-ns
Scenario 2
Create a Role named packt-role
and bind it with the RoleBinding packt-rolebinding
. Map the packt-sa
service account with list
and get
permissions.
Use the following command to create a cluster role in the targeting namespace:
kubectl create role packt-role --verb=get --verb=list --resource=pods --namespace=packt-ns
Use the following command to create a Role binding in the targeting namespace:
kubectl create rolebinding packt-pods-binding --role=packt-role --user=packt-user -- namespace=packt-ns
To achieve the same result, you can create a yamldefinition called packt-role.yaml
:
apiVersion...