# Service with type NodePort

**URL:** <https://forums.suse.com/t/service-with-type-nodeport/10482>\
**Category:** SUSE Rancher Prime\
**Created:** [May 19, 2018, 11:28am UTC](https://forums.suse.com/t/service-with-type-nodeport/10482 "2018-05-19T11:28:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgamperl](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mgamperl/32/2226_2.png) [@mgamperl](https://forums.suse.com/u/mgamperl)\
**Post date:** [May 19, 2018, 11:28am UTC](https://forums.suse.com/t/service-with-type-nodeport/10482/1 "2018-05-19T11:28:24Z")

</div>

Hi,  
how to create a Service of type NodePort in the Rancher UI?

I am running rancher 2 on a bare metal cluster and have to expose some deployments (redis, mongodb) to the outside world over tcp.  
I am fairly new to k8s and after some research I assume that the only way expose a tcp port for a deployment on bare metal is by using a service of type NodePort.  
My Idea is to use an external load balancer to balance between all hosts on that specific port to get one ip to connect to from my other infrastructure

Is this a suitable way of doing what I want or are there better ways? If this is the way to go, I have to create a such a service in my cluster, but I found no way of doing it in rancher. The only way I got it working is by using kubectl directly.

Thanks!

---

<div class="post-metadata">

**Author:** ![Pee\_Tankulrat](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/pee_tankulrat/32/4068_2.png) [@Pee\_Tankulrat](https://forums.suse.com/u/Pee_Tankulrat)\
**Post date:** [May 19, 2018, 2:28pm UTC](https://forums.suse.com/t/service-with-type-nodeport/10482/2 "2018-05-19T14:28:57Z")

</div>

You can use ClusterPort on the deployment that’s exposed by an Ingress with hostname routing.

> **[Kubernetes Ingress Support in Rancher](https://rancher.com/docs/rancher/v1.2/en/kubernetes/ingress/)**
>
> Documentation for Rancher

But! The ingress randomly make you wait 5 seconds until it is routed to the correct pods.

> [@Nginx ingress slows occasionally?](http://forums.suse.com/t/nginx-ingress-slows-occasionally/10475):
>
> Hi there! I’ve recently started trying out Rancher 2.0 and notice some strange behavior with hostname ingress. In my experiment, I tried deploying two replicas of tutum/hello-world image that’s linked to a service that’s then exposed by host-based ingress. In this configuration, I noticed The round-robin load balancing never kicked in If one of the replica pod is killed a 504 from nginx ingress is thrown for a few seconds There’s about a 50/50 chance that a request is delayed for 5 seconds fo…

Also! NodePort on Rancher 2.0 doesn’t seem to work either! If you need to use NodePort to connect to external loadbalancer now and doesn’t care much about Master’s HA then, I’d recommend just using Kubeadm…

Good luck

---

<div class="post-metadata">

**Author:** ![mgamperl](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mgamperl/32/2226_2.png) [@mgamperl](https://forums.suse.com/u/mgamperl)\
**Post date:** [May 20, 2018, 10:31am UTC](https://forums.suse.com/t/service-with-type-nodeport/10482/3 "2018-05-20T10:31:10Z")

</div>

Isn’t the ingress with hostname routing only working for level 7 and not for tcp connections?

I was able to get NodePort working by deploying the following via kubectl:

```
kind: Service
apiVersion: v1
metadata:
    name: redis-outside
spec:
    type: NodePort
    selector:
        app: redis
    ports:
    - name: redis
      protocol: TCP
      port: 6379
      targetPort: 6379
      nodePort: 30000

```

this makes redis available on all nodes on port 30000. I can then use my own loadbalancer to balance between all nodes but have not yet tested out how well this is working.

But I did not find a way to configure this type of service in the UI.

So your recommendation would be to use kubeadm instead of rancher2 or am I missing anything?

thanks

---

<div class="post-metadata">

**Author:** ![mgamperl](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mgamperl/32/2226_2.png) [@mgamperl](https://forums.suse.com/u/mgamperl)\
**Post date:** [May 22, 2018, 6:50pm UTC](https://forums.suse.com/t/service-with-type-nodeport/10482/4 "2018-05-22T18:50:33Z")

</div>

I have found out that rancher deployed ingress-nginx in its default configuration and after moving the namespace to its own project I was able to configure the tcp-services ConfigMap via rancher ui. This way its possible to expose tcp ports which are load balanced across all nodes similar to rancher 1.6.

Can someone from the rancher team confirm if this is a way to do tcp load balancing or if this could have any side effects for the cluster?

---

<div class="post-metadata">

**Author:** ![Guido\_Steiner](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/guido_steiner/32/5862_2.png) [@Guido\_Steiner](https://forums.suse.com/u/Guido_Steiner)\
**Post date:** [May 29, 2018, 10:13am UTC](https://forums.suse.com/t/service-with-type-nodeport/10482/5 "2018-05-29T10:13:38Z")

</div>

we did the ports also over the services but we used this to have a VIP instead of a external loadbalancer

> **[contrib/keepalived-vip at master · kubernetes-retired/contrib](https://github.com/kubernetes-retired/contrib/tree/master/keepalived-vip)**
>
> master/keepalived-vip
