Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Docker image not respecting environment variables #328

Closed
aetter opened this issue May 4, 2021 · 2 comments
Closed

[BUG] Docker image not respecting environment variables #328

aetter opened this issue May 4, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@aetter
Copy link

aetter commented May 4, 2021

Describe the bug

With Docker, you have the option of overriding default values in opensearch_dashboards.yml with environment variables. That way, instead of passing a new opensearch_dashboards.yml file to the container, you can just specify a few lines in your Docker Compose file. OpenSearch Dashboards appears to be ignoring environment variables currently.

To Reproduce

  1. Copy the following Docker Compose file to your machine as docker-compose.yml:
version: '3'
services:
  opensearch-node1:
    image: opensearchstaging/opensearch:latest
    container_name: opensearch-node1
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node1
      - discovery.seed_hosts=opensearch-node1,opensearch-node2
      - cluster.initial_master_nodes=opensearch-node1,opensearch-node2
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536 # maximum number of open files for the Elasticsearch user, set to at least 65536 on modern systems
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    networks:
      - opensearch-net
  opensearch-node2:
    image: opensearchstaging/opensearch:latest
    container_name: opensearch-node2
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node2
      - discovery.seed_hosts=opensearch-node1,opensearch-node2
      - cluster.initial_master_nodes=opensearch-node1,opensearch-node2
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - opensearch-data2:/usr/share/opensearch/data
    networks:
      - opensearch-net
  opensearch-dashboards:
    image: opensearchstaging/opensearch-dashboards:latest
    container_name: opensearch-dashboards
    ports:
      - 5601:5601
    expose:
      - "5601"
    environment:
      OPENSEARCH_HOSTS: https://opensearch-node1:9200
    networks:
      - opensearch-net

volumes:
  opensearch-data1:
  opensearch-data2:

networks:
  opensearch-net:
  1. From its directory, run docker-compose up.
  2. After the cluster stabilizes, note that OpenSearch Dashboards won't connect to it. Instead, it repeatedly tries to connect to https://localhost:9200, as specified in the container's opensearch_dashboards.yml:
opensearch-dashboards    | {"type":"log","@timestamp":"2021-05-04T22:42:13Z","tags":["error","opensearch","data"],"pid":1,"message":"[ConnectionError]: connect ECONNREFUSED 127.0.0.1:9200"}
  1. Run docker-compose down -v to stop the cluster.
  2. Replace your docker-compose.yml with this:
version: '3'
services:
  opensearch-node1:
    image: opensearchstaging/opensearch:latest
    container_name: opensearch-node1
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node1
      - discovery.seed_hosts=opensearch-node1,opensearch-node2
      - cluster.initial_master_nodes=opensearch-node1,opensearch-node2
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536 # maximum number of open files for the Elasticsearch user, set to at least 65536 on modern systems
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    networks:
      - opensearch-net
  opensearch-node2:
    image: opensearchstaging/opensearch:latest
    container_name: opensearch-node2
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node2
      - discovery.seed_hosts=opensearch-node1,opensearch-node2
      - cluster.initial_master_nodes=opensearch-node1,opensearch-node2
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - opensearch-data2:/usr/share/opensearch/data
    networks:
      - opensearch-net
  opensearch-dashboards:
    image: opensearchstaging/opensearch-dashboards:latest
    container_name: opensearch-dashboards
    ports:
      - 5601:5601
    expose:
      - "5601"
    environment:
      OPENSEARCH_HOSTS: https://opensearch-node1:9200
    volumes:
      - ./sample-opensearch_dashboards.yml:/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml
    networks:
      - opensearch-net

volumes:
  opensearch-data1:
  opensearch-data2:

networks:
  opensearch-net:

Note that there's now a volumes section to copy a new file over to the container.

  1. Create sample-opensearch_dashboards.yml:
