11 k8s 考试基础知识(九)

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

JSONPath Online Evaluator

上面的这个网站可以用来练习

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值