I'm trying to run private stellar blockchain infrastructure on kubernetes (not to join to existing public or test stellar network) but my question can be generalized to the scenario of running any peer to peer services on kubernetes. Therefore, I will try to explain my problem in a generalized way (hoping that it can yield answers that are applicable to any similar topology running on the kubernetes).
Here is the scenario:
I want to run 3 peers (in kube terms: pods) which are able to communicate with each other in a decentralized way but the problem lies in the fact that each of these peers has a slightly different configuration. In general, configuration looks like this (this is an example for pod0):
NETWORK_PASSPHRASE="my private network"
NODE_SEED=<pod0_private_key>
KNOWN_PEERS=[
"stellar-0",
"stellar-1",
"stellar-2"]
[QUORUM_SET]
VALIDATORS=[ <pod1_pub_key>, <pod2_pub_key> ]
The problem lies in the fact that each pod would have different:
- NODE_SEED
- VALIDATORS list
My first idea (before realizing this problem) was to:
- Create config map for this configuration
- Create statefulset (3 replicas) with headless service to enable stable reachability between pods (stellar-0, stellar-1, stellar-2...etc.)
Another idea (after realizing this problem) would be to:
- Create separate config maps for each peer
- Create statefulset (1 replica) with service
I'm wondering if there is any better solution/pattern that could be utilized for this purpose rather than running completely same services with slightly different configuration as separate entities (statefulset, deployment..) with their separate service through which these peers would be available (but this kind of defeats a purpose of using kubernetes high level resources which enable replication)?
Thanks
So you can have a single
ConfigMap
with multiple keys each one uniquely meant for one of your replicas. You can also deploy your pods using aStatefulSet
with aninitContainer
to setup the configs. This is just an example (You'll have to tweak it to your needs):ConfigMap:
StatefulSet:
Service (if you need to expose it)
Hope it helps!