apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: elasticsearch
  labels:
    app.kubernetes.io/name: elasticsearch
spec:
  serviceName: elasticsearch
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: elasticsearch
  template:
    metadata:
      labels:
        app.kubernetes.io/name: elasticsearch
    spec:
      containers:
        - image: elasticsearch:7.17.3
          name: elasticsearch
          ports: # A kontener ket portot is publikal (9200-at hasznaljuk a 9300 az Elasticsearch klaszterezesehez kellene)
            - containerPort: 9200
              name: db
              protocol: TCP
            - containerPort: 9300
              name: transport
              protocol: TCP
          volumeMounts: # Kontenerbe becsatolt volume
            - name: elasticsearch-data # Hivatkozas a volume nevere
              mountPath: /usr/share/elasticsearch/data
          env: # Kornyezeti valtozok
            - name: cluster.name
              value: elasticsearch
            - name: node.name
              value: elasticsearch
            - name: discovery.type
              value: single-node
            - name: ES_JAVA_OPTS
              value: "-Xms256m -Xmx256m"
      initContainers: # A fent definialt kontener indulasa elott lefuto kontenerek; kornyezetet inicializaljak
        - name: set-max-map-count
          image: alpine:3.6
          command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
          securityContext:
            privileged: true
        - name: increase-ulimit
          image: alpine:3.6
          command: ["sh", "-c", "ulimit -n 65536"]
          securityContext:
            privileged: true
  volumeClaimTemplates: # Automatikusan keszul egy PVC, amit a kornyezet fog biztositani
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 2Gi