Pod配置
基本配置
yaml
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: nginx
image: nginx:1.19
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c"]
args:
- echo "Hello"
workingDir: /app镜像拉取
| 策略 | 说明 |
|---|---|
| Always | 始终拉取最新镜像 |
| IfNotPresent | 本地存在则使用 |
| Never | 只使用本地镜像 |
yaml
imagePullPolicy: Always启动命令
yaml
command: ["/bin/sh", "-c"]
args:
- echo "Starting"
- "-config"
- "/config/app.yaml"环境变量
yaml
env:
- name: APP_ENV
value: "production"
- name: DB_HOST
valueFrom:
configMapKeyRef:
name: my-config
key: database.host端口设置
yaml
ports:
- name: http
containerPort: 80
protocol: TCP资源配额
yaml
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"