helm启动radis-ha

前言:
helm启动redis集群,可用户生产环境。

1. 准备

2. 修改配置文件

以下修改 redis-ha/values.yaml

  • 修改密码
## Configures redis with AUTH (requirepass & masterauth conf params)
auth: true
redisPassword: yunweizhidao
  • 修改存储
persistentVolume:
  enabled: true
  ## redis-ha data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  # storageClass: "-"
  accessModes:
    - ReadWriteOnce
  size: 300Gi
  annotations: {}
  # reclaimPolicy per https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming
  reclaimPolicy: ""
  • 启用haproxy
haproxy:
  enabled: true
  # Enable if you want a dedicated port in haproxy for redis-slaves
  readOnly:
    enabled: true
    port: 6380
  replicas: 3
  image:
    repository: haproxy
    tag: 2.0.4
    pullPolicy: IfNotPresent
  • 其他
    比如资源限制和一些参数优化根据情况修改。

3. 启动服务

  • 创建namespace
[root@DoM01 redis-ha]# kubectl create namespace redis
  • 创建release
    进入redis-ha 目录执行
helm install redis-ha -n redis
  • 查看release
[root@DoM01 redis-ha]# helm list -n redis
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
redis-ha        redis           2               2021-02-01 13:43:34.01374826 +0800 CST  deployed        redis-ha-4.4.4  5.0.6

4. 查看

查看redis下资源如下:

[root@DoM01 redis-ha]# kubectl get all -n redis
NAME                                    READY   STATUS    RESTARTS   AGE
pod/redis-ha-haproxy-68d8dc6644-hmvsp   1/1     Running   0          8h
pod/redis-ha-haproxy-68d8dc6644-q7lkx   1/1     Running   0          8h
pod/redis-ha-haproxy-68d8dc6644-sd4mh   1/1     Running   0          8h
pod/redis-ha-server-0                   2/2     Running   0          13d
pod/redis-ha-server-1                   2/2     Running   0          13d
pod/redis-ha-server-2                   2/2     Running   0          13d


NAME                          TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                         AGE
service/redis-ha              ClusterIP   None           <none>        6379/TCP,26379/TCP              13d
service/redis-ha-announce-0   ClusterIP   10.1.3.165     <none>        6379/TCP,26379/TCP              13d
service/redis-ha-announce-1   ClusterIP   10.1.193.90    <none>        6379/TCP,26379/TCP              13d
service/redis-ha-announce-2   ClusterIP   10.1.145.245   <none>        6379/TCP,26379/TCP              13d
service/redis-ha-haproxy      NodePort    10.1.172.30    <none>        6379:30010/TCP,6380:30011/TCP   8h


NAME                               READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/redis-ha-haproxy   3/3     3            3           8h

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/redis-ha-haproxy-68d8dc6644   3         3         3       8h

NAME                               READY   AGE
statefulset.apps/redis-ha-server   3/3     13d

pod

3个无状态的 haproxy
3个有状态的 redis

service

  • 3个redis的常规 service

redis端口:6379/TCP
哨兵端口:26379/TCP

  • 1个redis的headless类型service

redis端口:6379/TCP
哨兵端口:26379/TCP

  • 1个haproxy的service(客户端连这两个端口

读写端口: 6379:30010/TCP
只读端口: 6380:30011/TCP


在这里插入图片描述

posted on 2021-08-17 18:49  运维开发玄德公  阅读(9)  评论(0编辑  收藏  举报  来源

导航