Following a small example of this setup. (POC)
- Create a project:
$ oc new-project bluegren
- Create a new app based on a git source image to get cats images
$oc new-app --name='blue' --labels=name="blue" php~https://github.com/wkulhanek/cotd.git --env=SELECTOR=cats
- Create a router to expose the blue pod service.
$oc expose service blue -l name=bluegreen
- Open a new terminal and make a curl for this route/service as follow.
$ while true; do curl -s $(oc get route blue --template='{{ .spec.host }}')/item.php | grep "data/images" | awk '{print $5}'; sleep 1; done
- Create a new app based on the same a git source image, however, which the same endpoint used above will return cities images. ( v2 of the same code source/application )
$oc new-app --name='green' --labels=name="green" php~https://github.com/wkulhanek/cotd.git --env=SELECTOR=cities
- Edit the router to switch the router to point for the latest pod created (green).
$oc patch route/blue -p '{"spec":{"to":{"name":"green"}}}'</code>
- Check that in the other terminal that the router starts to address all request for the second pod.
NOTE: It is possible to edit the route by the command $oc edit route <name>
For further information check the following docs: