【问题标题】:Unable to get to microservice无法访问微服务
【发布时间】:2018-12-19 06:28:16
【问题描述】:

使用

  • minikube 0.23
  • kubectl 1.8x
  • istio 0.2.10

启用自动 sidecar 注入并使用所有正确的插件启动 minikube

minikube start --vm-driver=xhyve --extra-config=apiserver.Admission.PluginNames="Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,GenericAdmissionWebhook,ResourceQuota" --kubernetes-version=v1.7.5

我看到微服务旁边的小车。

NAME                       READY     STATUS    RESTARTS   AGE
microse-598544478f-hs8pv   2/2       Running   2          1d

但我现在无法在启用 istio 的情况下访问患者微服务。

export GATEWAY_URL=$(kubectl get po -n istio-system -l istio=ingress -o 'jsonpath={.items[0].status.hostIP}'):$(kubectl get svc istio-ingress -n istio-system -o 'jsonpath={.spec.ports[0].nodePort}')

curl -iv -H "Content-Type: application/json" -X PUT $GATEWAY_URL -d '{"firstField":"firstData"}'

我得到以下信息:

* Rebuilt URL to: 192.168.64.4:31496/
*   Trying 192.168.64.4...
* TCP_NODELAY set
* Connected to 192.168.64.4 (192.168.64.4) port 31496 (#0)
> PUT / HTTP/1.1
> Host: 192.168.64.4:31496
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 84
> 
* upload completely sent off: 84 out of 84 bytes
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< date: Fri, 03 Nov 2017 13:53:31 GMT
date: Fri, 03 Nov 2017 13:53:31 GMT
< server: envoy
server: envoy
< connection: close
connection: close
< content-length: 0
content-length: 0

< 
* Closing connection 0

在没有 istio 的情况下执行此 PUT 没有问题。感谢您的帮助。

【问题讨论】:

    标签: istio


    【解决方案1】:

    您是否为您的服务创建了 Ingress 资源?你需要这样的东西:

    cat <<EOF | kubectl apply -f -
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: gateway
      annotations:
        kubernetes.io/ingress.class: "istio"
    spec:
      rules:
      - http:
          paths:
          - path: /.*
            backend:
              serviceName: <your service name>
              servicePort: <your service port>
    EOF
    

    【讨论】:

      猜你喜欢
      • 2019-11-15
      • 2017-07-26
      • 2019-10-22
      • 2019-11-11
      • 1970-01-01
      • 2020-03-04
      • 1970-01-01
      相关资源
      最近更新 更多