Elasticsearch on fly.io

I’m trying to setup elasticsearch on fly. I’m able to deploy with this configuration, but my app remains not reachable.
keeps complaining
The app is not listening on the expected address and will not be reachable by fly-proxy.74de0a1460d8 reached started state
You can fix this by configuring your app to listen on the following addresses:

  • 0.0.0.0:9200

what going wrong here ?

# deployment/fly/elasticsearch/fly.toml
app = "my-elasticsearch"
primary_region = "bom"

[build]
  image = "elasticsearch:8.7.0"

# Mount volume
[mounts]
  source = "memehunt_elasticsearch_data"  # Match the volume name created in script
  destination = "/usr/share/elasticsearch/data"

# Define process
[processes]
  app = "/usr/local/bin/docker-entrypoint.sh eswrapper -p 9200"

[env]
  ES_JAVA_OPTS = "-Xms512m -Xmx512m"
  discovery.type = "single-node"
  xpack.security.enabled = "false"
  cluster.name = "memehunt_es_cluster"
  network.host = "0.0.0.0"
  http.port = "9200"
  transport.port = "9300"
  bootstrap.memory_lock = "true"
  TINI_SUBREAPER = "true"

[http_service]
  internal_port = 9200
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

# Add VM configuration
[vm]
  cpu_kind = "shared"
  cpus = 1
  memory = "1024"

this is a bit tricky in my experience. I’d recommend taking a look at the logs to see if there’s any obvious errors. otherwise, feel free to copy my working config below:

opensearch configs

disclaimer: the below configs are not supported by Fly.io or myself. I have a working app with this configs, but I don’t guarantee it will work for anyone else, and I’m not able to provide support for it.
please read and understand what the below will do before copy-pasting them.

fly.toml:

app = "your-appname-opensearch"
primary_region = "sjc"

[env]
	"discovery.seed_hosts" = "your-appname-opensearch.internal"
	"network.publish_host" = "fly-local-6pn"
	"bootstrap.memory_lock" = "true"
	"plugins.security.disabled" = "true"
	DISABLE_INSTALL_DEMO_CONFIG = "true"

[http_service]
	internal_port = 9200

	[http_service.concurrency]
		type = "requests"
		soft_limit = 250
		hard_limit = 250

[checks.opensearch-health]
grace_period = "30s"
interval = "15s"
method = "get"
path = "_cluster/health"
port = 9200
timeout = "10s"
type = "http"

[mounts]
	source = "opensearch_data"
	destination = "/usr/share/opensearch/data"
	initial_size = "100gb"

[[vm]]
	size = "performance-2x"
	memory = "8gb"

Dockerfile:

FROM opensearchproject/opensearch:latest
USER root
RUN dnf install -y procps util-linux
COPY entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]

entrypoint.sh:

#!/bin/sh

sysctl vm.max_map_count=1048576
sysctl fs.file-max=65536
ulimit -n 65535
ulimit -l unlimited
chown -R opensearch /usr/share/opensearch/data
exec su -p opensearch ./opensearch-docker-entrypoint.sh

Thanks for responding @lillian,
Like you suggested I looked through the logs and tried a few things, now i’ve got the elastic server working and could see it after i ssh into the machine.

root@2874de0a1460d8:/usr/share/elasticsearch# curl -u elastic:<password> -X GET http://0.0.0.0:9200
{
  "name" : "2874de0a1460d8",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "GL8CxBH1TAePwhpN28MV2g",
  "version" : {
    "number" : "8.7.0",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "09520b59b6bc1057340b55750186466ea715e30e",
    "build_date" : "2023-03-27T16:31:09.816451435Z",
    "build_snapshot" : false,
    "lucene_version" : "9.5.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

but for some reasong I’m not able to access it over http, must be some configuration issue in my fly.toml

# deployment/fly/elasticsearch/fly.toml
app = "my-elasticsearch"
primary_region = "bom"

[build]
  dockerfile = "Dockerfile"

# Mount volume
[mounts]
  source = "my_elasticsearch_data"  # Match the volume name created in script
  destination = "/usr/share/elasticsearch/data"
  initial_size = "8GB"


[env]
  discovery.type = "single-node"
  ES_JAVA_OPTS = "-Xms1g -Xmx1g"
  xpack.security.enabled = "false"
  cluster.name = "memehunt_es_cluster"
  ELASTIC_PASSWORD = "password"
  network.host = "0.0.0.0"
  http.port = "9200"
  transport.port = "9300"
  bootstrap.memory_lock = "true"
  TINI_SUBREAPER = "true"

[http_service]
  internal_port = 9200
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = false
  min_machines_running = 1
  processes = ['app']

# Add VM configuration
[vm]
  cpu_kind = "shared"
  cpus = 1
  memory = "2048"

looks correct, what happens when you try to connect to it? do you have an IP address allocated to the app?

Thanks for all the help @lillian. much appreciated.
Yeah, it was missing ip address. I though fly allocates a shared ipv4 and dedicated v6 for each app. but looks like it didn’t.
I manually allocated a shared v4, not it’s working fine.

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