'Expose Digital Ocean's Managed Kubernetes Cluster

I have been playing with Digital Ocean's new managed Kubernetes service. I have created a new cluster using Digital Ocean's dashboard and, seemingly, successfully deployed my yaml file (attached).

running in context kubectl get services

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE api-svc NodePort XX.XXX.XXX.XXX <none> 8080:30000/TCP 2h kubernetes ClusterIP XX.XXX.X.X <none> 443/TCP 2h

My question is, how do I go exposing my service without a load balancer?

I have been able to do this locally using minikube. To get the cluster IP I run minikube ip and use port number 30000, as specified in my nodePort config, to reach the api-svc service.

From what I understand, Digital Ocean's managed service abstracts the master node away. So where would I find the public IP address to access my cluster?

Thank you in advance!

my yaml file for reference

apiVersion: v1
kind: Secret
metadata:
  name: regcred
data:
  .dockerconfigjson: <my base 64 key>
type: kubernetes.io/dockerconfigjson
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: api-deployment
  labels:
    app: api-deployment
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      labels:
        app: api
 spec:
   containers:
   - name: api
     image: <my-dockerhub-user>/api:latest
     ports:
         - containerPort: 8080
   imagePullSecrets:
   - name: regcred
---
apiVersion: v1
kind: Service
metadata:
  name: api-svc
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 8080
    nodePort: 30000
    protocol: TCP
  selector:
    app: api
  type: NodePort


Solution 1:[1]

Slightly more detailed answer: DigitalOcean manages firewall rules for your NodePort services automatically, so once you expose the service, the NodePort is automatically open to public traffic from all worker nodes in your cluster. See docs

To find the public IP of any of your worker nodes, execute the following doctl commands:

# Get the first worker node from the first node-pool of your cluster
NODE_NAME=$(doctl kubernetes cluster node-pool get <cluster-name> <pool-name> -o json | jq -r '.[0].nodes[0].name')
WORKER_NODE_IP=$(doctl compute droplet get $NODE_NAME --template '{{.PublicIPv4}}')

Solution 2:[2]

Using "type: NodePort" presume use of node external address (any node) and may be unsustainable because nodes might be changed/upgraded.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 spinlok
Solution 2 Michael Shnit