Helm部署Redis-cluster集群 3主3从 7.5.0

Helm部署Redis-cluster

本文安装 Redis 3主3

helm包 redis-cluster-7.5.0
镜像版本 redis-cluster:6.2.6-debian-10-r193

[root@k8s-master-node1 redis-cluster]# vim /etc/exports
/redis *(sync,rw,no_root_squash)

[root@k8s-master-node1 redis]# exportfs -r
[root@k8s-master-node1 redis]# systemctl restart nfs
[root@k8s-master-node1 redis]# showmount -e
Export list for k8s-master-node1:
/redis *


创建sc

[root@k8s-master-node1 redis-cluster]# cat sc.yaml 
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: redis
provisioner: redis

创建pv

创建6个文件夹  为创建pv做准备
[root@k8s-master-node1 redis-cluster]#  mkdir -p /resid/redis{1..6}

helm里面写的用户是1001所以要给1001用户权限
[root@k8s-master-node1 redis-cluster]# chown -R 1001:root /redis

[root@k8s-master-node1 redis-cluster]# cat pv.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis1
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: redis
  nfs:
    server: 10.196.110.62
    path: /redis/redis1
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis2
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: redis
  nfs:
    server: 10.196.110.62
    path: /redis/redis2
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis3
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: redis
  nfs:
    server: 10.196.110.62
    path: /redis/redis3
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis4
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: redis
  nfs:
    server: 10.196.110.62
    path: /redis/redis4
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis5
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: redis
  nfs:
    server: 10.196.110.62
    path: /redis/redis5
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis6
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: redis
  nfs:
    server: 10.196.110.62
    path: /redis/redis6

修改vim values.yaml文件

global:
  imageRegistry: ""
  ## E.g.
  ## imagePullSecrets:
  ##   - myRegistryKeySecretName
  ##
  imagePullSecrets: []
  #设置存储类名字
  storageClass: "redis"
  #设置redis密码
  redis:
    password: "123456"
[root@k8s-master-node1 redis-cluster]# helm install redis ./

等待1分钟检测集群是否正常

[root@k8s-master-node1 redis-cluster]# kubectl exec statefulset/redis-redis-cluster -- redis-cli -h 127.0.0.1 -a 123456 cluster info
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_ping_sent:259
cluster_stats_messages_pong_sent:258
cluster_stats_messages_sent:517
cluster_stats_messages_ping_received:258
cluster_stats_messages_pong_received:259
cluster_stats_messages_received:517

你可能感兴趣的:(helm,k8s,redis,数据库,kubernetes,docker)