kubernetes redis 数据持久化

来源:互联网 发布:淘宝保养品店铺推荐 编辑:程序博客网 时间:2024/06/12 16:11

1.编写 configmap : redis-config 文件  就是 redis 的配置文件 这里略。

(1)创建configmap

$ kubectl create configmap example-redis-config --from-file=configmap/redis-config
(2)查看configmap 信息
$ kubectl get configmap example-redis-config -o yaml


2.编写 redis-rc.yml

apiVersion: v1
kind: Pod
metadata:
  name: redis
spec:
  containers:
  - name: redis
    image: f-registry:5000/redis_db
    env:
    - name: MASTER
      value: "true"
    ports:
    - containerPort: 6378
      hostPort: 6378
    resources:
      limits:
        cpu: "0.1"
    volumeMounts:
    - mountPath: /data
      name: data1
    #- mountPath: /data
    #  name: data2
    - mountPath: /usr/local/etc/redis
      name: config
  volumes:
    - name: data1
      #emptyDir: {}
      hostPath:
        path: /data/redis
    #- name: data2
      #hostPath:
        #path: /data/redis//usr/local/bin/redis-check-aof
    - name: config
      configMap:
        name: example-redis-config
        items:
        - key: redis-config
          path: redis.conf


3. 官方的 redis 镜像默认没有 redis.conf  编写 Dockerfile

FROM index.tenxcloud.com/docker_library/redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

redis.conf 略


原创粉丝点击