【问题标题】:How to make harbor reachable behind istio ingress?如何在 istio 入口后使港口可达?
【发布时间】:2020-05-05 16:14:37
【问题描述】:

我已经安装了Harbor如下:

helm install hub harbor/harbor \
  --version 1.3.2 \
  --namespace tool \
  --set expose.ingress.hosts.core=hub.service.example.io \
  --set expose.ingress.annotations.'kubernetes\.io/ingress\.class'=istio \
  --set expose.ingress.annotations.'cert-manager\.io/cluster-issuer'=letsencrypt-prod \
  --set externalURL=https://hub.service.example.io \
  --set notary.enabled=false \
  --set secretkey=secret \
  --set harborAdminPassword=pw  

一切都已启动并正在运行,但无法通过https://hub.service.example.io 访问该页面。同样的问题出现在这里Why css and png are not accessible? 但是如何在 Helm 中设置通配符*

更新

Istio 支持入口网关。例如,这可以在没有 Gateway 和 VirtualService 定义的情况下工作:

apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes-first
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 8080
  selector:
    app: hello-kubernetes-first
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes-first
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes-first
  template:
    metadata:
      labels:
        app: hello-kubernetes-first
    spec:
      containers:
        - name: hello-kubernetes
          image: paulbouwer/hello-kubernetes:1.8
          ports:
            - containerPort: 8080
          env:
            - name: MESSAGE
              value: Hello from the first deployment!
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: istio
  name: helloworld-ingress
spec:
  rules:
    - host: "hw.service.example.io"
      http:
        paths:
          - path: "/*"
            backend:
              serviceName: hello-kubernetes-first
              servicePort: 80
---

【问题讨论】:

    标签: kubernetes istio harbor


    【解决方案1】:

    我会说它不适用于 ingress 和 istio。

    如上所述here

    简单的入口规范,包含主机、TLS 和基于精确路径的匹配,无需路由规则即可开箱即用。但是,请注意,入口资源中使用的路径不应包含任何 .字符。

    例如,以下入口资源匹配 example.com 主机的请求,URL 为 /helloworld。

    $ kubectl create -f - <<EOF
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
    name: simple-ingress
    annotations:
      kubernetes.io/ingress.class: istio
    spec:
    rules:
    - host: example.com
      http:
        paths:
        - path: /helloworld
          backend:
            serviceName: myservice
            servicePort: grpc
    EOF
    

    但是,以下规则将不起作用,因为它们在路径和 ingress.kubernetes.io 注释中使用了正则表达式:

    $ kubectl create -f - <<EOF
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
    name: this-will-not-work
    annotations:
      kubernetes.io/ingress.class: istio
      # Ingress annotations other than ingress class will not be honored
      ingress.kubernetes.io/rewrite-target: /
    spec:
    rules:
    - host: example.com
      http:
        paths:
        - path: /hello(.*?)world/
          backend:
            serviceName: myservice
            servicePort: grpc
    EOF
    

    我假设您的 hello-world 正在工作,因为只有 1 个注释是入口类。

    如果你看一下harbor here 的注解,当你想在 istio 中使用 ingress 时可能会出现问题。


    但是如何在 Helm 中设置通配符 *?

    通配符在这里无关。正如我在answer 中提到的,您可以使用通配符或其他路径,这很好。查看入口路径here

    【讨论】:

      【解决方案2】:

      https://github.com/goharbor/harbor-helm/blob/master/templates/ingress/ingress.yaml#L5

      如果您看这里,他们会将路径硬编码为几个入口选项。 Envoy/istio 不是其中之一。但是,您可能很幸运——将expose.ingress.controller 设置为“gce”似乎可以按照您需要的方式设置路径。 (我从没用过 gce,也许他们甚至用过 istio?)

      编辑-原始答案如下。显然,您可以在 istio 中启用一个入口控制器。上面绝对没有文档,但我应该期待什么?

      在你的情况下,掌舵不是你的问题。 istio 不使用 ingress 对象,它使用“网关”和“虚拟服务”。您无法使用 kubernetes.io/ingress.class 注解将应用配置为使用 istio 入口系统。

      (至少,这是我的经验,我在他们的文档中找不到任何与此相矛盾的东西,但完全有可能有一个 istio 入口控制器

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-01-19
        • 1970-01-01
        • 1970-01-01
        • 2019-04-18
        • 1970-01-01
        • 2013-11-15
        • 2019-11-01
        相关资源
        最近更新 更多