DIgitalOcean Kubernetes service: NodePort

Hi, DigitalOcean community!

I need to expose service on each worker node. I have a running pod, which is listening on 443 port. Please, take a look at the service manifest:

kind: Service
apiVersion: v1
  name: relay-service
  namespace: {{}}{{}}
    app: {{ .Chart.Name }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  type: NodePort
    name: {{ .Chart.Name }}

    - name: tcp
      port: 443
      targetPort: 443
      protocol: TCP

Service has been successfully created:

Olegs-MacBook-Pro:helm mukolaich$ kubectl get svc --all-namespaces --kubeconfig=../frakubeconfig
NAMESPACE     NAME                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                  AGE
default      relay-service   NodePort   <none>        443:32168/TCP            19h

Here is more detailed service data:

Olegs-MacBook-Pro:helm mukolaich$ kubectl describe svc sling-relay-service --kubeconfig=../frakubeconfig
Name:                     relay-service
Namespace:                default
Labels:                   app=s3sync
Annotations:              <none>
Selector:                 name=s3sync
Type:                     NodePort
Port:                     tcp  443/TCP
TargetPort:               443/TCP
NodePort:                 tcp  32168/TCP
Endpoints:      ,
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

And unfortunately, I can access it using external worker IPs. From my point of view, it must work with the current approach (following basic Kubernetes principles).

I’ve opened the attached firewall to the Kubernetes as well.

Could someone point me in the right direction why it isn’t working?

Thanks, Oleg

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

One more, ingress working on L4, but I have TCP traffic there.

So, the only ingress with type LoadBalancer can be used, and it will create external Cloud LB (I don’t wanna have LB for each node).

It seems hostPort is the best solution here.

Example configuration, I can confirm it’s working:

apiVersion: v1
kind: Pod
  name: pod-name
    - name: pod-name
      image: docker-image
        - containerPort: 8086
          hostPort: 8086

Ok, I found this setup working for external clients when they go to the 32168 port (automatically assigned NodePort). I need to use 443, but NodePort is limited to use 30000-32767 range. So, I will prefer to use an ingress for routing traffic.

Going to keep this question for the community members who need to deal with NodePort in DOKS.

Good luck