cka 模拟考题十二
Create a new user called john. Grant him access to the cluster.
John should have permission to create, list, get, update and delete pods in the development namespace.
kubectl config use-context kubernetes-admin@kubernetes
{ mkdir ~/userAccount_dir/ ; cd $_ ; }
(umask 077; openssl genrsa -out john.key 2048)
openssl req -new -key john.key -out john.csr -subj "/CN=jemmy/O=Shanghai/O=worker"
openssl x509 -req -in john.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out john.crt -days 365
kubectl config set-credentials john --client-certificate=john.crt --client-key=john.key
kubectl create role john-ro --resource=pods --verb=create,list,get,update,delete --namespace=development
kubectl create rolebinding john-ro-rolebinding --role=john-ro --user=john --namespace=development
k auth can-i get po -n development --as john
k auth can-i delete po -n development --as john
cka 模拟考题十三
Use JSON PATH query to retrieve the architecture of all the nodes and store it in a file /opt/outputs/nodes_architecture.txt
The architecture are under the nodeInfo
section under status
of each node.
kubectl get no --sort-by=.status.capacity.memory
kubectl get no -o jsonpath='{.items[*].status.capacity.memory}'
kubectl get nodes -o jsonpath='{.items[*].status.nodeInfo.architecture}' > /opt/outputs/nodes_architecture.txt
上面的这个网站可以用来练习