0

With a Service called "myservice" backed onto a Statefulset called "mypods" you can curl
mypods-0.myservice to direct traffic to the first pod in the Statefulset.

How can I accomplish something similar with a Daemonset?

GDev
  • 428
  • 1
  • 5
  • 14
  • Is it enough to reach a pod on the same node as the current container, or do you specifically need to call an arbitrary known pod somewhere in the cluster? – David Maze Oct 17 '20 at 01:03
  • I am trying to bootstrap an elasticsearch cluster, so I need to specify seed and peer nodes (the other nodes in the daemonset). Statefulsets have storage problems. – GDev Oct 17 '20 at 01:06
  • 3
    Curious, what storage problems do statefulsets have? We have been using ECK for ES deployments and it's been working great. Before that we used statefulsets. Also, in ES you only need seed nodes. The peer nodes are discovered during cluster metadata exchange. So you could just create a Service that points to all your pods. The cluster should just form by itself. – tuxiedev Oct 17 '20 at 02:00
  • Depending on what you're doing, Elasticsearch can be kind of heavy-weight. If you want to run ES on _every_ node in a cluster (which is what a DaemonSet does), running a bare-metal ES cluster might make more sense. – David Maze Oct 17 '20 at 11:07
  • So in the end I created a statefulset of `node.roles=master` seed nodes and a daemonset of data (all roles) nodes. Baremetal-ES or kubelet controlled static pods might perhaps be a better design. For clarity the issue with statefulsets is that volumeClaimTemplate doesn't support hostPath out of the box, and LPVs require you to know the names of the Nodes in advance. This is a tin installation, Cloud would have been easier. – GDev Oct 17 '20 at 20:32

1 Answers1

0

According to kubernetes documentation, In general a pod has the following DNS resolution:

pod-ip-address.my-namespace.pod.cluster-domain.example

Any pods created by a Deployment or DaemonSet exposed by a Service have the following DNS resolution available:

pod-ip-address.deployment-name.my-namespace.svc.cluster-domain.example

pod-ip-address.daemonset-name.my-namespace.svc.cluster-domain.example

But instead of using pod-ip-address you can set hostname for pod in its yaml description. The Pod spec has an optional hostname field, which can be used to specify the Pod's hostname. So set pod.pec.hostname Then following DNS resolution will available:

pod-hostname.my-namespace.svc.cluster-domain.example

mhafshari
  • 41
  • 3