简体   繁体   中英

Dynamically configuring routing to two set of pods

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.

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 Deployment s

eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM