2017-12-02 171 views
1

我有一个服务部署和kubernetes无法访问暴露IP在kubernetes

[email protected]:~$ kubectl get svc 
NAME        TYPE   CLUSTER-IP  EXTERNAL-IP  PORT(S)   AGE 
kubernetes      ClusterIP  10.11.240.1  <none>   443/TCP   19d 
weather-view-deployment   LoadBalancer 10.11.250.200 130.211.181.24 9082:32173/TCP 1d 
weather-view-service    NodePort  10.11.243.238 <none>   9082:32640/TCP 1d 

当我尝试访问外部IP喜欢跑步,

ssk181993 @ SDN-ASSIGN2:〜$卷曲130.21。 181.24:9082
curl:(7)无法连接到130.21.181.24端口9082:连接超时

有什么建议吗?

Update--

service.yml

`apiVersion: v1 
kind: Service 
metadata: 
    name: weather-view-service 
spec: 
    type: LoadBalancer 
    loadBalancerIP: 78.11.24.25 
    ports: 
    - 
     port: 9082 
     targetPort: 9082 
    selector: 
    app: weather-view 
    type: NodePort 
status: 
    loadBalancer: {}` 

deployment.yml

`apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    name: weather-view-deployment 
spec: 
    replicas: 2 # tells deployment to run 2 pods matching the template 
    minReadySeconds: 10 
    strategy: 
    type: RollingUpdate 
    rollingUpdate: 
     maxUnavailable: 1 
     maxSurge: 1 
    template: # create pods using pod definition in this template 
    metadata: 
     labels: 
     app: weather-view 
    spec: 
     containers: 
     - name: weather-view 
     image: ##dockerhubimage## 
     ports: 
     - containerPort: 9082` 

请参考图像的文件夹结构在GIT中。 https://i.stack.imgur.com/d0BAZ.jpg

回答

0

您试图访问内部目标端口,如果您的服务类型字段设置为NodePort,该Kubernetes主将从标志配置的范围(:30000-32767默认)分配一个端口。

于是尝试去做curl http://130.211.181.24:32173

有关更多信息,请参见本link

+0

虽然这不是这里提出的问题。 –

+0

为什么不呢? '9082:32173'表示端口32173映射到端口9082.不是吗? –

+0

确实。但是OP的错误信息的原因比这个简单得多;) –