首页 > 解决方案 > Micronaut 2.0.0 - 无法在 kubernetes 上调用另一个服务

问题描述

我有一个名为 Identity 的服务,我想从中调用另一个名为 Notification 的服务。这两种服务都是用 构建的Java 11Micronaut 2.0.0并且将部署在kubernetes.

通知服务的 kubernetes 清单如下所示 -

apiVersion: apps/v1
kind: Deployment
metadata:
  name: notification-service
  labels:
    app: notification-service
spec:
  selector:
    matchLabels:
      app: notification-service
  template:
    metadata:
      labels:
        app: notification-service
    spec:
      containers:
        - name: notification-service
          image: notification-service
          ports:
            - containerPort: 8080
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 5
            timeoutSeconds: 3
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 5
            timeoutSeconds: 3
            failureThreshold: 10
---
apiVersion: v1
kind: Service
metadata:
  name: notification-service
spec:
  type: NodePort
  selector:
    app: notification-service
  ports:
  - port: 8080
    protocol: TCP

为了调用此服务,我在身份服务中添加了一个声明性客户端,如下所示 -

@Client(id="notification-service")
public interface NotificationClient {

    @Get("/health")
    String checkHealth();
}

每当我在将checkHealth()方法注入任何服务或控制器后调用该方法时,请求就会卡住。如果我使用 Micronaut 版本 1.3.x 从任何服务进行调用,调用工作正常。

有人能帮忙吗?

标签: kubernetesjava-11micronautdocker-desktopmicronaut-client

解决方案


推荐阅读