Expose internal IP so it can be accessed from internet

2/13/2019

I just deployed nginx on a K8S Node in a cluster, the master and worker communicate using internal IP address.

I can curl http://worker_ip:8080 (nginx) from internal network, but how to make it can be accessed from external/internet network?

Or should I use public IP as my node host?

-- Justinus Hermawan
amazon-web-services
docker
kubernetes

1 Answer

2/13/2019

update the service type to NodePort. grab the nodePort that is assigned to the service. you should be able to access nginx using host:nodeport

see below for reference

apiVersion: v1
kind: Service
metadata:
  name: my-nginx
  labels:
    run: my-nginx
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: http
  - port: 443
    protocol: TCP
    name: https
  selector:
    run: my-nginx
-- P Ekambaram
Source: StackOverflow