kubectl reveal 明显暴露了错误的端口/连接超时

kubectl reveal 明显暴露了错误的端口/连接超时

我有一个如下所示的 pod 文件:

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

运行正常:

$ kubectl get pods
NAME          READY     STATUS    RESTARTS   AGE
test-api      1/1       Running   0          10d

我可以使用kubectl port-forward test-api 3000:80then 来访问它wget localhost:3000

当我使用公开它时kubectl expose -f test-api-pod.yml --port=80 --target-port=80 --type=LoadBalancer,服务已成功创建:

$ 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

但我无法访问,wget XYZ-ABC.us-east-1.elb.amazonaws.com因为超时了。

我认为这可能是主机名的问题,因此我将 XYZ-ABC.us-east-1.elb.amazonaws.com 添加到我的本地“hosts”文件中,使其解析为127.0.0.1,并且服务器响应正常。

有谁知道是什么原因导致了这个问题?

另请注意,当我使用常规nginx图像而不是我自己的应用服务器时,两者都port-forward可以expose正常工作。

仅供参考:

$ 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"}

相关内容