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

[WIP] DUP: use Erlang clustering and allow autoscaling #1037

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Annopaolo
Copy link
Collaborator

@Annopaolo Annopaolo commented Dec 12, 2024

Create an Erlang cluster of DUPs which are able to autoscale and share load.

Add the DATA_UPDATER_PLANT_CLUSTERING_STRATEGY env to allow choosing which Erlang cluster topology to use.
At the moment, two options are available:

  • none (default): every instance is a single-node cluster
  • kubernetes: multi-nodes cluster using k8s API. The kubernetes strategy requires a service account with permissions to list endpoints.

The DUP release name now includes the k8s pod IP, which can be supplied via the MY_POD_IP env var.

When none strategy is used

Nothing changes w.r.t previous releases. The service will still run as not clustered.

When kubernetes strategy is used

A cluster of DUPs will be created - under the hood, we have libcluster's Cluster.Strategy.Kubernetes with :ip option. By default, it will comprise instances in the astarte namespace having label app=astarte-data_updater_plant.
These two values can be customized by setting the related env vars:

  • DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_NAMESPACE
  • DATA_UPDATER_PLANT_CLUSTERING_KUBERNETES_SELECTOR

Important

In order to form clusters, kubernetes discovery is used. Therefore, the ServiceAccount of DUP pods should have permissions to get and list resources of type endpoints in the "" API group.

What this PR does / why we need it:

Autoscale DUP, wohoo

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?
  • Yes
  • No

Additional documentation e.g. usage docs, diagrams, etc.:


@Annopaolo Annopaolo force-pushed the dup-mississippi-clustering branch from a6d4c08 to 063668e Compare December 12, 2024 18:25
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.22%. Comparing base (76adaf5) to head (1995c24).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1037      +/-   ##
==========================================
- Coverage   69.23%   69.22%   -0.01%     
==========================================
  Files         275      276       +1     
  Lines        7193     7201       +8     
==========================================
+ Hits         4980     4985       +5     
- Misses       2213     2216       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Annopaolo Annopaolo force-pushed the dup-mississippi-clustering branch 2 times, most recently from b132c41 to 22d3fd0 Compare December 16, 2024 16:04
@Annopaolo Annopaolo force-pushed the dup-mississippi-clustering branch from 22d3fd0 to b4b23f2 Compare February 7, 2025 11:16
Add the DATA_UPDATER_PLANT_CLUSTERING_STRATEGY env
to allow choosing which Erlang cluster topology to use.
At the moment, two options are available:
- `none` (default): every instance is a single-node cluster
- `kubernetes`: multi-nodes cluster using k8s API.
The `kubernetes` strategy requires a service account
with permissions to list endpoints.
Instances in the `astarte` namespace having label
`app=astarte-data_updater_plant` will form an Erlang cluster.
Under the hood, we have libcluster's Cluster.Strategy.Kubernetes
with `:ip` option.

Moreover, to support distributed Erlang (over k8s),
the DUP release name includes the `MY_POD_IP` env
var when it is set.
If `MY_POD_IP` is not set, DUP will run in local
mode, without distribution, as if it was before.

Signed-off-by: Arnaldo Cesco <[email protected]>
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 <[email protected]>
@Annopaolo Annopaolo force-pushed the dup-mississippi-clustering branch from b4b23f2 to 1995c24 Compare February 7, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant