创建一个Pod
# kubectl run pod名称 --image=镜像名称
删除Pod
# kubectl delete pod Pod名称
查看Pod
查看默认ns中pod
# kubectl get pod
查看指定ns中的pod
# kubectl get pod -n 名称空间
查询所有空间的Pod
kubectl get pod -A
kubectl get pods -A
查看Pod的运行日志
# kubectl logs Pod名称
查看Pod描述信息
# kubectl describe pod mynginxpod
查看Pod的ip信息
# kubectl get pod -owide
2.Yaml文件操作
2.1文件准备
单容器
# vi mynginx.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: mynginx
name: mynginx
# namespace: default #默认是default空间
spec:
containers:
- image: nginx
name: mynginx
多容器
# vi myapp.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: myapp
name: myapp
spec:
containers:
- image: nginx
name: nginx
- image: tomcat:8.5.68
name: tomcat
2.2命令
创建启动Pod
kubectl apply -f mynginx.yaml
kubectl apply -f myapp.yaml
删除Pod
kubectl delete -f mynginx.yaml
kubectl delete -f myapp.yaml