【发布时间】:2018-08-21 15:34:42
【问题描述】:
我目前创建了这个kubernetes file:用于在 GCloud 上的集群中部署两个 API。我曾尝试在 kind Service 上制作两种“类型”。 首先,我将服务类型设置为 NodePort 并且无法连接到它,之后我尝试使用 LoadBalancer,尽管即使使用外部 IP 和 Endpoints 我也无法访问任何 API。
apiVersion: apps/v1
kind: Deployment
metadata:
name: xxxxxxxxxxxxx
labels:
app: xxxxxxxx
spec:
replicas: 1
selector:
matchLabels:
app: xxxxxxxxx
template:
metadata:
labels:
app: xxxxxxxx
spec:
containers:
- name: xxxxx
image: xxxxxxxxx
ports:
- containerPort: 3000
---
kind: Service
apiVersion: v1
metadata:
name: xxxxxxxxx
spec:
selector:
app: xxxxxxxx
ports:
- protocol: TCP
port: 8080
targetPort: 3000
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: yyyyyy
labels:
app: yyyyyy
spec:
replicas: 1
selector:
matchLabels:
app: yyyyyy
template:
metadata:
labels:
app: yyyyyy
spec:
containers:
- name: yyyyyy
image: yyyyyy
ports:
- containerPort: 3000
---
kind: Service
apiVersion: v1
metadata:
name: yyyyyy
spec:
selector:
app: yyyyyy
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: LoadBalancer
有人可以帮我解决这个问题吗?
问候。
【问题讨论】:
-
1.如果您想将服务公开为 type:nodePort,那么您可以使用节点外部 IP 结合分配给服务的 nodePort(即 xxx.xxx.xxx.xxx:31000)到达 pod,或者您需要使用 @ 987654322@ 可以联系到外部。
-
2.如果使用 type:LoadBalancer:验证 TCP 负载均衡器中配置的节点是否健康,可以接收流量,如果它们被列为不健康,那么他应该验证配置端口中的 Service IP 和 Endpoint (pod) IP 是否可达。为此,您可以 SSH 进入其中一个 Google Kubernetes Engine 节点并 curl 内部 IP: SVC-IP:端口 Endpoint-IP:端口 如果这没有回复,那么您将需要 SSH 进入 pod 并验证它是否正常工作在 localhost:3000 或验证服务可能正在侦听的端口。
标签: kubernetes google-kubernetes-engine