I'm currently having issues exposing a pod running in an openshift 4 environment.
The attempt to connect to https://route...
results in an 503.
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: app-elastic-route
namespace: app-test
spec:
to:
kind: Service
name: app-elastic-svc
weight: 100
port:
targetPort: 9200-es
tls:
termination: edge
insecureEdgeTerminationPolicy: None
wildcardPolicy: None
kind: Service
apiVersion: v1
metadata:
name: app-elastic-svc
namespace: app-test
spec:
ports:
- name: 9200-es
protocol: TCP
port: 8080
targetPort: 9200
selector:
app: app-elastic
type: ClusterIP
sessionAffinity: None
kind: Deployment
apiVersion: apps/v1
metadata:
name: app-deploy
namespace: app-test
spec:
replicas: 1
selector:
matchLabels:
app: app-elastic
template:
metadata:
creationTimestamp: null
labels:
app: app-elastic
spec:
volumes:
- name: application-config
configMap:
name: app-config
items:
- key: application.properties
path: application.properties
defaultMode: 420
containers:
- resources:
limits:
cpu: 750m
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
name: app-elastic
ports:
- containerPort: 9200
protocol: TCP
imagePullPolicy: IfNotPresent
volumeMounts:
- name: application-config
readOnly: true
mountPath: /config
terminationMessagePolicy: File
image: >-
elastic/elasticsearch:7.14.0
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: { }
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600
I have the exact same setup running an port 8080 for a spring boot app and this works fine!
I'm positive the pod is alive, when connecting to the pod itself curl localhost:9200
works fine!
Can someone please provide some pointers on what might be wrong, or how I can investigate this issue in more detail?!
In yourRoute
,port.targetPort
should be 8080
https -> route:443 -> service:8080 -> pods:9200
In your service, change the spec.ports0.port to 9200 instead of 8080 an it should work .
Apparently my service and route configuration was correct. In fact the pod was not corrctlty behaving on the port...
Honestly I don't understand the details but I had to change configuration of the pod with elasticsearch.yml
http.host: 0.0.0.0
http.port: 8080
transport.tcp.port: 9200
transport.host: localhost
The following links helped me:
https://stackoverflow.com/questions/43889492/cant-access-port-9200-remotely