kubernetes

List All Pod’s IP with a Specific Labels

In OpenShift or plain Kubernetes, we can have a multiple pods for a specific Deployment or DeploymentConfigs. But sometimes we want to know what are the IPs of those pods, lets say for a token refresh or cache refresh purpose.

Listing all pod’s IPs can be achieved by running below command,

$ kubectl get pods --output custom-columns=POD:.status.podIP \
	-l app=your-application-label --no-headers

It will gives a result of something like this,

10.128.6.66
10.128.5.181
10.130.2.12
10.131.7.74

Create A Simple Canary Deployment on Openshift

Openshift support multiple ways of deployements, such as traditional, canary and blue/green deployment. On this blog, im trying to create a simple canary deployment in order to see how can we leverage Openshift routing in deploy partially within a timeframe to reduce unwanted risks.

First we create two simple hello world app, one on top of PHP, and another one is on top of Java. We call my-blue and my-green. The goal of this scenario is to partially moving traffic from my-blue to my-green seamlessly.

oc new-app registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift~https://github.com/edwin/hello-world --name=my-blue
oc new-app php:7.0~https://github.com/edwin/php-helloworld --name=my-green

First is giving a 100percent traffic to my-blue microservice.

oc expose svc/my-blue --name=my-bluegreen

Then gradually reduce it to 75 percent,

oc set route-backends my-bluegreen my-blue=75 my-green=25 

And 15 percent,

oc set route-backends my-bluegreen my-blue=15 my-green=85 

Until the end is 100 percent of traffic goes to my-green.

oc set route-backends my-bluegreen my-green=100 

We can test the url output with below curl command

curl http://your-openshift-url