---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  namespace: edoc2
  labels:
    app: nginx
spec:
  # externalTrafficPolicy: Local
  ports:
    - name: nginx
      port: 80
      targetPort: 80
      protocol: TCP
  #- name: nginx-ssl
  #  port: 443
  #  targetPort: 443
  #  protocol: TCP
  selector:
    app: nginx
  type: ClusterIP
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: nginx
    k8s-app: nginx
  name: nginx
  namespace: edoc2
spec:
  # replicas: 1
  #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.6.0.0-beta
          #imagePullPolicy: Always
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: ng-envfile
          # env:
          # - name: SSL
          #   value: "true"
          # - name: DOMAIN_NAME
          #   value: "changekb.edoc2.com"
          ports:
            - name: nginx
              containerPort: 80
              hostPort: 80
          #- name: nginx-ssl
          #  containerPort: 443
          resources:
            requests:
              cpu: 900m
              memory: 2Gi
            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
