How to test different versions of backend services on Kubernetes?

2/7/2019

I have a frontend instance (Angular app on nginx), which proxies calls to backend under a specific domain (let's say backend-app). Everything's easy when there is only one instance of both backend and frontend - I name the Service backend-app and DNS resolves to the correct backend Deployment.

Let's say I have another version of backend which I would like to test before merging to master. As nginx configuration of frontend instance is hardcoded to proxy to backend-api, creating another Service under the same name for a newer version of backend doesn't work.

I considered these options:

  1. Making an environment variable and substituting domain name in nginx proxy configuration during runtime. This way I could be flexible about where do I want to route frontend calls to. Cons of this solution, as far as I have investigated, is that this approach beats the purpose of self-containment, that is, it becomes ambiguous what is the frontend's backend client and this type of configuration is prone to errors.
  2. Creating different namespace every time I want to test things. While this allows spinning the whole stack without any problem or conflict, it seems to me that it's a huge overhead to create namespaces just for testing something once.
  3. Having some fancy configurations combining labels and selectors. I couldn't think or find how to do it.

Any other opinions/suggestions you might have?

-- pkey
kubernetes
nginx
openshift
reverse-proxy

2 Answers

2/7/2019

Are you using open shift. If yes then you can divide load between services by percentage using route.
Check blue/green and canary deployment options for more details

-- Rajesh Deshpande
Source: StackOverflow

2/7/2019

Try this approach

add label name:backend-1 to backend1 pod
add label name:backend-2 to backend2 pod

create a service using backend-1 selector.

to test against other backend, say backend2, all you have to do is edit the service yaml file and update the selector. you can toggle this way to test between backend1 and backend2

-- P Ekambaram
Source: StackOverflow