Openshift OKD with other Ports (Teamspeak)

318 Views Asked by At

I need help in creating an Teamspeak-Pod on an Openshift (OKD 3.11). My problem is after deploying the pod, I don´t know how I´m able to give Ports 9887, 10011 and 30033 for external access.

Only 8080, 8443 and 443 is reachable for webapplications from outside.

Do anyone know what I should do to give external acccess? I think I have to do something with firewalld and port-forwards. But I can´t find anything for this.

Thx, for your help...

1

There are 1 best solutions below

0
On

By default pods can only communicate within the cluster, so you won't be able to route external traffic to them.

One way to do this is to configure the service as a NodePort. That will map those ports to ports in the range of 30000-32767 across all of the nodes. For example:

apiVersion: v1
kind: Service
metadata:
  name: teamspeak
  labels:
    name: teamspeak
spec:
  type: NodePort
  ports:
  - name: 9887-tcp
    port: 9887
    nodePort: 31694
    protocol: TCP
  - name: 10011-tcp
    port: 10011
    nodePort: 30906
    protocol: TCP
  - name: 30033-tcp
    port: 30033
    nodePort: 32316
    protocol: TCP
  selector:
    name: teamspeak

If you run, oc edit service teamspeak, or whatever your app's service is called, and change the type to NodePort, Openshift will automatically assign a port in the range mentioned above.

After your service is setup as a NodePort, you'll need to forward requests for those ports to the new ones that were assigned by Openshift (the 30000 - 32767 range ports), so instead of requests going to 9887, they go to 30036, in the case of our example.

Reference: https://docs.openshift.com/container-platform/3.6/dev_guide/expose_service/expose_internal_ip_nodeport.html

Alternatively, you can define the service as type LoadBalancer, which will not only expose your pods to external traffic, but also distribute requests among pods per your configuration. For example,

apiVersion: v1
kind: Service
metadata:
  name: egress-2 
spec:
  ports:
  - name: db
    port: 3306
  - name: additional-port
    port: 9887
  - name: another-one
    port: 10011
  loadBalancerIP:
  type: LoadBalancer 
  selector:
    name: mysql

Reference: https://docs.openshift.com/container-platform/3.4/dev_guide/expose_service/expose_internal_ip_load_balancer.html