etcd.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from lib.compose.services import ClusterCommonService
  2. class EtcdService(ClusterCommonService):
  3. SVC_ETCD = "etcd"
  4. SVC_PORT_ETCD_CLIENT = 2379
  5. SVC_PORT_ETCD_PEER_PORT = 2380
  6. VERSION = "3.4.6"
  7. def __init__(self):
  8. super().__init__(self.SVC_ETCD, self.VERSION,
  9. port=self.SVC_PORT_ETCD_CLIENT)
  10. self.set_healthcheck(f"/bin/sh -ec ETCDCTL_API=3 etcdctl endpoint status")
  11. self.add_environment({
  12. "ETCDCTL_API": "3",
  13. })
  14. def get_config_path(self):
  15. return None
  16. def _get_init_service(self):
  17. return None
  18. def _get_post_init_service(self):
  19. return None
  20. def get_command(self):
  21. return [
  22. "/usr/local/bin/etcd",
  23. "--data-dir=/var/etcd/data",
  24. "--name=etcd",
  25. f"--initial-advertise-peer-urls=http://etcd:{self.SVC_PORT_ETCD_PEER_PORT}",
  26. f"--listen-peer-urls=http://0.0.0.0:{self.SVC_PORT_ETCD_PEER_PORT}",
  27. f"--listen-client-urls=http://0.0.0.0:{self.SVC_PORT_ETCD_CLIENT}",
  28. f"--advertise-client-urls=http://etcd:{self.SVC_PORT_ETCD_CLIENT}",
  29. f"--initial-cluster=etcd=http://etcd:{self.SVC_PORT_ETCD_PEER_PORT}",
  30. "--initial-cluster-state=new",
  31. "--quota-backend-bytes",
  32. "134217728",
  33. "--auto-compaction-retention",
  34. "1",
  35. "--max-wals",
  36. "1",
  37. "--initial-cluster-token=7f283eed-0f7f-4d55-9159-32e673517b53"
  38. ]