Simple routing from domain.com to /index.html with plain nginx deployment

Hi, I’am very new to istio and after the many examples I now trying to get a simple nginx (default nginx:alpine with no changes to it’s config) deployment to work properly.

My problem is:

What do I expect?
I expect the service to respond with the default route aka /index.html if no route is given, otherwise the asked file if it’s there.

APP_DOMAIN="test.domain.com"
APP_NAME="test-app"

cat << EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: ${APP_NAME}
  labels:
    app: ${APP_NAME}
    service: ${APP_NAME}
spec:
  ports:
  - port: 80
    name: http
  selector:
    app: ${APP_NAME}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: ${APP_NAME}
  labels:
    account: ${APP_NAME}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${APP_NAME}-v1
  labels:
    app: ${APP_NAME}
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ${APP_NAME}
      version: v1
  template:
    metadata:
      labels:
        app: ${APP_NAME}
        version: v1
    spec:
      serviceAccountName: ${APP_NAME}
      containers:
      - name: ${APP_NAME}
        image: nginx:alpine
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: ${APP_NAME}
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - ${APP_DOMAIN}
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ${APP_NAME}
spec:
  hosts:
  - "*"
  gateways:
  - ${APP_NAME}
  http:
  - route:
    - destination:
        host: ${APP_NAME}
        port:
          number: 80

---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: ${APP_NAME}
spec:
  host: ${APP_NAME}
  subsets:
  - name: v1
    labels:
      version: v1
---
EOF

I tried to do a rewrite, but this just works for http://domain.com// (yes…really two “/”)

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ${APP_NAME}
spec:
  hosts:
  - "*"
  gateways:
  - ${APP_NAME}
  http:
  - route:
    - destination:
        host: ${APP_NAME}
        port:
          number: 80
  - match:
    - uri:
        prefix: /
    redirect:
      uri: /index.html

Hopefully someone can give me a hint, what I missed here.

I am assuming APP_DOMAIN="test.domain.com", and you mentioned to call http://domain.com is a typo. (If not, I’d change APP_DOMAIN="domain.com")

I deployed your YAML files, removing the match and redirect from the VirtualService (deployed on Docker for Mac).

If I call: curl -H "Host: test.domain.com" http://localhost, I get back the expected response from Nginx.

Yes, the different domains where typos.
I complexly reinstalled everything and now it works…don’t know what was wrong in the first place. Most likely nothing related to the example.