---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  namespace: edoc2
  labels:
    app: nginx
spec:
  externalTrafficPolicy: Local
  ports:
  - name: nginx
    port: 80
    targetPort: 80
    nodePort: 30179
    protocol: TCP
  selector:
    app: nginx
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment 
metadata:
  labels:
    app: nginx
    k8s-app: nginx
  name: nginx
  namespace: edoc2
spec:
  replicas: 3
  #revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      hostname: nginx
      terminationGracePeriodSeconds: 60
      containers:
      - name: nginx-container
        image: registry.edoc2.com:5000/edoc2v5/nginx:inbiz-v6.3.0.0
        #imagePullPolicy: Always
        imagePullPolicy: IfNotPresent
        envFrom:
        - configMapRef:
            name: envfile
        #- name: SSL
        #  value: "true"
        #- name: DOMAIN_NAME
        #  value: ab.edoc2.co
        ports:
        - name: nginx
          containerPort: 80
        resources:
          requests:
            cpu: 600m
            memory: 1Gi
          limits:
            cpu: 2000m
            memory: 4Gi
#        volumeMounts:
#        - name: nginx-transport-config
#          mountPath: /opt/nginx/nginx-transport-config.sh
#          subPath: nginx-transport-config.sh
#        - name: nginx-edoc2-config
#          mountPath: /opt/nginx/nginx-edoc2-config.sh
#          subPath: nginx-edoc2-config.sh
#        - name: nginx-inbiz-config
#          mountPath: /opt/nginx/nginx-inbiz-config.sh
#          subPath: nginx-inbiz-config.sh
        livenessProbe:
          exec:
            command: ["bash","/opt/nginx/check.sh"]
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 3         # 检测时间间隔
          failureThreshold: 5       # 检测失败5次表示未就绪     
          successThreshold: 1       # 检查成功为2次表示就绪
        #volumeMounts:
        #- name: nginx-tls
        #  mountPath: /etc/nginx/cert
      restartPolicy: Always
      #volumes:
      #- name: nginx-tls
      #  secret:
      #    secretName: nginx-tls
#      volumes:
#        - name: nginx-transport-config
#          configMap:
#            defaultMode: 493
#            name: nginx-conf
#            items:
#              - key: nginx-transport-config.sh
#                path: nginx-transport-config.sh
#        - name: nginx-edoc2-config
#          configMap:
#            defaultMode: 493
#            name: nginx-conf
#            items:
#              - key: nginx-edoc2-config.sh
#                path: nginx-edoc2-config.sh
#        - name: nginx-inbiz-config
#          configMap:
#            defaultMode: 493
#            name: nginx-conf
#            items:
#              - key: nginx-inbiz-config.sh
#                path: nginx-inbiz-config.sh
      nodeSelector:
        node.drive.nodelabels: InDrive