server.name: "opensearch-dashboards"
server.host: "0"
opensearch.hosts: ["https://opensearch-node1:9200"]
opensearch.ssl.verificationMode: none
opensearch.username: "kibanaserver"
opensearch.password: "kibanaserver"
opensearch.requestHeadersWhitelist: ["securitytenant", "Authorization"]

opensearch_security.multitenancy.enabled: true
opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"]
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
# Use this setting if you are running kibana without https
opensearch_security.cookie.secure: false
  1. Run docker-compose up again.
  2. Note that it works this time.

Expected behavior

Environment variables from Docker should override any settings in opensearch_dashboards.yml, provided they are specified in ALL_CAPS with underscores to separate words.

OpenSearch Version
1.0.0-beta1

Dashboards Version
1.0.0-beta1

Plugins

opensearch-node1 opensearch-alerting             1.0.0.0-beta1
opensearch-node1 opensearch-anomaly-detection    1.0.0.0-beta1
opensearch-node1 opensearch-asynchronous-search  1.0.0.0-beta1
opensearch-node1 opensearch-index-management     1.0.0.0-beta1
opensearch-node1 opensearch-job-scheduler        1.0.0.0-beta1
opensearch-node1 opensearch-knn                  1.0.0.0-beta1
opensearch-node1 opensearch-performance-analyzer 1.0.0.0-beta1
opensearch-node1 opensearch-reports-scheduler    1.0.0.0-beta1
opensearch-node1 opensearch-security             1.0.0.0-beta1
opensearch-node1 opensearch-sql                  1.0.0.0-beta1

Host/Environment (please complete the following information):

  • OS: macOS
  • Browser and version: N/A
@aetter aetter added the bug Something isn't working label May 4, 2021
@aetter aetter closed this as completed May 4, 2021
@dblock
Copy link
Member

dblock commented May 4, 2021

@aetter What was the resolution here?

@aetter
Copy link
Author

aetter commented May 4, 2021

@dblock I pulled the image around noon, and independent of this bug report, @peterzhuamazon pushed a new image with a fix a few hours later.

SuZhou-Joe added a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this issue Apr 17, 2024
* feat: workspace level ui settings

When getting ui settings within a workspace, it will combine the workspace ui settings with
the global ui settings and workspace ui settings have higher priority if the same setting
was defined in both places

When updating ui settings within a workspace, it will update the workspace ui settings,
the global ui settings will remain unchanged.

Signed-off-by: Yulong Ruan <[email protected]>

* fix WorkspaceAttribute type

Signed-off-by: Yulong Ruan <[email protected]>

* update based on PR comments

Signed-off-by: Yulong Ruan <[email protected]>

* add integration tests for workspace ui settings wrapper

Signed-off-by: Yulong Ruan <[email protected]>

* Update src/plugins/workspace/server/saved_objects/workspace_ui_settings_client_wrapper.ts

Co-authored-by: SuZhou-Joe <[email protected]>

* fix failed tests

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>
Co-authored-by: SuZhou-Joe <[email protected]>
raintygao pushed a commit to raintygao/OpenSearch-Dashboards that referenced this issue Apr 19, 2024
* feat: workspace level ui settings

When getting ui settings within a workspace, it will combine the workspace ui settings with
the global ui settings and workspace ui settings have higher priority if the same setting
was defined in both places

When updating ui settings within a workspace, it will update the workspace ui settings,
the global ui settings will remain unchanged.

Signed-off-by: Yulong Ruan <[email protected]>

* fix WorkspaceAttribute type

Signed-off-by: Yulong Ruan <[email protected]>

* update based on PR comments

Signed-off-by: Yulong Ruan <[email protected]>

* add integration tests for workspace ui settings wrapper

Signed-off-by: Yulong Ruan <[email protected]>

* Update src/plugins/workspace/server/saved_objects/workspace_ui_settings_client_wrapper.ts

Co-authored-by: SuZhou-Joe <[email protected]>

* fix failed tests

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>
Co-authored-by: SuZhou-Joe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants