如何处理 K8S 启动的POD,默认时区不准的问题。
[root@master bin]# kubectl get pod
NAME READY STATUS RESTARTS AGE
elasticsearch-b4489c797-cc28f 1/1 Running 0 152m
eureka-0 1/1 Running 0 4d2h
mysql-ddd86f8fb-7shp9 1/1 Running 0 8h
nginx-0 1/1 Running 0 4d1h
redis-0 1/1 Running 0 8d
zuul-0 1/1 Running 0 4s
[root@elasticsearch-b4489c797-cc28f elasticsearch]# date
Tue Jan 12 09:58:27 UTC 2021
[root@elasticsearch-b4489c797-cc28f elasticsearch]# exit
exit
[root@master bin]# kubectl get podpreset
error: the server doesn't have a resource type "podpreset"
添加一行配置- --runtime-config=settings.k8s.io/v1alpha1=true,enable-admission-plugins后面增加PodPreset。
[root@master bin]# vim /etc/kubernetes/manifests/kube-apiserver.yaml
[root@master bin]# kubectl get podpreset
No resources found in default namespace.
[root@master bin]# vim preset.yml
[root@master bin]# cat preset.yml
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: allow-tz-env
namespace: default
spec:
selector:
matchLabels:
env:
- name: TZ
value: Asia/Shanghai
[root@master bin]# kubectl create -f preset.yml
podpreset.settings.k8s.io/allow-tz-env created
[root@master bin]# kubectl get podpresets
NAME CREATED AT
allow-tz-env 2021-01-12T09:46:00Z
[root@master bin]# kubectl delete pod elasticsearch-b4489c797-cc28f
pod "elasticsearch-b4489c797-cc28f" deleted
[root@master bin]# kubectl get pod
NAME READY STATUS RESTARTS AGE
elasticsearch-b4489c797-f2pw7 1/1 Running 0 8s
eureka-0 1/1 Running 0 4d2h
mysql-ddd86f8fb-7shp9 1/1 Running 0 8h
nginx-0 1/1 Running 0 4d1h
redis-0 1/1 Running 0 8d
zuul-0 1/1 Running 0 10m
[root@master bin]# kubectl exec -it elasticsearch-b4489c797-f2pw7 /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.
[root@elasticsearch-b4489c797-f2pw7 elasticsearch]# date
Tue Jan 12 17:59:08 CST 2021