K8S命令
http://kubernetes.io/docs/user-guide/kubectl-overview/
//列出POD
# kubectl get pods
//列出复制的副本
# kubectl get replicationcontroller
//列出复制品
# kubectl get rc
//列出POD的描述,这里可以看到与docker的对应关系
# kubectl describe pod cnsend
//services是Kubernetes最外围的单元,通过虚拟一个访问IP及服务端口,
可以访问我们定义好的Pod资源,目前的版本是通过iptables的nat转发来实现,转发的目标端口为Kube_proxy生成的随机端口
//列出服务
# 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
//获取服务的描述
# kubectl describe service fmadapter-sv-np
kubectl describe pod fm-adapter-controller-r9yb9
kubectl describe service fmadapter-sv-np
//创建以及删除服务
kubectl create -f mysql-controller.json
kubectl delete -f mysql-controller.json
//在容器中运行命令
kubectl exec cnsend-kg0es env
//打印在POD中的容器的日志
kubectl logs busybox -c busybox1
//rc与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"
通过 Labels:
//得到rc
kubectl get rc --namespace=xxx -o wide
NAME DESIRED CURRENT AGE CONTAINER(S) IMAGE(S) SELECTOR
SELECTOR 的值与前面的labels一致。
//删除pod
kubectl delete rc xxxxxxx --namespace=xxx
//k8s RESTFUL接口
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
http://kubernetes.io/docs/user-guide/kubectl-overview/
//列出POD
# kubectl get pods
//列出复制的副本
# kubectl get replicationcontroller
//列出复制品
# kubectl get rc
//列出POD的描述,这里可以看到与docker的对应关系
# kubectl describe pod cnsend
//services是Kubernetes最外围的单元,通过虚拟一个访问IP及服务端口,
可以访问我们定义好的Pod资源,目前的版本是通过iptables的nat转发来实现,转发的目标端口为Kube_proxy生成的随机端口
//列出服务
# 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
//获取服务的描述
# kubectl describe service fmadapter-sv-np
kubectl describe pod fm-adapter-controller-r9yb9
kubectl describe service fmadapter-sv-np
//创建以及删除服务
kubectl create -f mysql-controller.json
kubectl delete -f mysql-controller.json
//在容器中运行命令
kubectl exec cnsend-kg0es env
//打印在POD中的容器的日志
kubectl logs busybox -c busybox1
//rc与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"
通过 Labels:
//得到rc
kubectl get rc --namespace=xxx -o wide
NAME DESIRED CURRENT AGE CONTAINER(S) IMAGE(S) SELECTOR
SELECTOR 的值与前面的labels一致。
//删除pod
kubectl delete rc xxxxxxx --namespace=xxx
//k8s RESTFUL接口
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