# kubectl常用指令

# 查看某个pod情况

kubectl describe pod {POD}
1

# 进入pod

kubectl exec -it {POD} sh
1

# 创建secret

kubectl create secret docker-registry {key} \
--docker-server={server} --docker-username={username} --docker-password={password}
1
2

# 创建role

 kubectl create role pods-reader --verb=get,list,watch --resource=pods,endpoints --dry-run -o yaml
 kubectl create rolebinding app-api-default-pods-reader --role=pods-reader --namespace=default --dry-run -o yaml > rolebinding.yaml
1
2

kubectl get rolebinding -o yaml app-api-default-pods-reader kubectl describe rolebinding app-api-default-pods-reader

# 查看某个角色

kubectl get role
1

# 查看角色情况

kubectl describe role pods-reader
1

# 执行yaml

kubectl apply -f role-reader.yaml
1

kubectl get rolebinding -o yaml default-sa-resource-reader-binding kubectl get role -o yaml resource-reader

# 集群级别的 角色定义和授权:

kubectl get ClusterRole -o yaml cluster-admin kubectl get clusterRolebinding -o yaml admin

kubectl logs -f user-svc-dp-75985d755b-gntkz

kubectl get ep -o yaml

上次更新: 6/23/2021, 9:12:55 PM