Kubernetes clustered deployment with replicas #2641
brettinternet
started this conversation in
Show and tell
Replies: 1 comment
-
My friend pointed out that it's a better idea to separate the headless service from the web service so that the web service can properly load balance the pods with incoming requests. So I created a separate headless service: ---
apiVersion: v1
kind: Service
metadata:
name: livebook-headless
spec:
type: ClusterIP
clusterIP: None
selector:
app.kubernetes.io/name: livebook
app.kubernetes.io/instance: livebook And update the cluster query var to point to that service instead: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been playing around with Livebook's cluster mode on a bare-metal Kubernetes cluster. I initially had some trouble getting the replicas to discover each other, but now that it's working, I wanted to share the deployment setup.
You can see my full helm deployment here.
For storage, I use a RWX persistent longhorn volume to allow me to scale the deployment replicas.
I have a headless service with ports targeted for Livebook's container. The headless service load balances DNS queries for the replicated pods which is what Livebook expects for clustering. Side note: This is similar to what libcluster recommends for its Kubernetes DNS strategy. However, Livebook does not use libcluster.
Here are the pod's environment variables:
I pass these environment variables in a configMap to
/app/user/app.sh
:The
LIVEBOOK_CLUSTER: dns:livebook.default.svc.cluster.local
environment value is what DNSCluster lib expects, which Livebook uses for node discovery.Then, if I
dig
the headless service in the Kubernetes cluster I should see both pod replicas:So now with the query
livebook.default.svc.cluster.local
should find all the Elixir nodes. 🙂Beta Was this translation helpful? Give feedback.
All reactions