apiVersion: apps/v1
kind: Deployment
metadata:
  name: user-deploy
  labels:
    app: user
    version: v2
spec:
  replicas: 2
  selector:
    matchLabels:
      app: user  #选择 pod label
      version: v2
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: user #标注 pod label
        version: v2
    spec:
      containers:
      - name: user
        image: dockerxpub/eapi:v1.4.0
        imagePullPolicy: Always
        command: ["bash","-c","/eapi -cfgpath=/configs"]
        env:
        # redis
        - name: REDIS_SVC_PASS
          valueFrom:
            configMapKeyRef:
              name: redis-secret
              key: REDIS_PASSWORD
        - name: REDIS_SVC_ADDR
          value: $(REDIS_SVC):6379
        # mysql
        - name: MYSQL_SVC_USER
          valueFrom:
            configMapKeyRef:
              name: mysql-secret
              key: MYSQL_USER
        - name: MYSQL_SVC_PASS
          valueFrom:
            configMapKeyRef:
              name: mysql-secret
              key: MYSQL_PASSWORD
        - name: MYSQL_SVC_DSN
          value: $(MYSQL_SVC_USER):$(MYSQL_SVC_PASS)@tcp($(MYSQL_SVC):3306)/test_db?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8
        ports:
        - containerPort: 8080
        - containerPort: 50051
        volumeMounts:
        - name: user-cfg-vol # 选择 volume
          mountPath: /configs
      volumes:
      - name: user-cfg-vol
        configMap:
          name: cm-user # 选择 configmap
