簡體   English   中英

具有多個端口的Istio網關| 服務僅在端口80上響應

[英]Istio Gateway With multiple ports | service is responding only on port 80

嘿,所以我為同一域(例如example.com端口80和8083配置了網關。 現在,當我使用以下配置文件創建屬性時,一切都將啟動並運行。

問題是我在服務和virtualService中使用了8083 ,但是我從80處的服務獲得響應,在8083獲得連接超時。

無法理解為什么服務在80而不是8083上響應。我想將兩個端口都保留在網關中,但是在服務中定義和入口端口8083時,它應該專門在8083上響應。

在此感謝您的反饋。

apiVersion: v1
data:
  my.databag.1: need_triage
kind: ConfigMap
metadata:
  name: my-service-env-variables
  namespace: api

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: my-service
  name: my-service-service-deployment
  namespace: api
spec:
  replicas: 1
  template:
    metadata:
      annotations:
        traffic.sidecar.istio.io/excludeOutboundIPRanges: 0.0.0.0/0
      labels:
        app: my-service-service-deployment
    spec:
      containers:
      - env:
        - name: my.variable
          valueFrom:
            secretKeyRef:
              key: my_token
              name: my.variable
        envFrom:
        - configMapRef:
            name: my-service-env-variables
        image: imaagepath:tag
        name: my-service-pod
        ports:
        - containerPort: 8080
          name: mysvcport
        resources:
          limits:
            cpu: 700m
            memory: 1.8Gi
          requests:
            cpu: 500m
            memory: 1.7Gi

---
apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: api
spec:
  ports:
  - port: 8083
    protocol: TCP
    targetPort: mysvcport
  selector:
    app: my-service-service-deployment

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-service-ingress
  namespace: api
spec:
  gateways:
  - http-gateway
  hosts:
  - my-service.example.com
  http:
  - route:
    - destination:
        host: my-service
        port:
          number: 8083
---
apiVersion: v1
items:
- apiVersion: networking.istio.io/v1alpha3
  kind: Gateway
  metadata:
    clusterName: ""
    creationTimestamp: 2018-11-07T13:17:00Z
    name: http-gateway
    namespace: api
    resourceVersion: "11778445"
    selfLink: /apis/networking.istio.io/v1alpha3/namespaces/api/gateways/http-gateway
    uid: 694f66a4-e28f-11e8-bc21-0ac9e31187a0
  spec:
    selector:
      istio: ingressgateway
    servers:
    - hosts:
      - '*.example.com'
      port:
        name: http
        number: 80
        protocol: HTTP
    - hosts:
      - '*.example.com'
      port:
        name: tomcat-http
        number: 8083
        protocol: HTTP
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

您的配置有兩個問題:

  1. 您必須調用端口http-tomcat而不是tomcat-http ,請參閱命名端口的Istio要求
  2. 為了在端口8083上啟用入口,您必須重新部署istio-ingressgateway服務,並添加端口8083: helm template install/kubernetes/helm/istio/ --name istio-ingressgateway \\ --namespace istio-system -x charts/gateways/templates/service.yaml \\ --set gateways.istio-egressgateway.enabled=false \\ --set gateways.istio-ingressgateway.ports[0].port=80 \\ --set gateways.istio-ingressgateway.ports[0].name=http \\ --set gateways.istio-ingressgateway.ports[1].port=443 \\ --set gateways.istio-ingressgateway.ports[1].name=https \\ --set gateways.istio-ingressgateway.ports[2].port=8083 \\ --set gateways.istio-ingressgateway.ports[2].name=http-tomcat \\ | kubectl apply -f - helm template install/kubernetes/helm/istio/ --name istio-ingressgateway \\ --namespace istio-system -x charts/gateways/templates/service.yaml \\ --set gateways.istio-egressgateway.enabled=false \\ --set gateways.istio-ingressgateway.ports[0].port=80 \\ --set gateways.istio-ingressgateway.ports[0].name=http \\ --set gateways.istio-ingressgateway.ports[1].port=443 \\ --set gateways.istio-ingressgateway.ports[1].name=https \\ --set gateways.istio-ingressgateway.ports[2].port=8083 \\ --set gateways.istio-ingressgateway.ports[2].name=http-tomcat \\ | kubectl apply -f -

話雖如此,您真的必須啟用對端口8083的入口訪問嗎? 您可以在VirtualService為端口80定義一些路徑,例如/ tomcat / *,並將來自端口80的傳入流量定向到端口8083上的服務。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM