【发布时间】:2020-11-23 23:20:54
【问题描述】:
我是 Kubernetes/OCP 世界的新手,我将我的应用程序部署到 OCP 命名空间并尝试连接到同样位于同一命名空间中的 gemfire 服务器。为了访问,我创建了一个ClusterIPService:ocp-gemfire。此服务公开10334 和40404 端口,并且相同的端口在下划线容器中公开。
我的期望是,当我通过此服务时,它应该从我的应用程序连接如下:
ocp-gemfire/xx.xx.xx.xx(Service IP):10334
ocp-gemfire/xx.xx.xx.xx(Service IP):40404
但实际情况是,它映射到下划线Pod 名称而不是 IP。我能够从两个端口上的应用程序远程登录 IP 或服务名称;但是这个 Pod 名称是不可解析的。
我不确定为什么它映射到Pod 名称而不是 IP ?
2020-08-03 16:55:20 INFO - AutoConnectionSource discovered new locators [myapp-gemfire-1-9npl6:10334]
2020-08-03 16:55:20 WARN - Could not connect to: myapp-gemfire-1-9npl6:40404
java.net.UnknownHostException: myapp-gemfire-1-9npl6
我的服务:
apiVersion: v1
kind: Service
metadata:
labels:
app: ${APPLICATION_NAME}-gemfire
name: ${APPLICATION_NAME}-gemfire
namespace: ${PROJECT_NAMESPACE}
spec:
type: ClusterIP
ports:
- name: 10334-tcp
port: 10334
protocol: TCP
targetPort: 10334
- name: 40404-tcp
port: 40404
protocol: TCP
targetPort: 40404
selector:
app: ${APPLICATION_NAME}-gemfire
deploymentconfig: ${APPLICATION_NAME}-gemfire
【问题讨论】:
标签: kubernetes open-closed-principle