Configuring load balancer on GCP with ingress for https

9/10/2017

I have troubles configuring ingress service

This is how i configure kubernetes:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: web-spa-development-deployment
spec:
template:
  metadata:
    labels:
      app: web-spa-development-291
  spec:
    containers:
    - name: web-spa-development-291
      image: web-spa-development:292
      ports:
      - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: web-spa-development-service
spec:
  type: NodePort
  selector:
    app: web-spa-development-291
  ports:
    - port: 80
      targetPort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: development-ingress
annotations:
  kubernetes.io/ingress.global-static-ip-name: staging
spec:
tls:
- hosts:
  - dev-app.example.com
  secretName: wildcard-cert 
rules:
- host: dev-app.example.com
  http:
    paths:
    - backend:
        serviceName: web-spa-development-service
        servicePort: 80
      path: /*
    - backend:
        serviceName: web-spa-development-service
        servicePort: 80
      path: /
---

And in the image itself - a nodejs server, serving on port 80.

When the ingress is up and running - accessing the web app with http/https return the index.html in the response. However it doesnt return any of the static assests - .js, .css, .html.

What could possibly be the problem?

-- Vis Viva
google-cloud-platform
google-kubernetes-engine
kubernetes
load-balancing

1 Answer

9/10/2017

Try this:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: development-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: staging
spec:
  tls:
  - hosts:
    - dev-app.example.com
    secretName: wildcard-cert 
  rules:
  - host: dev-app.example.com
    http:
      paths:
      - backend:
          serviceName: web-spa-development-service
          servicePort: 80

See https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting

-- Janos Lenart
Source: StackOverflow