How to configure NodePort on Digital Ocean Kubernetes?

12/15/2018

I am new to Kubernetes. I have searched that you can use a LoadBalancer or NodePort to expose services. I am trying to follow tutorials on https://kubernetes.io/docs/tutorials/.

I am able to expose service with LoadBalancer but not NodePort. Here is the command I used.

kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
-- Joshua
digital-ocean
kubernetes

1 Answer

12/15/2018

I guess you're specifically following 'Use a Service to Access an Application in a Cluster'

Just to note in an answer what you came to already in the comments, you don't set a --port parameter on the expose in that example and just on the run. You set the port that the Pod responds to in the run command but not the port exposed externally in expose - k8s will choose that for you automatically from the NodePort range and then tell you which one it chose. Then you find a public IP for a node in order to access.

-- Ryan Dawson
Source: StackOverflow