0
votes

I am looking to have a dynamic etcd cluster running inside my k8s cluster. The best way I can think of doing it dynamically (no hardcoded addresses, names, etc.) is to use DNS discovery, with the internal k8s DNS (CoreDNS).

I find detached information about SRV records created for services in k8s, and some explanations on how etcd DNS discovery works, but no complete howto.

For example:

  • how does k8s name SRV entries?
  • should they be named with a specific way for etcd to be able to find them?
  • should any special CoreDNS setting be set?

Any help on that would be greatly appreciated.

references:

1

1 Answers

1
votes

how does k8s name SRV entries?

via the Service.port[].name, which is why almost everything in kubernetes has to be a DNS-friendly name: because a lot of times, it does put them in DNS for you.

A Pod that has dig or a new enough nslookup will then show you:

$ dig SRV kubernetes.default.svc.cluster.local.

and you'll see the names of the ports that the kubernetes Service is advertising.

should they be named with a specific way for etcd to be able to find them?

Yes, as one can see in the page you linked to, they need to be named one of these four:

  • _etcd-client
  • _etcd-client-ssl
  • _etcd-server
  • _etcd-server-ssl

so something like this on the kubernetes side:

ports:
- name: etcd-client
  port: 2379
  containerPort: whatever
- name: etcd-server
  port: 2380
  containerPort: whatever