Adding S3 Credentials to Elasticsearch Managed by eck-operator

You can do this easily with an initContainer 😀

yaml
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: elasticsearch
  ...
  ...
spec:
  version: 8.11.3
  nodeSets:
  - name: master-nodes
    config:
      node.roles: ["master"]
      ...
      ...
    podTemplate:
      spec:
        initContainers:
        - name: init-keystore
          command:
          - sh
          - -c
          - |
            elasticsearch-keystore create
            echo "${S3_ACCESS_KEY}" | elasticsearch-keystore add s3.client.<<KEYSTORE-NAME>>.access_key
            echo "${S3_SECRET_KEY}" | elasticsearch-keystore add s3.client.<<KEYSTORE-NAME>>.secret_key
          env:
          - name: S3_ACCESS_KEY
            valueFrom:
              secretKeyRef:
                name: elasticsearch-bucket
                key: AWS_ACCESS_KEY_ID
          - name: S3_SECRET_KEY
            valueFrom:
              secretKeyRef:
                name: elasticsearch-bucket
                key: AWS_SECRET_ACCESS_KEY
        		...
		        ...
        containers:
        - name: elasticsearch
          resources:
            requests:
              cpu: 2
              memory: 4Gi
            limits:
              cpu: 4
              memory: 8Gi
              ...
              ...

Diagram

100%

Drag to pan; pinch or use the wheel to zoom. Keyboard: arrow keys pan, + − zoom, 0 fits, Esc closes. The same content is in “Read the diagram as text” below the figure.