I have a pod file that looks like this:
apiVersion: v1
kind: Pod
metadata:
name: test-api
labels:
app: web
spec:
containers:
- name: test-api-container
image: cmgvieira/test-api:latest
imagePullSecrets:
- name: regsecret
It's running properly:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
test-api 1/1 Running 0 10d
I can access it using kubectl port-forward test-api 3000:80
then wget localhost:3000
.
When I expose it using kubectl expose -f test-api-pod.yml --port=80 --target-port=80 --type=LoadBalancer
, the service gets created successfully:
$ kubectl describe service test-api
Name: test-api
Namespace: default
Labels: app=web
Selector: app=web
Type: LoadBalancer
IP: 100.XXX.XXX.XXX
LoadBalancer Ingress: XYZ-ABC.us-east-1.elb.amazonaws.com
Port: <unset> 80/TCP
NodePort: <unset> 32310/TCP
Endpoints: <none>
Session Affinity: None
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
7m 7m 1 {service-controller } Normal CreatingLoadBalancer Creating load balancer
7m 7m 1 {service-controller } Normal CreatedLoadBalancer Created load balancer
But I can't access with wget XYZ-ABC.us-east-1.elb.amazonaws.com
because it times out.
I thought this might be a problem with the hostname, so I added XYZ-ABC.us-east-1.elb.amazonaws.com to my local "hosts" file, making it resolve to 127.0.0.1
, and the server responds just fine.
Does anyone know what could be causing this issue?
Also note that when I use the regular nginx
image instead of my own app server, both port-forward
and expose
work just fine.
FWIW:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:40:50Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-01-12T04:52:34Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}