We can now combine these subdomains into a comma-separated list, and use it as the value for the discovery.zen.ping.unicast.hosts environment variable we are passing into the Elasticsearch containers. Update the manifests/elasticsearch/stateful-set.yaml file to read the following:
env: - name: discovery.zen.ping.unicast.hosts value: "elasticsearch-0.elasticsearch.default.svc.cluster.local,elasticsearch-1.elasticsearch.default.svc.cluster.local,elasticsearch-2.elasticsearch.default.svc.cluster.local"
The final stateful-set.yaml should read as follows:
apiVersion: apps/v1kind: StatefulSetmetadata: name: elasticsearchspec: replicas: 3 serviceName: elasticsearch selector: matchLabels: app: elasticsearch template: ...