使用 Kubernetes 部署 Quarkus 应用程序

Deploying Quarkus Apps with Kubernetes

我正在尝试使用 Kubernetes 部署 example Quarkus app。当我 运行 它处于 dev 模式 mvn quarkus:dev -Dquarkus.http.port=8080 时,一切都很好。但是当我部署并转到端点 localhost/rest-json 时,它显示 RESTEASY003210: Could not find resource for full path: http://rest-json-http/。我正在使用 ingress-nginx。我错过了什么? k8s 清单有什么问题吗?

这是我的 application.yml:

quarkus:
  http:
    cors:
      ~: true
    root-path: /rest-json

deployment.yml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rest-json
  namespace: default
  labels:
    app: rest-json
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rest-json
  template:
    metadata:
      labels:
        app: rest-json
    spec:
      containers:
        - name: rest-json
          image: quarkus/rest-json-jvm:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8080

service.yml:

apiVersion: v1
kind: Service
metadata:
  name: rest-json-http
  namespace: default
spec:
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
      name: http
  selector:
    app: rest-json

ingress.yml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rest-json-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: "/"
    nginx.ingress.kubernetes.io/upstream-vhost: "rest-json-http"
spec:
  rules:
    - host: localhost
      http:
        paths:
          - path: /rest-json
            pathType: Prefix
            backend:
              service:
                name: rest-json-http
                port:
                  number: 8080

这是要重现的 repo github.com/miador/rest-json-quickstart

尝试改变这个:

nginx.ingress.kubernetes.io/rewrite-target: "/"

还有这个:

- path: /rest-json/(.+)

然后访问:http:///localhost/rest-json/fruits.html

Here你可以看到更多关于入口路径匹配的信息。