@(kernetes虚拟化学习)[pod基本操作]

pod基本操作

创建Pod

kubectl create -f test_pod.yaml

查询Pod

kubectl get pod my-pod
kubectl get pod busybox
NAME READY STATUS RESTARTS AGE
busybox 0/1 ContainerCreating 0 18h

查询显示字段含义

  • NAME: Pod的名称
  • READY: Pod的准备状况,右边的数字表示Pod包含的容器总数目,左边的数字表示准备就绪的容器数目。
  • STATUS: Pod的状态。
  • RESTARTS: Pod的重启次数
  • AGE: Pod的运行时间。

 pod的准备状况指的是Pod是否准备就绪以接收请求,Pod的准备状况取决于容器,即所有容器都准备就绪了,Pod才准备就绪。这时候kubernetes的代理服务才会添加Pod作为分发后端,而一旦Pod的准备状况变为false(至少一个容器的准备状况为false),kubernetes会将Pod从代理服务的分发后端移除,即不会分发请求给该Pod。

kubectl get pod busybox   --output json # 使用JSON格式显示Pod的完整信息

kubectl get pod busybox --output yaml # 使用YAML方式显示Pod的完整信息

kubectl get支持以Go Template方式过滤指定的信息,比如查询Pod的运行状态

kubectl get pods busybox --output=go-template --template={{.status.phase}}
Running

查看kubectl describe 支持查询Pod的状态和生命周期事件:

[root@k8s-master ~]# kubectl describe   pod  busybox
Name: busybox
Namespace: default
Node: k8s-node-1/116.196.105.133
Start Time: Thu, 22 Mar 2018 09:51:35 +0800
Labels: name=busybox
role=master
Status: Pending
IP:
Controllers: <none>
Containers:
busybox:
Container ID:
Image: docker.io/busybox
Image ID:
Port:
Command:
sleep
360000
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
7m 7m 1 {default-scheduler } Normal Scheduled Successfully assigne
d busybox to k8s-node-1 7m 1m 6 {kubelet k8s-node-1} Warning FailedSync Error syncing pod, s
kipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)"
6m 13s 27 {kubelet k8s-node-1} Warning FailedSync Error syncing pod, skipping: failed to "StartContain
er" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""
  • Name: Pod的名称
  • Namespace: Pod的Namespace。
  • Image(s): Pod使用的镜像
  • Node: Pod所在的Node。
  • Start Time: Pod的起始时间
  • Labels: Pod的Label。
  • Status: Pod的状态。
  • Reason: Pod处于当前状态的原因。
  • Message: Pod处于当前状态的信息。
  • IP: Pod的PodIP
  • Replication Controllers: Pod对应的Replication Controller。
  • Containers:Pod中容器的信息
  • Container ID: 容器的ID。
  • Image: 容器的镜像
  • Image ID:镜像的ID。
  • State: 容器的状态。
  • Ready: 容器的准备状况(true表示准备就绪)。
  • Restart Count: 容器的重启次数统计。
  • Environment Variables: 容器的环境变量。

    Conditions: Pod的条件,包含Pod准备状况(true表示准备就绪)

    Volumes: Pod的数据卷。

    Events: 与Pod相关的事件列表。

删除Pod

可以通过kubectl delete命令删除Pod:

kubectl delete pod busybox

批量删除

kubectl delete pod -all

更新Pod

Pod在创建以后希望更新Pod,可以在修改Pod的定义文件后执行:

kubectl replace /path/to/busybox.yaml

因为Pod的很多属性是没办法修改的,比如容器镜像,这时候可以用kubectl replace命令设置--force参数,等效于重新建Pod。

最新文章

  1. 未能正确加载 ”Microsoft.VisualStudio.Editor.Implementation.EditorPackate“包错误解决方法
  2. 【shell】条件判断式
  3. TP-Link访问策略
  4. iphone/ipad关于size, frame and bounds总结和UIScroll view学习笔记
  5. 制作越狱版本的ipa文件
  6. SQL_UNPIVOT(行列转换)
  7. Problem A Where is the Marble?(查找排序)
  8. 搭建python集成开发环境.
  9. 在Android上实现SSL握手(客户端需要密钥和证书),实现服务器和客户端之间Socket交互
  10. Java实现邮箱发送验证码
  11. 开放源代码的设计层面框架Spring——day02
  12. 为s5pv210烧录镜像
  13. js打断点
  14. 设计模式のAdapterPattern(适配器模式)----结构模式
  15. js处理异步的几种方式
  16. Ant Design 日期选择组件RangePicker 选择时间范围后计算范围内的天数。
  17. CentOS 7 之 Docker 安装及操作命令
  18. 让人抓狂的MySQL安装-8.0.12版本
  19. Rpgmaker开发心得(1)且事件
  20. hdu-4417-主席树+离线

热门文章

  1. swing JCheckBox 更换复选框样式
  2. Entity Framework Code-First(23):Entity Framework Power Tools
  3. Required plugin could not be found. Videos requires to install plugins to play files of the following types : MPEG-4-AAC decoder and H.264 decoder
  4. 【Android开源】CircleImageView自定义圆形控件的使用
  5. Java50道经典习题-程序38 求字符串长度
  6. PDG科普篇
  7. ChineseLunisolarCalendar 农历日期
  8. python---信用卡ATM
  9. 小程序开发笔记【二】,抽奖结果json数据拼装bug解决
  10. 【转】如何恶搞朋友的电脑?超简单的vbs代码