同步pod容器内时区

同步pod容器内时区

1、直接修改镜像的时间设置,好处是应用部署时无需做特殊设置,但是需要手动构建Docker镜像。

2、部署应用时,单独读取主机的“/etc/localtime”文件,即创建pod时同步时区,无需修改镜像,但是每个应用都要单独设置。


实例:


[root@lab2 dandang]# cat dandang.v1.yaml 
apiVersion: v1
kind: ReplicationController
metadata:
  name: dandang
  namespace: development
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: dandang
    spec:
      containers:
      - name: dandang
        image: 10.1.1.71:5000/library/dandang.ceshi:v1
        volumeMounts:
        - name: host-time
          mountPath: /etc/localtime
        ports:
        - containerPort: 8080
      volumes:
      - name: host-time
        hostPath:
          path: /etc/localtime
---
apiVersion: v1
kind: Service
metadata:
  name: dandang
  namespace: development
spec:
  type: NodePort
  ports: 
  - port: 8080
    nodePort: 30320
    targetPort: 8080
  selector:
    name: dandang
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: dandang
  namespace: development
spec:
  rules:
  - host: www.dandang.com      
    http:
      paths:
      - path: /
        backend:
          serviceName: dandang
          servicePort: 8080

参照文档:

https://blog.csdn.net/u013201439/article/details/79436413

 

posted @ 2019-02-09 14:33  effortsing  阅读(696)  评论(0编辑  收藏  举报