Skip to content

Commit 1995c24

Browse files
committed
DUP: allow to customize Erlang clustering on k8s
Introduce two configuration options for the formation of DUP clusters on k8s. They can be set via two env vars: - `DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_SELECTOR`, defaulting to `app=astarte-data-updater-plant` - `DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_NAMESPACE`, defaulting to `astarte` Signed-off-by: Arnaldo Cesco <arnaldo.cesco@secomind.com>
1 parent 2a39bc0 commit 1995c24

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
allowing to autoscale the service. This is done via Erlang clustering, so
1717
the `DATA_UPDATER_PLANT_CLUSTERING_STRATEGY` env var (default `none`) has
1818
been introduced to set clustering strategy.
19+
- [astarte_data_updater_plant] allow to configure Erlang clustering when using
20+
the `kubernetes` option via `DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_SELECTOR`
21+
and `DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_NAMESPACE`.
1922

2023
## [1.2.1] - Unreleased
2124
### Changed

apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/config.ex

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,22 @@ defmodule Astarte.DataUpdaterPlant.Config do
245245
type: Astarte.DataUpdaterPlant.ClusteringStrategy,
246246
default: "none"
247247

248+
@envdoc "The Kubernetes selector to use when `kubernetes` Erlang clustering strategy is used. Defaults to `app=astarte-data-updater-plant`."
249+
app_env :clustering_kubernetes_selector,
250+
:astarte_data_updater_plant,
251+
:clustering_kubernetes_selector,
252+
os_env: "DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_SELECTOR",
253+
type: :binary,
254+
default: "app=astarte-data-updater-plant"
255+
256+
@envdoc "The Kubernetes namespace to use when `kubernetes` Erlang clustering strategy is used. Defaults to `astarte`."
257+
app_env :clustering_kubernetes_namespace,
258+
:astarte_data_updater_plant,
259+
:clustering_kubernetes_namespace,
260+
os_env: "DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_NAMESPACE",
261+
type: :binary,
262+
default: "astarte"
263+
248264
# Since we have one channel per queue, this is not configurable
249265
def amqp_consumer_channels_per_connection_number!() do
250266
ceil(data_queue_total_count!() / amqp_consumer_connection_number!())
@@ -449,8 +465,8 @@ defmodule Astarte.DataUpdaterPlant.Config do
449465
config: [
450466
mode: :ip,
451467
kubernetes_node_basename: "astarte_data_updater_plant",
452-
kubernetes_selector: "app=astarte-data-updater-plant",
453-
kubernetes_namespace: "astarte",
468+
kubernetes_selector: clustering_kubernetes_selector!(),
469+
kubernetes_namespace: clustering_kubernetes_namespace!(),
454470
polling_interval: 10_000
455471
]
456472
]

0 commit comments

Comments
 (0)