部署 Spring 微服务后,Kubernetes 中的负载均衡器未连接到 Google Cloud Platform 中提到的端口。
我们需要更改任何防火墙设置以连接到已部署的服务吗?
https://serverfault.com/questions/912734/kubernetes-connection-refused-during-deployment
部署 Spring 微服务后,Kubernetes 中的负载均衡器未连接到 Google Cloud Platform 中提到的端口。
我们需要更改任何防火墙设置以连接到已部署的服务吗?
https://serverfault.com/questions/912734/kubernetes-connection-refused-during-deployment
这很可能是您的 Kubernetes 服务和/或部署的问题。Service
GKE 将自动配置映射到资源的端口所需的防火墙规则。
确保您已port 80
在您的上公开Service
并将其映射到您Deployment
的上的有效端口Pods
下面是一个使用Deployment
andService
暴露 nginx pod 的示例:
部署.yaml:
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
服务.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 services
和kubectl describe pod <your pod name
>`
如果您仍然遇到问题,请提供上述两个kubectl
命令的输出。
祝你好运!