Deployment无状态应用编排建议配置项

公众号:yunops

建议 Deployment 基础模版内置的内容:

示例:

HPA、DNSCache、init container、SecurityContext 等配置因环境受限或无此需求暂未添加

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: alan-web
  namespace: mars-prod
  labels:
    app: alan-web
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: alan-web
  template:
    metadata:
      labels:
        app: alan-web
    spec:
      securityContext:
        runAsUser: 1000
        runAsGroup: 3000
        fsGroup: 2000
      imagePullSecrets:
        - name: docker-reg-secret
      containers:
        - name: alan-web
          image: registry.cn-hangzhou.aliyuncs.com/xxx/alan-web:dev-xxx
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: config-prod
          ports:
            - containerPort: 80
              protocol: TCP
          readinessProbe:
            tcpSocket:
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            tcpSocket:
              port: 80
            initialDelaySeconds: 15
            periodSeconds: 20
          resources:
            requests:
              cpu: 0.1
              memory: 128Mi
            limits:
              cpu: 0.2
              memory: 256Mi
          lifecycle:
            preStop:
              exec:
                command: ["/bin/bash", "-c", "sleep 10"]
          securityContext:
            allowPrivilegeEscalation: false