一、背景说明

在K8s部署项目时,需要提供一份Deployment配置文件,一下提供一份配置文件的示例,后续继续补充完善。

二、Deployment配置文件

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations: {}
  labels:
    app: msmp-mt-server
    k8s.kuboard.cn/name: msmp-mt-server-deployment
  name: msmp-mt-server-deployment
  namespace: hw-msmp
  resourceVersion: '10843811'
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: msmp-mt-server
      env: dev
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/restartedAt: '2023-11-03T17:39:17+08:00'
      creationTimestamp: null
      labels:
        app: msmp-mt-server
        env: dev
    spec:
      containers:
        - env:
            - name: TZ
              value: Asia/Shanghai
          image: 'harbor.mos.com/hw/mt-server:v4.0.7'
          imagePullPolicy: Always
          name: msmp-mt-server
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          resources:
            limits:
              cpu: '16'
              memory: 32Gi
            requests:
              cpu: '2'
              memory: 4Gi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /root/mt-server/cache
              name: cache
              subPath: cache
            - mountPath: /root/mt-server/logs
              name: cache
              subPath: logs
      dnsPolicy: ClusterFirst
      nodeName: host-172.16.1.113
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - configMap:
            defaultMode: 420
            name: hw2-msmp-config
          name: config-volume
        - hostPath:
            path: /home/msmp/
            type: ''
          name: cache