Dynamically configuring routing to two set of pods

11/7/2019

I have a web solution (angular application connecting to rest services) deployed in Kubernetes. I don't use any http sessions in my solution.

On upgrade of my rest services, I need to have both my pods with rest service version 1 and with rest service with version 2 available. Is there any way to setup a gateway/router where I can configure my endpoints dynamically?

I want /myendpoint?version=1 to route the traffic to the group of PODs with version 1, and /myendpoint?version=2 to route the traffic to the other group of PODs.

I must be able to dynamically add new endpoints without stopping the service.

-- Elena
kubernetes
kubernetes-ingress
kubernetes-pod
routing

1 Answer

11/7/2019

Separate components by deployment cycle

I would recommend to separate frontend app and REST backend. (I don't know if you have this already)

By separation, you can roll out new versions independently, with a deployment cycle for each app.

Two Deployment or N-1 compatibility

In addition, if you want to have multiple versions of the same app available for a longer period, you can deploy them in two different Deployments

e.g. Two Deployment, each with its own Service and Ingress that setup both.

kind: Ingress
spec:
  rules:
  - host: foo.bar.com
    http:
      paths:
      - path: /v1/*
        backend:
          serviceName: service-v1
          servicePort: 8080
      - path: /v2/*
        backend:
          serviceName: service-v2
          servicePort: 8080

Or you can have N-1 compatibility, so version 2 implements both /v1/ and /v2/ API.

Consider using CDN for static assets

It is usually recommended to deploy frontend on a CDN since it is static content. Sometimes your Javascript refers to other Javascript files using cache busting, then it is much easier to handle such setup if all your static content is available from a CDN.

-- Jonas
Source: StackOverflow