kubernetes redis 数据持久化

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 略


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值