apiVersion: v1
kind: Service
metadata:
  name: humio
  labels:
    run: humio
spec:
  ports:
    - name: zookeeper
      port: 2181
      targetPort: 2181
    - name: kafka
      port: 9092
      targetPort: 9092
    - name: http
      port: 9081
      targetPort: 9081
  selector:
    run: humio
#  type: LoadBalancer
#status:
#  loadBalancer: {}
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: humio-data
spec:
  capacity:
    storage: 10Ti
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain # Keep 4eva
  storageClassName: default
  mountOptions:
    - hard
    - nfsvers=3
  nfs:
    path: /mnt/DroboFS/Shares/Kubernetes/volumes/static/humio-data
    server: 10.42.42.10
  claimRef:
    name: humio-data
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: humio-data
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Ti
status: {}
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: humio-config
spec:
  capacity:
    storage: 5Mi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain # Keep 4eva
  storageClassName: default
  mountOptions:
    - hard
    - nfsvers=3
  nfs:
    path: /mnt/DroboFS/Shares/Kubernetes/volumes/static/humio-config
    server: 10.42.42.10
  claimRef:
    name: humio-config
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: humio-config
  annotations:
    nfs.io/storage-path: "humio-config"
spec:
  storageClassName: default
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Mi
status: {}
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: humio-kafka-data
spec:
  capacity:
    storage: 5Mi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain # Keep 4eva
  storageClassName: default
  mountOptions:
    - hard
    - nfsvers=3
  nfs:
    path: /mnt/DroboFS/Shares/Kubernetes/volumes/static/humio-kafka-data
    server: 10.42.42.10
  claimRef:
    name: humio-kafka-data
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: humio-kafka-data
  annotations:
    nfs.io/storage-path: "humio-kafka-data"
spec:
  storageClassName: default
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Mi
status: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: humio
spec:
  replicas: 1
  selector:
    matchLabels:
      run: humio
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        run: humio
    spec:
      terminationGracePeriodSeconds: 30
      containers:
        - image: krishnarajeshs/humio_arm:v1.0
          imagePullPolicy: "Always"
          name: humio
          env:
            - name: TZ
              value: US/Michigan
            - name: user
              value: root
            - name: HUMIO_PORT
              value: "9081"
            - name: ELASTIC_PORT
              value: "9202"
            - name: ZOOKEEPER_URL
              value: "127.0.0.1:2181"
            - name: KAFKA_SERVERS
              value: "127.0.0.1:9092"
            - name: EXTERNAL_URL
              value: "http://127.0.0.1:9081"
            - name: PUBLIC_URL
              value: "https://humio.monkeybox.org"
            - name: HUMIO_SOCKET_BIND
              value: "0.0.0.0"
            - name: HUMIO_HTTP_BIND
              value: "0.0.0.0"
            - name: HUMIO_JVM_ARGS
              value: "-Xss2M"
          ports:
            - containerPort: 2181
            - containerPort: 9092
            - containerPort: 9081
          resources:
            limits:
              memory: "4096Mi"
              cpu: "2000m"
            requests:
              memory: "500Mi"
              cpu: "1000m"
          volumeMounts:
            - mountPath: /opt/humio/data
              name: humio-data
            - mountPath: /opt/humio/config
              name: humio-config
            - mountPath: /opt/humio/data/kafka-data
              name: humio-kafka-data
      restartPolicy: Always
      volumes:
        - name: humio-config
          persistentVolumeClaim:
            claimName: humio-config
        - name: humio-data
          persistentVolumeClaim:
            claimName: humio-data
        - name: humio-kafka-data
          persistentVolumeClaim:
            claimName: humio-kafka-data
#      dnsPolicy: "None"
#      dnsConfig:
#        nameservers:
#          - 10.42.42.239
#          - 10.42.42.1
#        searches:
#          - default.svc.cluster.local
#          - svc.cluster.local 
#          - cluster.local
#        options:
#          - name: ndots
#            value: "2"
#          - name: edns0
#          - name: trust-ad
status: {}
---
# Hosting
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: humio-ingress
  annotations:
    cert-manager.io/cluster-issuer: "letsencrypt-stage"
    ## No basic auth for humio
    ## type of authentication
    #nginx.ingress.kubernetes.io/auth-type: basic
    ## name of the secret that contains the user/password definitions
    #nginx.ingress.kubernetes.io/auth-secret: basic-auth
    ## message to display with an appropriate context why the authentication is required
    #nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - Octoprint'
spec:
  tls:
  - hosts:
    - humio.monkeybox.org
    secretName: humio-tls
  rules:
  - host: humio.monkeybox.org
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: humio
            port:
              number: 9081
