Reputation: 285
We are using Azure and I'm creating a Elasticsearch instance through the following snippet with terraform on a managed AKS cluster:
resource "helm_release" "elasticsearch" {
name = "elasticsearch"
repository = "https://helm.elastic.co"
chart = "elasticsearch"
version = "7.12.1"
timeout = 900
set {
name = "volumeClaimTemplate.storageClassName"
value = "elasticsearch-ssd"
}
set {
name = "volumeClaimTemplate.resources.requests.storage"
value = "5Gi"
}
set {
name = "imageTag"
value = "7.12.1"
}
...
}
So far no problem. Elasticsearch spins up and is ready to use. Everything is in a virtual net. So the nodes of Elasticsearch get attributed a Cluster IP.
Now, to deploy something on my Kubernetes Cluster that actually uses Elasticsearch, I need to pass it the cluster IP of the Elasticsearch.
Does anybody know a way to retrieve the Cluster IP in an automated way? So that I can pass it to the following terraform modules in my configuration? I think I scanned all the outputs of the helm release, but I'm unable to find the cluster IP...
In the example below, it would be the "10.0.169.174":
ppaulis@ppaulis-sb3:~/PhpstormProjects/baywa/infra/terraform-final/5_tms-api$ kubectl get services -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
elasticsearch-master ClusterIP 10.0.169.174 <none> 9200/TCP,9300/TCP 25h app=elasticsearch-master,chart=elasticsearch,release=tms-dv-elasticsearch
elasticsearch-master-headless ClusterIP None <none> 9200/TCP,9300/TCP 25h app=elasticsearch-master
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 28h <none>
Any help is appreciated! Thanks, Pascal
Upvotes: 0
Views: 1424
Reputation: 9012
First of all it's a bad practice to rely on Service IP address instead of DNS name. If you're trying to reach ES outside of Kubernetes then you might want to automatically create DNS record for it using external-dns. I think this is the best way.
However, nothing stops you from adjusting ES Helm chart to your needs. Just go ahead and modify the YAML here: https://github.com/elastic/helm-charts/blob/master/elasticsearch/templates/service.yaml
Upvotes: 1