I have created a kubernetes service:
d = {1: [[0,100], [100, 500], [500, 800]], 2: [[0, 700], [800, 1000]]}
for a in d.keys():
x = [[i,i+1] for i,v in enumerate(d[a][:-1]) if v[1] != d[a][i+1][0]]
if len(x) > 0:
print a
However, am unable to connect to connect to the Endpoint, not even from the shell on the node host:
[root@Infra-1 kubernetes]# kubectl describe service gitlab
Name: gitlab
Namespace: default
Labels: name=gitlab
Selector: name=gitlab
Type: NodePort
IP: 10.254.101.207
Port: http 80/TCP
NodePort: http 31982/TCP
Endpoints: 172.17.0.4:80
Port: ssh 22/TCP
NodePort: ssh 30394/TCP
Endpoints: 172.17.0.4:22
Session Affinity: None
No events.
Calling [root@Infra-2 ~]# wget 172.17.0.4:80
--2015-12-08 20:22:27-- http://172.17.0.4:80/
Connecting to 172.17.0.4:80... failed: Connection refused.
on the NodePort also gives a wget localhost:31982
and the kube-proxy logs error messages:
Recv failure: Connection reset by peer
What could be the reason for this failure?
Here is my service configuration file http://pastebin.com/RriYPRg7, a slight modification of https://github.com/sameersbn/docker-gitlab/blob/master/kubernetes/gitlab-service.yml
答案 0 :(得分:1)
实际上,Pod或复制控制器存在问题,因为它没有转发到服务。也许发布该配置或确保它已指定端口并且其容器的进程正在侦听正确的端口
<强>原始强>
实际上是在pod之外暴露的NodePort
。 Port
是节点内NAT网络上的端口,Port
是容器内部进程应绑定的端口,通常使用服务发现。其他pod将与NodePort
上的该pod进行通信。如果要为Web服务器明确设置NodePort
,则在Pod的定义或复制控制器或服务定义中,将NodePort
显式设置为所需的端口。
Port: 80
可以说在监听端口80的容器中使用nginx,然后NodePort: 4980
将是暴露的端口。所以你会wget <Node IP>:4980
。
就修复您的具体情况而言,我建议不要将其复杂化并明确设置TargetPort
和NodePort
。
答案 1 :(得分:1)
除了&#34; NodePort&#34;服务类型还有一些其他方法可以与集群外部的kubernetes服务进行交互。也许他们会更自然&#34;而且容易: