문제
spec: schedule: "0 0 * * *"
1) kubernetes Cron Expression 에 위와 설정하면,
UTC 0시0분 (KST 9시0분) 에 실행된다.
절대 KST 시간이 되어주질 않는 문제가 있었다 . . .
2) kubernetes 에 설치한 SCDF 서버에서 schedule 을 등록해 pod 를 생성하고 있다.
[ kubernetes 에 설치한 SCDF 서버 ]
[pod1] [pod2] ...
3) kubernetes 버전 1.23 이다.
해결
[ 방법 1 ]
배포 pod 에 TZ=Asia/Seoul 환경변수(environment) 추가하기
웹 콘솔에서 추가해도 되고, yaml 편집에서 env 아래에 추가
name: TZ
value: Asia/Seoul
이렇게 하면 될 것도 같은데, 내 경우 배포하는 pod 에서 schedule 을 등록하는게 아니라
이 방법은 시도해보지 않았다.
[ 방법 2 ]
배포된 pod 에spec.timeZone 설정 추가하기
spec: timeZone: 'Asia/Seoul'
schedule: "0 0 * * *"
내 kubernetes 는 버전 1.23 으로, CronJobTimeZone 기능 적용되는 버전이 아니었기 때문에
kubernetes pod 는 KST 시간으로 설정되지 않았다.
[ 방법 3 ]
volumeMounts:
- name: tz-seoul
mountPath: /etc/localtime
volumes:
- name: tz-seoul
hostPath:
path: /usr/share/zoneinfo/Asia/Seoul
spec:
schedule: CRON_TZ=Asia/Seoul 4 15 * * *
![[Kubernetes] CronJob 스케줄 타임존을 UTC에서 KST로 바꾸기](/posts/kubernetes-cronjob-timezone-kst/images/image_1.jpg)