Skip to content

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"