Unable to access exposed k8s service on AWS on the internet

10/10/2017

I have an image called hello-node on my AWS ECR (described at bottom of post). If I run it locally and go to localhost:8080 I see "hello world."

On my node on AWS I run:

kubectl run hello-node --image=xxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/hello-node:v1 --port=8080 (account number blocked out)

then:

kubectl expose deployment hello-node --type="LoadBalancer"

and if I run:

kubectl describe service hello-node

I see (info edited)

Name:           hello-node
Namespace:      default
Labels:         run=hello-node
Annotations:        <none>
Selector:       run=hello-node
Type:           LoadBalancer
IP:         xx.xx.xx.xx
LoadBalancer Ingress:   xxxxxxxxx-xxxxxx.us-east-1.elb.amazonaws.com
Port:           <unset> 8080/TCP
NodePort:       <unset> 32059/TCP
Endpoints:      xx.xx.xx.xx:8080
Session Affinity:   None

I am trying to access my hello-node service online. I want to go to some web address or IP address in my browser and see 'hello world.'

I have tried going to the above-listed IP, LoadBalancer Ingress, and Endpoints, but those sites do not load in my browser. How can I access this service on the internet? I will provide any more info if required.

NOTE: if I do kubectl port-forward hello-node-621867969-ztxnr 8080 then I can access it on localhost:8080 on my machine, so something is working at least.

hello-node service:

Source here under 'Create an app, package it in a container and publish to a Docker registry' section

server.js:

var http = require('http');
var handleRequest = function(request, response) {
  response.writeHead(200);
  response.end("Hello World!");
}
var www = http.createServer(handleRequest);
www.listen(8080);

Dockerfile:

FROM node:6.9.2
EXPOSE 8080
COPY server.js .
CMD node server.js

run docker build -t hello-node:v1 .

run docker tag hello-node:v1 AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/hello-node:v1

run docker push AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/hello-node:v1 (put in my account and region info, and I verified that it is uploaded to my ECR)

Then I ran the two kubectl commands I listed in the start of this post.

-- swagrov
amazon-web-services
docker
kubectl
kubernetes

1 Answer

10/11/2017

I can access it through <loadbalanceringress>:<port>. I honestly can't remember if I had tried that or not (I tried a lot of address:Port combinations.

-- swagrov
Source: StackOverflow