Kubernetes负载平衡器服务器连接被拒绝:默认的80端口正在工作



部署spring微服务后,Kubernetes中的负载均衡器没有连接到谷歌云平台中提到的端口。

是否有任何防火墙设置需要更改才能连接到已部署的服务?

https://serverfault.com/questions/912734/kubernetes-connection-refused-during-deployment

这很可能是Kubernetes服务和/或部署的问题。GKE将自动提供映射到Service资源的端口所需的防火墙规则。

确保已在Service上公开port 80,并将其映射到DeploymentPods上的有效端口

下面是一个使用DeploymentService来暴露nginxpod的示例:

部署人员: apiVersion: apps/v1 # API Version of this Object kind: Deployment # This Object Type metadata: # Allows you to specify custom metadata name: nginx # Specifies the name of this object spec: # The official specification matching object type schema selector: # Label selector for pods matchLabels: # Must match these label(s) app: nginx # Custom label with value template: # Template describes the pods that are created metadata: # Standard objects metadata labels: # Labels used to group/categorize objects app: nginx # The name of this template spec: # Specification of the desired behaviour of this pod containers: # List of containers belonging to this pod (cannot be changed/updated) - name: nginx # Name of this container image: nginx # Docker image used for this container ports: # Port mapping(s) - containerPort: 80 # Number of port to expose on this pods ip

service.yaml: apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: type: LoadBalancer selector: app: nginx ports: - name: http port: 80 targetPort: 80

要查看映射的ip地址(和端口(,可以运行:kubectl get serviceskubectl describe pod <your pod name>`

如果您仍然有问题,请提供上面两个kubectl命令的输出。

祝你好运!

相关内容

  • 没有找到相关文章

最新更新