Kubernetes Container Timezone Management


I want to show how to change the container’s timezone which runs on the Kubernetes cluster. Basically, when you push a docker image from the docker hub you can easily check which timezone already defined for the image. I just defined a basic YAML file, creates a container that sleeps “100000” seconds. We used BusyBox image.

BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc.

Default TimeZone:

Step 1: Create a test  POD definition file 

#cat /tmp/defaulttz.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: defaulttz
  name: defaulttz
spec:
  containers:
  - image: busybox
    name: defaulttz
    args:
    - sleep
    - "100000"
#kubectl  create  -f  /tmp/defaulttz.yaml
pod/defaulttz created
#kubectl  get  pods
NAME        READY   STATUS    RESTARTS   AGE
defaulttz   1/1     Running   0          13s

Step 2: Deploy new POD without change 

When you create a new Pod with a POD definition file, it performs some steps like pull image, create container and start container etc.

#kubectl describe  pod defaulttz
.........
.........
  Type    Reason     Age        From               Message
  ----    ------     ----       ----               -------
  Normal  Scheduled  <unknown>  default-scheduler  Successfully assigned default/defaulttz to node01
  Normal  Pulling    2m30s      kubelet, node01    Pulling image "busybox"
  Normal  Pulled     2m24s      kubelet, node01    Successfully pulled image "busybox"
  Normal  Created    2m24s      kubelet, node01    Created container defaulttz
  Normal  Started    2m23s      kubelet, node01    Started container defaulttz

Now we can check the timezone variable for BusyBox image. First, you need to get a shell to the running container then run “date” command.

#kubectl exec  defaulttz  -it  --  /bin/sh
/ # date
Sat Dec 21 10:01:33 UTC 2019
/ # ls  -ld  /etc/localtime
-rw-r--r--    1 root     root           127 Sep 17 20:51 /etc/localtime
/ # strings  /etc/localtime
TZif2
TZif2
UTC0
/ #

New TimeZone:

Step 1: Create new POD definition file with spesific timezone.

Let’s try to change this timezone variable from UTC to GMT+3. We defined two variables that “volumeMounts” and “volumes”. A hostPath volume mounts a file or directory from the host node’s filesystem into your Pod. So we defined a new volume that shares the Timezone variable to the Pod. And we attached this volume to the container with volumeMounts method.

Connect one of the worker nodes that the container will schedule. You can define any timezone under this directory.

node01 $ ls  -ld /usr/share/zoneinfo/*
#cat /tmp/tzistanbul
apiVersion: v1
kind: Pod
metadata:
  name: tzistanbul
spec:
  containers:
  - name: tzistanbul
    image: busybox
    args:
    - sleep
    - "1000000"
    volumeMounts:
    - name: tz-istanbul
      mountPath: /etc/localtime
  volumes:
    - name: tz-istanbul
      hostPath:
        path: /usr/share/zoneinfo/Europe/Istanbul

Step 2: Deploy new POD

Now it’s time to create POD.

#kubectl create  -f  /tmp/tzistanbul
pod/tzistanbul created
#kubectl get  pods
NAME         READY   STATUS    RESTARTS   AGE
defaulttz    1/1     Running   0          13m
tzistanbul   1/1     Running   0          4s

Get a shell to the running Container:

#kubectl exec  tzistanbul  -it  --  /bin/sh

Step 3: Check TimeZone

Check if the container gets the timezone as you need.
/ # df -h /etc/localtime
Filesystem                Size      Used Available Use% Mounted on
/dev/vda1                44.1G     21.8G     20.0G  52% /etc/localtime
/ # ls  -ld  /etc/localtime
-rw-r--r--    1 root     root          1956 Oct  3 00:06 /etc/localtime
/ # date
Sat Dec 21 13:17:04 +03 2019
/ # strings  /etc/localtime
TZif2
EEST
TZif2
EEST
<+03>-3
/ #

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

200 Total Posts
Follow Me

14 Comments

  1. kamagra store in ny kamagra 100mg kamagra oral jelly how to use video kamagra 100 mg kamagra oral jelly vs cialis

  2. kamagra oral jelly 100 mg wirkungsdauer kamagra online kamagra bestellen rotterdam kamagra online super kamagra forum hr kamagra 100mg chewable tablets Caf 031189d

  3. free adult webcam sites cam to cam sites best cam to cam site. camgirl camgirl sexy cam girl. web cam sites cam sites like chatroulette adult cam sites free.

  4. sexcams free sex cam to cam fire sex cam. free webcam girls cam model hairy cam girls. free gay webcam sites adultfreewebcamsites.com chat cam sites. webcam sex videos teen webcam sex asian hidden cam sex. top adult webcam sites adultfreewebcamsites best free sex cam sites. ebony live sex cam live free sex cam sex webcam.

  5. cam sex live bestonlinesexcams1.com online sex cam. young girls on cam nude cam girls sexy dance girl. asian cam girls camgirls1.com asian cam girls. free cam sites adultfreewebcamsites.com best live webcam sites. web cam girls camgirl websites top web cam girl. cam sex bestonlinesexcams1 random cam sex.

  6. young girls on cam nude cam girls cams girl. camming camgirls1.com hottest cam girl. asian cam sex bestonlinesexcams1 teen hidden cam sex. best cam to cam sites adult live cam sites best cam sites for couples. nude cam girls best cam girl websites sexy dance girl. free sex web cam hidden cam sex tapes pakistani hidden cam sex.

  7. camming japanese cam girls anal cam girls. live webcam sex bestonlinesexwebcams.com teen web cam sex. cam sex online bestonlinesexcams1.com sex webcam. cam sites free adult web cam sites dirty cam sites. nude cam sites adult webcam sites best chat cam sites. free webcam girls free cam girls cam girl orgasm.

  8. random sex cam bestonlinesexwebcams mobile cam sex. sex cam sites online webcam sex young sex cam. other ebony cam sites cam sites that work on android dirty cam sites. model porn camgirls1.com online webcam girls. my free cam site adultfreewebcamsites.com top porn cam sites. webcam girls lesbian cam girls chaturbate cam girls.

  9. webcam model hotcamgirls1.com cam girl websites. camgirl hotcamgirls1.com best webcam girls. adult free webcam sites adultcamsites1 chatterbait cam site. free webcam sex cam sex online sex cam chat room. sex cam site free cam 2 cam sites webcam sites reviews. best cam to cam sites adultfreewebcamsites cam site reviews.

  10. I don't know if it's just me or if everyone else encountering problems with your site. It looks like some of the text within your posts are running off the screen. Can someone else please provide feedback and let me know if this is happening to them too? This may be a issue with my browser because I've had this happen previously. Kudos P.S. If you have a minute, would love your feedback on my new website re-design. You can find it by searching for «royal cbd» — no sweat if you can’t. Keep up the good work!

  11. Its not my first time to go to see this web site, i am browsing this website dailly and obtain nice data from here daily. P.S. If you have a minute, would love your feedback on my new website re-design. You can find it by searching for «royal cbd» — no sweat if you can’t. Keep up the good work!

  12. Good way of telling, and good paragraph to get data concerning my presentation subject, which i am going to convey in college. P.S. If you have a minute, would love your feedback on my new website re-design. You can find it by searching for «royal cbd» — no sweat if you can’t. Keep up the good work!

  13. private free sex cams sexcams00.online free safe sex cams.

Leave a Reply