代码之家  ›  专栏  ›  技术社区  ›  mahendra

如何从浏览器访问istio mesh

  •  0
  • mahendra  · 技术社区  · 6 年前

    我试图在本地ubuntu16.04系统的minikube环境中将istio注入kubernetes。这是我的部署

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: nodejs-master
      labels:
        run: nodejs-master
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            run: nodejs-master
        spec:
          containers:
          - name: nodejs-master
            image: hegdemahendra9/nodejs-master:v1
            ports:
            - containerPort: 8080
              protocol: TCP
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: nodejs-master
    spec:
      selector:
        run: nodejs-master
      ports:
        - name: port1
          protocol: TCP
          port: 8080
          targetPort: 8080
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: nodejs-slave
      labels:
        run: nodejs-slave
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            run: nodejs-slave
        spec:
          containers:
          - name: nodejs-slave
            image: hegdemahendra9/nodejs-slave:v1
            ports:
            - containerPort: 8081
              protocol: TCP
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: nodejs-slave
    spec:
      selector:
        run: nodejs-slave
      ports:
        - name: port1
          protocol: TCP
          port: 8081
          targetPort: 8081
      type: NodePort
    

    $kubect apply -f deployment.yaml

    我已经安装了istio via this method 以下是我的istio安装详细信息:

    $ kubectl get pods -n istio-system
    NAME                                      READY   STATUS      RESTARTS   AGE
    istio-citadel-6d7f9c545b-r665q            1/1     Running     0          2h
    istio-cleanup-secrets-qg4zh               0/1     Completed   0          2h
    istio-egressgateway-866885bb49-9l5rx      1/1     Running     0          2h
    istio-galley-6d74549bb9-jslss             1/1     Running     0          2h
    istio-ingressgateway-6c6ffb7dc8-rzvxb     1/1     Running     0          2h
    istio-pilot-685fc95d96-6296x              0/2     Pending     0          2h
    istio-policy-688f99c9c4-trg2j             2/2     Running     0          2h
    istio-security-post-install-gs6vk         0/1     Completed   0          2h
    istio-sidecar-injector-74855c54b9-j94qr   1/1     Running     0          2h
    istio-telemetry-69b794ff59-rqbzw          2/2     Running     0          2h
    prometheus-f556886b8-kj5ks                1/1     Running     0          2h
    
    
    $ kubectl get svc -n istio-system
    NAME                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                                                                   AGE
    istio-citadel            ClusterIP   10.108.144.211   <none>        8060/TCP,9093/TCP                                                                                                         2h
    istio-egressgateway      NodePort    10.99.160.138    <none>        80:32415/TCP,443:32480/TCP                                                                                                2h
    istio-galley             ClusterIP   10.97.0.188      <none>        443/TCP,9093/TCP                                                                                                          2h
    istio-ingressgateway     NodePort    10.97.75.20      <none>        80:31380/TCP,443:31390/TCP,31400:31400/TCP,15011:32188/TCP,8060:31372/TCP,853:31197/TCP,15030:30606/TCP,15031:31026/TCP   2h
    istio-pilot              ClusterIP   10.106.145.225   <none>        15010/TCP,15011/TCP,8080/TCP,9093/TCP                                                                                     2h
    istio-policy             ClusterIP   10.110.104.100   <none>        9091/TCP,15004/TCP,9093/TCP                                                                                               2h
    istio-sidecar-injector   ClusterIP   10.99.236.121    <none>        443/TCP                                                                                                                   2h
    istio-telemetry          ClusterIP   10.103.92.170    <none>        9091/TCP,15004/TCP,9093/TCP,42422/TCP                                                                                     2h
    prometheus               ClusterIP   10.105.31.126    <none>        9090/TCP      
    

    $kubectl get pods
    NAME                                   READY   STATUS    RESTARTS   AGE
    nodejs-master-6494d9dd66-pdbd6         2/2     Running   0          2h
    nodejs-slave-599cd5d676-6w4s8          2/2     Running   0          2h
    
    $ kubectl get svc
    NAME            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
    kubernetes      ClusterIP   10.96.0.1        <none>        443/TCP          1d
    nodejs-master   ClusterIP   10.104.99.240    <none>        8080/TCP         2h
    nodejs-slave    NodePort    10.101.120.229   <none>        8081:31263/TCP   2h
    

    这是我的大门

    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
      name: ms-gateway
    spec:
      selector:
        istio: ingressgateway # use istio default controller
      servers:
      - port:
          number: 80
          name: http
          protocol: HTTP
        hosts:
        - "*"
    ---
    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: mater-slave
    spec:
      hosts:
      - "*"
      gateways:
      - ms-gateway
      http:
      - match:
        - uri:
            prefix: /master
        route:
        - destination:
            host: nodejs-master
            port:
              number: 8080
    

    http://($minikube ip):kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}'/master
    

    http://192.168.99.100:31380/master

    但我发现了一个错误。有人请帮忙。

    提前谢谢。

    0 回复  |  直到 6 年前
        1
  •  0
  •   Rui    5 年前

    可能是服务端口的名称。它应该是“tcp-*”。 https://istio.io/docs/setup/kubernetes/additional-setup/requirements/