apiVersion: apps/v1
kind: Deployment
metadata:
  name: inwise
  namespace: edoc2
  labels:
    app: inwise
    k8s-app: inwise
spec:
  selector:
    matchLabels:
      app: inwise
  replicas: 1
  revisionHistoryLimit: 5
  template:
    metadata:
      labels:
        app: inwise
    spec:
      hostname: inwise
      #terminationGracePeriodSeconds: 30
      initContainers:
      - name: increase-vm-max-map
        image: registry.edoc2.com:5001/library/busybox:1.28
        command: ["sysctl", "-w", "vm.max_map_count=655360"]
        securityContext:
          privileged: true
      - name: increase-file-max-map
        image: registry.edoc2.com:5001/library/busybox:1.28
        command: ["sysctl", "-w", "fs.file-max=655360"]
        securityContext:
          privileged: true
      - name: increase-somaxconn-map
        image: registry.edoc2.com:5001/library/busybox:1.28
        command: ["sysctl", "-w", "net.core.somaxconn=38096"]
        securityContext:
          privileged: true
      - name: increase-fd-ulimit
        image: registry.edoc2.com:5001/library/busybox:1.28
        command: ["sh", "-c", "ulimit -n 655360"]
        securityContext:
          privileged: true
      - name: increase-max-connect
        image: registry.edoc2.com:5001/library/busybox:1.28
        command: ["sysctl", "-w", "vm.nr_hugepages=0"]
        securityContext:
          privileged: true
      containers:
      - name: inwise
        image: registry.edoc2.com:5000/edoc2v5/inwise:km-v6.1.0.0
        imagePullPolicy: IfNotPresent
        envFrom:
        - configMapRef:
           name: inwise-envfile
        env:
        - name: INWISE_URL
          value: "http://inwise:8088"
        - name: EDOC2_URL
          value: "http://edoc2"
        - name: EDOC2_USER
          value: "admin"
        - name: EDOC2_PASSWORD
          value: "edoc2edoc2"
        - name: DEBUG
          value: "true"
        - name: INWISE_MEMORY
          value: "-Xms8g -Xmx8g"
        securityContext:
          privileged: true
        ports:
        - containerPort: 7687
          name: inwise7687
          protocol: TCP
        - containerPort: 5432
          name: inwise5432
          protocol: TCP
        - containerPort: 8684
          name: inwise8684
          protocol: TCP
        - containerPort: 7474
          name: inwise7474
          protocol: TCP
        - containerPort: 8088
          name: inwise8088
          protocol: TCP
        - containerPort: 22
          name: inwise22
          protocol: TCP
        #- containerPort: 8784
        #  name: inwise8784
        #  protocol: TCP
        volumeMounts:
        - name: inwise
          mountPath: /data
        #- name: inwisebash
        #  mountPath: /usr/local/start.sh
        #- name: pg
        #  mountPath: /data/pgsql
      restartPolicy: Always
      volumes: 
      - name: inwise
        hostPath:
          path: /home/edoc2/macrowing/edoc2v5/data/inwise
      #- name: inwisebash
      #  hostPath:
      #    path: /home/edoc2/macrowing/edoc2v5/data/inwise/start.sh
      #- name: pg
      #  hostPath:
      #    path: /data/pgdata/pgsql
      nodeSelector:
        node.inwise2.nodelabels: INWISE
---
apiVersion: v1
kind: Service
metadata:
  name: inwise
  namespace: edoc2
  labels:
    app: inwise
spec:
  ports:
  - name: inwise8088
    port: 8088
    targetPort: 8088
    nodePort: 8079
    protocol: TCP
  - name: inwise7687
    port: 7687
    targetPort: 7687
    nodePort: 7687
    protocol: TCP
  - name: inwise5432
    port: 5432
    targetPort: 5432
    nodePort: 35432
    protocol: TCP
  - name: inwise8684
    port: 8684
    targetPort: 8684
    nodePort: 38684
    protocol: TCP
  - name: inwise7474
    port: 7474
    targetPort: 7474
    nodePort: 7474
    protocol: TCP
  - name: inwise22
    port: 22
    targetPort: 22
    nodePort: 8022
    protocol: TCP
  #- name: inwise8784
  #  port: 8784
  #  targetPort: 8784
  #  nodePort: 8784
  #  protocol: TCP
  selector:
    app: inwise
  type: NodePort
