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:
- if I call http://domain.com/index.html the server responds with the asked page
- if I call http://domain.com I get a
503
return code, an nothing will reach the nginx container
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.