k8s common commands
K8S command
http://kubernetes.io/docs/user-guide/kubectl-overview/
//List PODs
[root@localhost vCN]# kubectl get pods
//List replicated replicas
[root@localhost vCN]# kubectl get replicationcontroller
//List replicas
[root@localhost vCN]# kubectl get rc
//List the description of POD, here you can see the correspondence with docker
[root@localhost vCN]# kubectl describe pod cnsend
//services is The outermost unit of Kubernetes
can access our defined Pod resources through a virtual access IP and service port. The current version is implemented through nat forwarding of iptables. The forwarded target port is a random port generated by Kube_proxy
//listed service
[root@localhost vCN]# kubectl get svc
NAME LABELS SELECTOR IP(S) PORT(S)
as-service-nodeport <none> name=as 10.254.38.46 4000/TCP
cnquery app=cnquery app=cnquery 10.254.42.29 8080/TCP
cnreceiver app=cnreceiver app=cnrcv 10.254.183.55 10010/TCP
kubernetes component=apiserver,provider=kubernetes <none> 10.254.0.1 443/TCP
msb-rc name=msb-rc name=msb-rc 10.254.81.154 10080/TCP
mysql app=mysql app=mysql 10.254.100.45 32768/TCP
//获取服务的描述
[root@localhost ~]# kubectl describe service fmadapter-sv-np
kubectl describe pod fm-adapter-controller-r9yb9
kubectl describe service fmadapter-sv-np
//Create and delete services
kubectl create -f mysql-controller.json
kubectl delete -f mysql-controller.json
//Run the command
kubectl in the container exec cnsend-kg0es env
//Print the log of the container in the POD
kubectl logs busybox -c busybox1
//The association between rc and pod
kubectl describe pod 30166149-810b-4f4b-8a21-0ae4a4c0bcdf-1-6q0ur --namespace="xxx "
ubuntu@default-np234:~$ kubectl describe pod 30166149-810b-4f4b-8a21-0ae4a4c0bcdf-1-6q0ur --namespace="xxx"
via Labels:
// get rc
kubectl get rc --namespace=xxx -o wide
NAME DESIRED CURRENT AGE CONTAINER(S) IMAGE(S) SELECTOR
The value of SELECTOR is the same as the previous labels.
//delete pod
kubectl delete rc xxxxxxx --namespace=xxx
//k8s RESTFUL interface
http://10.43.39.11:8080/api/v1/namespaces/default/replicationcontrollers
http://10.43.39.11:8080/api/v1 /namespaces/default/replicationcontrollers/fm-adapter-controller
http://10.43.39.11:8080/api/v1/namespaces/default/pods
http://10.43.39.11:8080/api/v1/namespaces/default/pods /fm-adapter-controller-7porr
http://10.43.39.11:8080/api/v1/nodes
http://10.43.39.11:8080/api/v1/nodes/10.43.39.12
http://10.43.39.11: 8080/api/v1/pods
http://10.43.39.11:8080/api/v1/replicationcontrollers
http://10.43.39.11:8080/api/v1/services
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326704373&siteId=291194637
Recommended
Ranking