首页 > 解决方案 > 如何在不重新启动应用程序的情况下在微服务副本之间动态共享数据

问题描述

我在 Kubernetes 上有一个微服务。它扩展到 4 个 pod。我创建了一个对象来使用rest api动态设置一些值。但是该对象将由rest api在单个pod上更新。我必须同时在另外 3 个具有单个 URL 的 pod 上共享相同的值,而无需重新启动应用程序。

我正在考虑使用 hazelcast 来满足这个要求,但它需要我无法提供的管理员权限。

错误

{"date":"2019-03-19T08:30:32.920+00:00","loglevel":"ERROR","logger_name":"com.hazelcast.internal.cluster.impl.DiscoveryJoiner","thread_name":"main","message":"[10.128.10.37]:5701 [some-group] [3.10.2] Failure executing: GET at: https://kubernetes.default.svc/api/v1/namespaces/somespace/endpoints/some-service . Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. endpoints \"some-service\" is forbidden: User \"system:serviceaccount:some-test:default\" cannot get endpoints in the namespace \"somespace\": User \"system:serviceaccount:some-test:default\" cannot get endpoints in project \"somespace\".","stack_trace":"io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: https://kubernetes.default.svc/api/v1/namespaces/gaming/endpoints/some-service . Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. endpoints \"some-service\" is forbidden: User \"system:serviceaccount:some-test:default\" cannot get endpoints in the namespace \"gaming\": User \"system:serviceaccount:some-test:default\" cannot get endpoints in project \"gaming\".\n\tat io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:470)\n\tat io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:407)\n\tat io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:379)\n\tat io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:343)\n\tat io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleGet(OperationSupport.java:312)\n\tat io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleGet(OperationSupport.java:295)\n\tat io.fabric8.kubernetes.client.dsl.base.BaseOperation.handleGet(BaseOperation.java:787)\n\tat io.fabric8.kubernetes.client.dsl.base.BaseOperation.getMandatory(BaseOperation.java:217)\n\tat io.fabric8.kubernetes.client

标签: javaspring-bootkubernetesmicroservices

解决方案


推荐阅读