我在kubernetes中部署并运行了一项服务
ssk181993@sdn-assign2:~$ 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:〜$ curl 130.21.181.24:9082
curl:(7)无法连接到130.21.181.24端口9082:连接超时
有什么建议吗?
更新 -
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 :(得分:0)
您正在尝试访问内部目标端口,如果将服务类型字段设置为NodePort
,Kubernetes主服务器将从标记配置的范围(默认值:30000-32767)中分配端口。
所以尽量做curl http://130.211.181.24:32173
有关详细信息,请参阅此link。