Fix Erlang clustering: use IP-based node names with DNS strategy
DNSSRV strategy resolves to IP-based names but nodes were named by pod name, causing connection failures. Switch to DNS strategy with IP-based node naming so libcluster discovery matches actual node names.
This commit is contained in:
parent
bff63bb8a8
commit
75ceb73607
3 changed files with 11 additions and 8 deletions
|
|
@ -153,15 +153,14 @@ if config_env() == :prod do
|
|||
|
||||
# Configure libcluster topology based on environment
|
||||
if cluster_enabled do
|
||||
# Use DNSSRV strategy for StatefulSet clustering
|
||||
# Use DNS strategy with headless service for node discovery
|
||||
config :libcluster,
|
||||
topologies: [
|
||||
k8s: [
|
||||
strategy: Cluster.Strategy.Kubernetes.DNSSRV,
|
||||
strategy: Cluster.Strategy.Kubernetes.DNS,
|
||||
config: [
|
||||
service: "aprs-headless",
|
||||
service: "aprs-headless.aprs.svc.cluster.local",
|
||||
application_name: "aprsme",
|
||||
namespace: "aprs",
|
||||
polling_interval: 5_000
|
||||
]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -114,6 +114,10 @@ spec:
|
|||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.podIP
|
||||
- name: PORT
|
||||
value: "4000"
|
||||
- name: PHX_HOST
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@
|
|||
# RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
|
||||
export RELEASE_DISTRIBUTION=name
|
||||
|
||||
# Check if we're in Kubernetes (POD_NAME will be set)
|
||||
if [ -n "$POD_NAME" ]; then
|
||||
# Use Kubernetes pod name and headless service for clustering
|
||||
export RELEASE_NODE=${RELEASE_NODE:-<%= @release.name %>@${POD_NAME}.aprs-headless.aprs.svc.cluster.local}
|
||||
# Check if we're in Kubernetes (POD_IP will be set)
|
||||
if [ -n "$POD_IP" ]; then
|
||||
# Use pod IP for Erlang distribution — matches libcluster DNS strategy
|
||||
export RELEASE_NODE=${RELEASE_NODE:-<%= @release.name %>@${POD_IP}}
|
||||
else
|
||||
# Fallback to Dokku naming for non-Kubernetes deployments
|
||||
export RELEASE_NODE=<%= @release.name %>@${DOKKU_APP_NAME:-aprsme}.web.${DOKKU_APP_INSTANCE:-1}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue