【问题标题】:kube-proxy Couldn't find an endpoint for default/tomcat:http: missing service entrykube-proxy 找不到默认/tomcat 的端点:http:缺少服务条目
【发布时间】:2016-07-06 18:56:05
【问题描述】:

我使用操作系统 Centos 7。 我的豆荚:

apiVersion: v1
kind: Pod
metadata:
  name: tomcat
spec:
  containers:
  - image: ec2-73-99-254-8.eu-central-1.compute.amazonaws.com:5000/tom
    name: tomcat
    command: ["sh","-c","/opt/tomcat/bin/deploy-and-run.sh"]
    volumeMounts:
    - mountPath: /maven
      name: app-volume
    ports:
    - containerPort: 8080
  volumes:
  - name: app-volume
    hostPath:
      path: /maven

我的服务:

apiVersion: v1
kind: Service
metadata:
  name: tomcat
spec:
  ports:
    - name: http
      port: 80
      targetPort: 8080
      protocol: TCP
  selector:
    name: tomcat

服务看起来像:

# kubectl get svc
NAME         CLUSTER_IP      EXTERNAL_IP   PORT(S)   SELECTOR      AGE
kubernetes   10.254.0.1      <none>        443/TCP   <none>        14h
tomcat       10.254.206.26   <none>        80/TCP    name=tomcat   13h

还有 Pod:

# kubectl get pod
NAME      READY     STATUS    RESTARTS   AGE
tomcat    1/1       Running   0          13h

当我运行 Curl 时:

curl 10.254.206.26
curl: (56) Recv failure: Connection reset by peer

当时的 Kube-proxy 日志显示如下:

kube-proxy[22273]: Couldn't find an endpoint for default/tomcat:http: missing service entry
kube-proxy[22273]: Failed to connect to balancer: missing service entry

但是当我直接运行 curl 到 pod ip 地址和端口 8080 - 它工作正常。 当我运行命令kubectl get endpoints

NAME         ENDPOINTS             AGE
kubernetes   195.234.109.11:6443   14h
tomcat       <none>                14h

此输出中带有“none”的字段 ENDPOINTS 看起来很奇怪。 怎么了?

【问题讨论】:

    标签: kubernetes kube-proxy


    【解决方案1】:

    服务通过匹配标签来工作。您正在尝试根据 pod 的名称进行匹配。尝试将您的 pod 的元数据更改为

    metadata:
      name: tomcat
      labels:
        name: tomcat
    

    看看是否有帮助。

    【讨论】:

    • 非常感谢!问题出在标签上。
    猜你喜欢
    • 1970-01-01
    • 2019-09-19
    • 2015-03-07
    • 2011-04-10
    • 2023-02-16
    • 2010-09-26
    • 1970-01-01
    • 2022-10-06
    相关资源
    最近更新 更多