apiVersion: v1 #api文档版本
kind: Pod # 资源类型 Deployment,StatefulSet之类
metadata: #pod元数据 描述信息
name: nginx-demo
labels:
type: app #自定义标签
version: 1.0.0 # 自定义pod版本
namespace: 'default'
spec: #期望Pod按照这里的描述创建
containers:
- name: nginx #容器名称
image: nginx:1.7.9 #版本
imagePullPolicy: IfNotPresent #镜像拉取策略
startupProbe: #1. 应用启动探针检测
httpGet: #探测方式
path: /index.html
port: 80
failureThreshold: 3 #重试次数
periodSeconds: 10 #间隔时间
successThreshold: 1 #检测成功的次数
timeoutSeconds: 5 #超时时间
command: #制定容器启动执行的命令
- nginx
- -g
- 'daemon off;'
workingDir: /usr/share/nginx/html #容器启动工作目录
ports:
- name: http
containerPort: 80
protocol: TCP
env: # 环境变量
- name: JVM_OPTS
value: '-Xms128m -Xmx128m'
resources:
requests:
cpu: 100m # cpu次用 0.1个核心 %10
memory: 128Mi #内存限制
limits: #最大限制
cpu: 200m #0.2个核心
memory: 256Mi
restartPolicy: OnFailure # 重启策略
执行命令: kubectl create -f nginx.yaml
查看命令 kubctl get po -n wide
查看详细信息命令: kubectl describe po nginx-demo