Istio custom Gateway in a namespace

4/29/2020

I'm trying to expose a Service with Istio Gateway and VirtualService following instructions at https://istio.io/blog/2019/custom-ingress-gateway

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: demo
  name: demo
  namespace: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      labels:
        app: demo
    spec:
      containers:
      - image: nginx
        name: nginx
---
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: demo
  name: demo
  namespace: demo
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: demo
  type: ClusterIP
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: demo-gw
  namespace: demo
spec:
  selector:
    app: demo
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: demo-vs
  namespace: demo
spec:
  hosts:
  - "example.com"
  gateways:
  - demo-gw
  http:
  - route:
    - destination:
        host: demo

I'm running a minikube cluster with minikube tunnel so that istio-ingressgateway has a LoadBalancer IP. I've modified /etc/hosts to point example.com to istio-ingressgateway Service IP like so

10.111.251.46 example.com

The request does seem to reach Envoy proxy. curl -v -X TRACE http://example.com returns

*   Trying 10.111.251.46...
* TCP_NODELAY set
* Connected to example.com (10.111.251.46) port 80 (#0)
> TRACE / HTTP/1.1
> Host: example.com
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< date: Wed, 29 Apr 2020 12:32:49 GMT
< server: istio-envoy
< content-length: 0
< 
* Connection #0 to host example.com left intact
* Closing connection 0
-- moazzem
envoyproxy
istio
kubernetes

1 Answer

4/30/2020

As @Piotr Malec mentioned in comments

The blog post You linked is outdated. This blog post was written assuming Istio 1, so some of this content may now be outdated.


I would recommend to use istio operator, since istio 1.5 that's the best option to add your custom ingress gateway.

There is open github issue about that, there are few ways to install it.

For example, with yaml from this comment you can install istio default profile with default ingress gateway and additionally it will create second ingress gateway in namespace dev.


Hope you find this useful.

-- jt97
Source: StackOverflow