Kubernetes Commands
Print the address of the control plane and cluster services
kubectl cluster-info
Get output from running pod mypod using the first container by default
kubectl attach mypod
Get output from ruby-container from pod mypod
kubectl attach mypod -c ruby-container
Get output from the first pod of a ReplicaSet named nginx
kubectl attach rs/nginx
Switch to raw terminal mode, sends stdin to "bash" in ruby-container from pod mypod # and sends stdout/stderr from "bash" back to the client
kubectl attach mypod -c ruby-container -i -t
Check to see if I can create pods in any namespace
kubectl auth can-i create pod --all-namespaces
Check to see if I can access the URL /logs
kubectl auth can-i get /logs
Check to if I can read pod logs
kubectl auth can-i list jobs.batch/bar -n foo
Check to see if I can do everything in my current namespace ("*" means all)
kubectl auth can-i '*' '*'
Create a ClusterRoleBinding for user1, user2 and group1 using the cluster-admin ClusterRole
kubectl create clusterrolebinding cluster-admin --clusterrole=cluster-admin --user=user1 --user2=user2 --group=group1
Create a ClusterRole named "pod-reader" that allows user to perform "get", "watch" and "list" on pods
kubectl create clusterrole pod-reader --berb=get, list,watch --resource=pods
Create a ClusterRole name "foo" with NonResouceURL specified
kubectl creat clusterrole "foo" --verb=get --non-resource-url=/logs/*
Create a ClusterRole named "foo" with API Group Specific
Kubectl create clusterrole foo --verb=get, list, watch --resource=rs.extensions
----------------
# kubectl create -f deployment.yaml
# kubectl get deployments
# kubectl get pods
# kubectl describe deployment my-deployment
# kubectl get all
--------
=> Services - NodePort
# kubectl create -f service-definition.yml
Service "myapp-service" created
# kubectl get services
Comments
Post a Comment