My scrapbook about almost anything I stumble upon in my tech world. If you find anything useful don't forget to give thumbs-up :)

Breaking

Friday, March 20, 2020

Set Timezone for Containers in Openshift


When running containers in Openshift (RedHat Implementation of Kubernetes), by default, it is using the timezone which is set in base container image but what if we want to run the image in different timezone ?
We can make that happen by tweaking few parameters, we will see the same in this post, please follow for details -

Scenario:
Let's assume, the base image is set for GMT (London) timezone, and you have to run it in EST timezone (GMT - 5).


Current Timezone in Image:

HowTo:
There is a very simple way to achieve it, simply set an environment variable for your openshift object (deployment config or statefulset), this sets TZ in any containers to the timezone specified.

oc set env OCP_OBJECT\NAME TZ=Timezone

# EST Timezone = America/Toronto
oc set env dc\d01 TZ=America/Toronto
oc set env sts\q03 TZ=America/Toronto


As soon as this command will be executed, your container will be redeployed with the new environment variable.

Timezone after setting up the TZ env variable:

Voila !! Now, your image is running in EST/EDT timezone, you can use this variable to set any timezone in which you want to run your container.

Hoping, you like the post, meet you soon with new post.. till then...Happy Learning !!



Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group

No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.