pod是容器化的根底,好比大楼的地基。
Pod跟容器的关系
类比一下:
POD: 物理机
容器: 物理机上的一个过程;
容器只是Pod的一个一般字段。
Pod的作用范畴
跟容器的linux namespace相干的货色肯定是Pod级别的,pod。
比方:
网络: hostAliases : 写入/ect/hosts内容 ; sharePrcessNamespace: 共享PID 空间
存储: vlume
平安: secret
调度: NodeSelector 用户指定pod跟node的对应关系 ; NodeName 标识调度过了,可用来调试pod;
Pod的Container元素
containers和initContainers关系
initContainers先于containers创立 ; sidecar实现的重要根底;依照定义的程序来执行;
containers: 容器定义
元素如下:
元素 | 阐明 |
---|---|
image | 镜像地址 |
ports | 端口定义 |
command | 启动指令 |
workingDir | 工作目录 |
volumeMounts | 数据卷挂载 |
imagePullPolicy | 镜像拉取策略 |
lifecycle | 容器生命周期钩子定义 preStop postStart |
Pod的问题定位
通过 spec.status.phase来定位;
pending:创立过程中,因为某些起因调度失败
running: 失常运行中
succeed: 一次性调度胜利
failed: 调度失败
unknow: 未知
还能够联合 condition来定位:
unscheduled: 没有调度
podScheduled: pod调度中
ready: 筹备好
initalized: 初始化中
其它指令
attach: 进入容器的tty 命令行,如果有装置的话;
kubectl attach -it youpodname -c youcontainername
小结
围绕pod的外围字段做了介绍。
示例配置文件:
apiVersion: apps/v1kind: Podmetadata: name: my-podspec: shareProcessNamespace: true nodeSelector: diskType: ssd hostAliases: - ip: "10.10.10.9" hostnames: - "a.b.com" - "ac.b.com" lifecycle: postStart: exec: command: ["/bin/bash","-c","echo 'xxxx'> /usr/share/messages"] preStop: exec: command: ["/usr/sbin/nginx","-t","quit"]
原创不易,关注诚可贵,转发价更高!转载请注明出处,让咱们互通有无,共同进步,欢送沟通交流。