---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: logstash
  namespace: elasticsearch
spec:
  replicas: 2
  selector:
    matchLabels:
      app: logstash
  template:
    metadata:
      labels:
        app: logstash
    spec:
      containers:
      - name: logstash
        image: docker.io/bitnami/logstash:7.17.0
        # Customize environment variables and command-line args as needed
        env:
        - name: ELASTICSEARCH_HOST
          value: "elasticsearch-ha-es-http"  # Adjust based on your ES service DNS name
        ports:
        - containerPort: 9600
        volumeMounts:
        - name: logstash-data
          mountPath: /bitnami
      volumes:
      - name: logstash-data
        persistentVolumeClaim:
          claimName: logstash-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: logstash-pvc
  namespace: elasticsearch
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
  name: logstash
  namespace: elasticsearch
spec:
  selector:
    app: logstash
  ports:
    - protocol: TCP
      port: 9600
      targetPort: 9600
