1、导出当前配置
kubectl get deployment <deployment-name> -n <namespace> -o yaml > deployment-patch.yaml2、编辑yaml文件
在 spec.template.spec 下添加 volumes 和 volumeMounts 字段。
apiVersion: apps/v1
kind: Deployment
metadata:
name: your-deployment-name
spec:
template:
spec:
containers:
- name: your-container-name
# ... 您容器原有的其他配置 ...
volumeMounts: # 添加容器卷挂载
- name: host-timezone-volume
mountPath: /etc/localtime # 挂载覆盖容器内的时区文件
readOnly: true # 建议设置为只读:cite[6]
volumes: # 定义 Pod 的卷
- name: host-timezone-volume
hostPath: # 使用宿主机路径
path: /usr/share/zoneinfo/Asia/Shanghai # 宿主机上具体的时区文件路径
type: File # 明确指定类型为文件:cite[5]3、应用新配置
kubectl apply -f deployment-patch.yaml4、验证配置
kubectl exec -it <新启动的Pod名称> -- date
















