datastax / zdm-proxy

An open-source component designed to seamlessly handle the real-time client application activity while a migration is in progress.
https://docs.datastax.com/en/astra-serverless/docs/migrate/introduction.html
Apache License 2.0
77 stars 19 forks source link

kubernetes helm chart: Automatically assign an ordinal index from statefulsets metadata #88

Open weideng1 opened 1 year ago

weideng1 commented 1 year ago

Currently zdm-proxy process expects this env value to be set at start time: ZDM_PROXY_TOPOLOGY_INDEX

I've looked into online discussions, and looks like there is an unresolved issue w.r.t. directly exposing this ordinal index from statefulsets: https://github.com/kubernetes/kubernetes/issues/40651

Before this is fully supported in a future version of k8s, we will have to adopt some ugly workaround by either using initContainers or lifecycle hook like the following:

apiVersion: apps/v1
kind: StatefulSet
spec:
  serviceName: "zdm-proxy"
  replicas: {{ $.Values.proxy.count | int }}
  template:
    spec:
      containers:
      - lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "export STS_INDEX=${HOSTNAME##*-}"]

┆Issue is synchronized with this Jira Task by Unito ┆Components: Proxy ┆Issue Number: ZDM-505

joao-r-reis commented 1 year ago

We could potentially add another config setting like "ZDM_PROXY_TOPOLOGY_LOCAL_ADDRESS" and then let the proxy compute its index by looking up the ZDM_PROXY_TOPOLOGY_LOCAL_ADDRESS in the ZDM_PROXY_TOPOLOGY_ADDRESSES. We would require only one of these 2 settings to be set (îndex or local address) but in order for the local address setting to work correctly we need the proxy to order the ZDM_PROXY_TOPOLOGY_ADDRESSES first just to ensure that it works even when the order of the addresses in ZDM_PROXY_TOPOLOGY_ADDRESSES is different in different proxy nodes (it should never happen but we should be safe).

Would this make it easier to make the proxy work with stateful sets @weideng1 ?