deployment

编写一个nginx deployment

这里我们配置了requests最小资源,和limits最大可用资源,容器内端口,存储、磁盘映射、还有 strategy,我们的滚动更新策略,这里我定义了每次最多更新40%的pod,最多不可用的pod是40%。

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-deploy
  labels:
    run: nginx-deploy
spec:
  replicas: 2
  strategy:
    rollingUpdate:
      maxSurge: 40%
      maxUnavailable: 40%
    type: RollingUpdate
  template:
    metadata:
      labels:
        run: nginx-deploy
    spec:
      containers:
      - name: nginx
        resources:
          limits:
            cpu: 2
            memory: 1Gi
          requests:
            cpu: 1
            memory: 500Mi
        image: nginx
        ports:
        - containerPort: 80
          #hostPort: 80
          protocol: TCP
          name: nginx-port
        volumeMounts:
        - name: tmp
          mountPath: /tmp
          readOnly: true
      volumes:
      - name: tmp
        hostPath:
          path: /tmp