502 Kubernetes 服务 /microservice1/hello(Quarkus 应用程序)的 Azure Ingress 上的网关错误

问题描述 投票:0回答:1

我有一个在 Azure 上运行的 Kubernetes 集群,并为多个服务配置了 Ingress。这些服务之一 microservice1 是 Quarkus 应用程序。在本地, /microservice1/hello 端点运行良好。但是,当通过 Azure 入口访问它时,我收到 502 Bad Gateway 错误。

集群中的其他服务包括:

quarkus-service
可访问
/qs
react-service
可访问
/web

入口配置:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/acme-challenge-type: http01
    cert-manager.io/issuer: letsencrypt-prod
    kubernetes.io/ingress.class: azure/application-gateway
  name: simple-frontend-ingress
  namespace: dev
spec:
  rules:
    - host: example.dev.company.com
      http:
        paths:
          - path: /microservice1/
            pathType: Prefix
            backend:
              service:
                name: microservice1-service
                port:
                  number: 80
          - path: /qs
            pathType: Prefix
            backend:
              service:
                name: quarkus-service
                port:
                  number: 80
          - path: /web
            pathType: Prefix
            backend:
              service:
                name: react-service
                port:
                  number: 80
  tls:
    - hosts:
        - example.dev.company.com
      secretName: frontend-tls-prod

服务配置:

apiVersion: v1
kind: Service
metadata:
  name: microservice1-service
spec:
  selector:
    app: microservice1
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  type: ClusterIP

部署配置:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: microservice1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: microservice1
  template:
    metadata:
      labels:
        app: microservice1
    spec:
      containers:
        - name: microservice1
          image: myregistry.azurecr.io/microservice1:latest
          ports:
            - containerPort: 8080
          env:
            - name: quarkus.http.root-path
              value: /microservice1/

夸库斯

application.properties

# Quarkus HTTP Configuration
quarkus.http.host=0.0.0.0
quarkus.http.port=8080
quarkus.http.root-path=/microservice1/

# OIDC Configuration
quarkus.oidc.provider=microsoft
quarkus.oidc.client-id=YOUR_CLIENT_ID
quarkus.oidc.credentials.secret=YOUR_SECRET
quarkus.oidc.auth-server-url=https://example.b2clogin.com/example.onmicrosoft.com/B2C_1_susi/v2.0/

# Logging Configuration
quarkus.log.category."io.quarkus.oidc".min-level=TRACE
quarkus.log.category."io.quarkus.oidc".level=TRACE

# Microservices
quarkus.rest-client.microservice2.url=${MICROSERVICE2}
quarkus.rest-client.microservice3.url=${MICROSERVICE3}

# Database Configuration
quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.url=${DB_URL}
quarkus.datasource.username=${DB_USERNAME}
quarkus.datasource.password=${DB_PASSWORD}
quarkus.datasource.jdbc.max-size=20
quarkus.datasource.jdbc.min-size=2
quarkus.hibernate-orm.database.generation=update

编辑:添加了dockerfile

FROM registry.access.redhat.com/ubi8/openjdk-17:1.19

ENV LANGUAGE='en_US:en'


# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 build/quarkus-app/*.jar /deployments/
COPY --chown=185 build/quarkus-app/app/ /deployments/app/
COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/

# Set environment variables in Dockerfile
ENV DB_URL=""
ENV DB_USERNAME=""
ENV DB_PASSWORD=""

EXPOSE 8080
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

观察:

  1. 指向
    http://localhost:8080/microservice1/hello.
  2. 时,本地测试工作正常
  3. 入口应该是正确的,因为我有另一个 quarkus 和 React 应用程序正在运行。
  4. 其他服务(
    quarkus-service
    上的
    /qs
    react-service
    上的
    /web
    )已部署并正在子URL上工作

任何见解或故障排除提示将不胜感激!

azure kubernetes microservices kubernetes-helm quarkus
1个回答
0
投票

问题出在 azure 的后端设置中。自定义探针未设置到指定的服务

© www.soinside.com 2019 - 2024. All rights reserved.