2

我正在尝试通过 Kubernetes 环境中的瘦客户端使用 Ignite 和我的 java 应用程序设置分布式缓存。

在我的 Kubernetes 集群中,我有 2 个带有 java 应用程序的 pod 和 2 个 ignite 的 pod。为了让 java pod 与 ignite pod 通信,我配置了一个瘦客户端来连接 ignite kubernetes 服务。使用这种配置,我期望负载平衡在 kubernetes 端。这是我在java代码中所做的:

ClientConfiguration cfg = new ClientConfiguration()
                    .setAddresses("ignite-service.default.svc.cluster.local:10800")
                    .setUserName("user")
                    .setUserPassword("password");
IgniteClient igniteClient = Ignition.startClient(cfg);

在从 ignite 存储和获取对象时,我删除了一个 ignite pod,过了一会儿,我收到错误消息,提示“Ignite 集群不可用”:

org.apache.ignite.client.ClientConnectionException:点燃集群不可用

通过这种行为,我假设 ClientConfiguration 类中的 setAddresses 方法存储了 pod 的 IP 之一,并将所有通信引导到该 pod。

这是这种方法中发生的事情吗?

点燃 2.7 版

Kubernetes 版本 1.12.3

4

2 回答 2

0

您需要传递多个 IP 地址才能在瘦客户端上启用故障转移(也称为自动重新连接)。在此处查找更多详细信息。

于 2019-09-25T20:33:34.757 回答
0

尽管您可能已经解决了这个问题,因为这个问题很久以前就发布了,但仍然在这里为其他人提供答案。

使用 Apache Ignite 版本(2.7+),您可以修改部署以使用 Kubernetes IP Finder。有了这个 Kubernetes 将负责发现和连接所有服务器和客户端节点。

TcpDiscoveryKubernetesIpFinder 模块将帮助您实现这一目标。

这是需要添加到您的配置中的发现 SPI(替换为适当的命名空间和服务名称)

    <property name="discoverySpi">
        <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
            <property name="ipFinder">
                <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder">
                    <constructor-arg>
                        <bean class="org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration">
                            <property name="namespace" value="default" />
                            <property name="serviceName" value="ignite" />
                        </bean>
                    </constructor-arg>
                </bean>
            </property>
        </bean>
    </property>

官方文档可以在这里找到 - https://ignite.apache.org/docs/latest/installation/kubernetes/amazon-eks-deployment

于 2021-06-17T03:21:30.223 回答