Skip to content
The Chat Archive
claude-3-5-sonnet-20241022· Anthropic LMArena Human Preference 140K

how to set up a docker compose file for 3 opensearch nodes with ssl

  1. User

    how to set up a docker compose file for 3 opensearch nodes with ssl

  2. Assistant

    I'll help you create a docker-compose.yml file for a 3-node OpenSearch cluster with SSL enabled. I'll break this down into steps:

    version: '3'
    services:
      opensearch-node1:
        image: opensearchproject/opensearch:latest
        container_name: opensearch-node1
        environment:
          - cluster.name=opensearch-cluster
          - node.name=opensearch-node1
          - discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
          - cluster.initial_master_nodes=opensearch-node1,opensearch-node2,opensearch-node3
          - bootstrap.memory_lock=true
          - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
          - "DISABLE_SECURITY_PLUGIN=false"
          - "DISABLE_INSTALL_DEMO_CONFIG=true"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
          - opensearch-data1:/usr/share/opensearch/data
          - ./certs:/usr/share/opensearch/config/certificates
        ports:
          - 9200:9200
          - 9600:9600
        networks:
          - opensearch-net
    
      opensearch-node2:
        image: opensearchproject/opensearch:latest
        container_name: opensearch-node2
        environment:
          - cluster.name=opensearch-cluster
          - node.name=opensearch-node2
          - discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
          - cluster.initial_master_nodes=opensearch-node1,opensearch-node2,opensearch-node3
          - bootstrap.memory_lock=true
          - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
          - "DISABLE_SECURITY_PLUGIN=false"
          - "DISABLE_INSTALL_DEMO_CONFIG=true"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
          - opensearch-data2:/usr/share/opensearch/data
          - ./certs:/usr/share/opensearch/config/certificates
        networks:
          - opensearch-net
    
      opensearch-node3:
        image: opensearchproject/opensearch:latest
        container_name: opensearch-node3
        environment:
          - cluster.name=opensearch-cluster
          - node.name=opensearch-node3
          - discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
          - cluster.initial_master_nodes=opensearch-node1,opensearch-node2,opensearch-node3
          - bootstrap.memory_lock=true
          - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
          - "DISABLE_SECURITY_PLUGIN=false"
          - "DISABLE_INSTALL_DEMO_CONFIG=true"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
          - opensearch-data3:/usr/share/opensearch/data
          - ./certs:/usr/share/opensearch/config/certificates
        networks:
          - opensearch-net
    
    volumes:
      opensearch-data1:
      opensearch-data2:
      opensearch-data3:
    
    networks:
      opensearch-net:
        driver: bridge
    

    Before running this, you'll need to:

    1. Create a certs directory in the same location as your docker-compose.yml file
    2. Generate SSL certificates and place them in the certs directory
    3. Create an opensearch.yml configuration file for SSL settings

    Here's a basic opensearch.yml that should be placed in the certs directory:

    plugins.security.ssl.transport.pemcert_filepath: certificates/node.pem
    plugins.security.ssl.transport.pemkey_filepath: certificates/node-key.pem
    plugins.security.ssl.transport.pemtrustedcas_filepath: certificates/root-ca.pem
    plugins.security.ssl.http.enabled: true
    plugins.security.ssl.http.pemcert_filepath: certificates/node.pem
    plugins.security.ssl.http.pemkey_filepath: certificates/node-key.pem
    plugins.security.ssl.http.pemtrustedcas_filepath: certificates/root-ca.pem
    plugins.security.allow_unsafe_democertificates: true
    plugins.security.allow_default_init_securityindex: true
    plugins.security.authcz.admin_dn:
      - "CN=kirk,OU=client,O=client,L=test,C=de"
    

    To generate self-signed certificates, you can use OpenSSL or the OpenSearch security tools. Would you like me to provide the commands for generating the certificates as well?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.