apiVersion: v1
kind: Service
metadata:
  name: kibana-service
  namespace: logharbour
spec:
  selector:
    app: kibana
  type: NodePort
  ports:
    - protocol: TCP
      port: 5601
      targetPort: 5601
      nodePort: 30005
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kibana
  namespace: logharbour
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kibana
  template:
    metadata:
      labels:
        app: kibana
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "5601"
    spec:
      containers:
        - name: kibana
          image: private-repo:5000/kibana:8.11.1
          lifecycle:
            postStart:
              exec:
                command:
                - "/bin/sh"
                - "-c"
                - |
                  chown -R kibana:kibana /usr/share/kibana/config
                  chmod -R 755 /usr/share/kibana/config
          ports:
            - containerPort: 5601
              name: http
              protocol: TCP
          envFrom:
          - configMapRef:
              name: kibana-config
          #env:
            #- name: ELASTICSEARCH_URL
            #  value: http://elasticsearch.logharbour.svc.cluster.local:9200  # Update with your Elasticsearch service name
            #- name: ELASTICSEARCH_USERNAME
            #  value: "remiges"
            #- name: ELASTICSEARCH_PASSWORD
            #  value: "rem@cloud9"
          volumeMounts:
            - mountPath: "/usr/share/kibana/data"
              name: kibana-pv-volume
      volumes:
        - name: kibana-pv-volume
          persistentVolumeClaim:
            claimName: kibana-pv-claim
      nodeSelector:
        name: node-1

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: kibana-pv-volume
  namespace: logharbour
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/kra-data/data/dev/kibana-data"

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: kibana-pv-claim
  namespace: logharbour
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
