azurekubernetesazure-aksrancher

How to set pod system time in the Rancher Edit Yaml setting?


I have a need to set pod time to 6 months in past from todays current date. I am using Rancher for provisioning the pod, how to set pods date to 6 month before/during it starts (maybe in yaml file ?) ?


Solution

  • As per Rancher's official document, you cannot directly modify the pod's system time globally due to Kubernetes and Rancher's architecture as they rely on NTP synchronization and shared system clocks. Setting a pod's system time to 6 months in the past is not natively supported in Kubernetes or Rancher because containers share the host kernel and system time.

    Max you can do is, inside a container, use libfaketime library. It overrides the time for processes inside the container without modifying the host system time.

    or use environment variables to Set a Time Zone Pass the TZ environment variable when launching the container, install tzdata in the container to support custom time zones.

    Checkout this SO thread

    Found few official docs from Rancher as well for better clarity

    Rancher cluster configuration

    Example Cluster.ymls

    How to set and manage environment variables in Kubernetes