0

I have an opensearch app which I want to expose via a service so it can communicate with the opensearch-dashboard app I got. when I open a shell in the pod I see that the opensearch server works properly.

when I run to extract the url :

cat /etc/hosts

I get:

opensearch-master-headless-0.opensearch-master-headless.search.svc.cluster.local

if I run this in the same pod, I get 200 response.:

curl -XGET http://opensearch-master-headless-0.opensearch-master-headless.search.svc.cluster.local:9200 -u 'admin:admin' --insecure

if I run it from the dashboard pod in the same namespace it says its not resolved:

curl -XGET http://opensearch-master-headless-0.opensearch-master-headless.search.svc.cluster.local:9200 -u 'admin:admin' --insecure

my service.yml

---
kind: Service
apiVersion: v1
metadata:
  name: {{ .Values.global.appName }} --- evaluates to opensearch
  namespace: {{ .Values.global.namespace }} --- evaluates to search
spec:
  type: ClusterIP
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
    - name: "http"
      protocol: TCP
      port: 9200
    - name: "transport"
      protocol: TCP
      port: 9300
---

But, If I use the opensearch's pod IP Address:

curl -XGET http://<IP-ADDRESS>:9200 -u 'admin:admin' --inse

cure

this works from the opensearch pod

  • I'm using argocd to deploy, when I deploy the opensearch app, it doesnt raises any errors on my service configuration
David Maze
  • 130,717
  • 29
  • 175
  • 215
yovel cohen
  • 267
  • 3
  • 12
  • 1
    You should be able to use the Service's name and namespace as described in [DNS for Services and Pods](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/) in the Kubernetes documentation; `http://opensearch.search.svc.cluster.local:9200`. – David Maze Jan 13 '22 at 23:23
  • 1
    Did @DavidMaze's suggestion helped you? –  Jan 14 '22 at 10:11

1 Answers1

0

You can access via type NodePort of Service

---
kind: Service
apiVersion: v1
metadata:
  name: {{ .Values.global.appName }} --- evaluates to opensearch
  namespace: {{ .Values.global.namespace }} --- evaluates to search
spec:
  type: NodePort
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
    - name: "http"
      protocol: TCP
      port: 9200
      nodePort: 30920
    - name: "transport"
      protocol: TCP
      port: 9300
      nodePort: 30930
---

Then, call via IP of Node k8s
(get IP of Node k8s by command kubectl get node -o wide - at field INTERNAL-IP)

curl -XGET http://<INTERNAL-IP>:30920 -u 'admin:admin' --insecure

quoc9x
  • 1,423
  • 2
  • 9
  • 26