Unable to add keystore secure password through kubernetes init containers

  1. Deploying elasticsearch as docker in kubernetes
  2. Trying to add keystore secure password as part of kubernetes init container while deploying the a statefulset but the password is not getting added.
      initContainers:
      - name: setup
        image: $REGISTRY_ADDRESS/elasticsearch:$DOCKER_TAG
        env:
        - name: XPACK_SECURITY_TRANSPORT_SSL_KEYSTORE_SECURE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: $K8S_SERVICE_SECRETS
              key: xpack.security.transport.ssl.keystore.secure_password
        command:
        - sh
        - -c
        - |
          echo $XPACK_SECURITY_TRANSPORT_SSL_KEYSTORE_SECURE_PASSWORD | /usr/share/elasticsearch/bin/elasticsearch-keystore add --stdin --force xpack.security.transport.ssl.keystore.secure_password
        resources:
          requests:
            cpu: $POD_RESOURCE_REQUESTS_CPU
            memory: $POD_RESOURCE_REQUESTS_MEM
          limits:
            cpu: $POD_RESOURCE_LIMITS_CPU
            memory: $POD_RESOURCE_LIMITS_MEM
        securityContext:
          privileged: true
  1. Tried adding as docker args but it fails for below reason.
docker run es-local echo abc | /usr/local/share/elasticsearch/bin/elasticsearch-keystore add abc
-bash: /usr/local/share/elasticsearch/bin/elasticsearch-keystore: No such file or directory
write /dev/stdout: broken pipe

Hello,

I have some experience with Docker and the Elasticsearch keystore utilities, but unfortunately I have less experience with Kubernetes. I see you've posted a fragment of your configuration file. Do you think you could create a version of the configuration where I could run kubectl -f sample-conf.yaml and see the problem for myself?

-William

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.