标签:val names -- classname 常用 cas status loopback strong
#1.查询信息 kubectl get [需要查询的服务]
node 节点
componentstatuses 简写 cs 组件状态
namespaces 简写 ns 名命空间
pod pod信息 添加 (-o wide )查看运行节点
service 查询service
deployments --all-namespaces
kind分类查询
all --all-namespaces
查询所有
--all-namespaces 所有命名空间
###将信息输入为yaml格式
kubectl get pod [pod名] -o yaml
nginx-6f858d4d45-sgwdf 1/1 Running 0 3h
[root@k8s-m ~]# kubectl get pod nginx-6f858d4d45-sgwdf -o yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: 2018-09-01T10:01:55Z
generateName: nginx-6f858d4d45-
...省略
#2.删除
1.删除节点
kubectl delete node node1
2.删除pod
kubectl delete pod $(pod_name) -n $(namespace-name)
3.删除services
kubectl delete svc $(svc_name) -n $(namespace-name)
#3.创建
1.创建pod
kubectl create -f create_pod.yaml
2.更新pod
kubectl rolling-update pod_v1 -f pod_v2.yaml
3.回滚
kubectl rolling-update pod_v2 --rollback
1.查询对象详细信息
kubectl describe pod [pod名] -n [所在命名空间]
[root@k8s-m ~]# kubectl describe pod client -n default
Name: client
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: node1/10.0.0.40
Start Time: Sat, 01 Sep 2018 20:12:08 +0800
Labels: run=client
Annotations: <none>
Status: Failed
IP: 10.244.1.5
..........
2.查询日志
kubectl logs -f
[pod名] -n [所在命名空间]
[root@k8s-m ~]# kubectl logs -f client -n default
/ #
/ # ls
bin etc proc sys usr
dev home root tmp var
/ # cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
3: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc noqueue
link/ether 0a:58:0a:f4:01:05 brd ff:ff:ff:ff:ff:ff
inet 10.244.1.5/24 scope global eth0
valid_lft forever preferred_lft forever
.........省略
3.进入容器运行命令,如果pod有多个容器,可用-c指定容器
kubectl exec [pod名称] -c [docker镜像] [执行的命令] -n [命名空间]
[root@k8s-m ~]# kubectl exec nginx-6f858d4d45-sgwdf -c nginx hostname -n default
nginx-6f858d4d45-sgwdf
标签:val names -- classname 常用 cas status loopback strong
原文地址:https://www.cnblogs.com/zhangb8042/p/9571647.html