|NO.Z.00259|——————————|CloudNative|——|KuberNetes&中间件容器化及helm.V06|——|中间件.v06|redis.v5.0.4|operator方式部署集群|

一、使用operator方式去部署redis
### --- 下载redis版本包:operator方式部署
~~~     下载redis-cluster-operator包文件

[root@k8s-master01 operator-redis]# git clone https://github.com/ucloud/redis-cluster-operator.git
### --- redis-cluster-operator配置文件详解

[root@k8s-master01 redis-cluster-operator]# more deploy/example/redis.kun_v1alpha1_distributedrediscluster_cr.yaml 
apiVersion: redis.kun/v1alpha1
kind: DistributedRedisCluster       // 自定的资源类型
metadata:
  annotations:
    # if your operator run as cluster-scoped, add this annotations
    redis.kun/scope: cluster-scoped
  name: example-distributedrediscluster
spec:
  # Add fields here
  masterSize: 3
  clusterReplicas: 1
  image: redis:5.0.4-alpine
~~~     以声明式的方法去创建一个redis集群,
  masterSize: 3                 // 这个redis集群定义了有几个master,有3个master
  clusterReplicas: 1            // 每个master有1个副本;也就说明这个位置会创建6个redis容器
  image: redis:5.0.4-alpine     // 使用的镜像版本是redis:5.0.4-alpine
二、创建redis-cluster-operator集群
### --- 创建redis集群
~~~     报错没有这个kind;说明就是没有配置operator

[root@k8s-master01 redis-cluster-operator]# kubectl create -f deploy/example/redis.kun_v1alpha1_distributedrediscluster_cr.yaml -n ratel-test1
error: unable to recognize "deploy/example/redis.kun_v1alpha1_distributedrediscluster_cr.yaml": no matches for kind "DistributedRedisCluster" in version "redis.kun/v1alpha1"
### --- 配置operator;创建CRD
~~~     地址:https://github.com/ucloud/redis-cluster-operator#deploy-a-sample-redis-cluster
~~~     注册DistributedRedisCluster和RedisClusterBackup自定义资源定义(CRD)。

[root@k8s-master01 redis-cluster-operator]# kubectl create -f deploy/crds/redis.kun_distributedredisclusters_crd.yaml
customresourcedefinition.apiextensions.k8s.io/distributedredisclusters.redis.kun created
[root@k8s-master01 redis-cluster-operator]# kubectl create -f deploy/crds/redis.kun_redisclusterbackups_crd.yaml
customresourcedefinition.apiextensions.k8s.io/redisclusterbackups.redis.kun created
### --- 命名空间范围的操作员监视和管理单个命名空间中的资源,
~~~     而集群范围的操作员监视和管理群集范围内的资源。
~~~     您可以选择以名称空间范围或集群范围运行您的操作员。

[root@k8s-master01 redis-cluster-operator]#  kubectl create -f deploy/service_account.yaml
serviceaccount/redis-cluster-operator created
[root@k8s-master01 redis-cluster-operator]# kubectl create -f deploy/cluster/cluster_role.yaml
clusterrole.rbac.authorization.k8s.io/redis-cluster-operator created
[root@k8s-master01 redis-cluster-operator]# kubectl create -f deploy/cluster/cluster_role_binding.yaml
clusterrolebinding.rbac.authorization.k8s.io/redis-cluster-operator created
[root@k8s-master01 redis-cluster-operator]# kubectl create -f deploy/cluster/operator.yaml
deployment.apps/redis-cluster-operator created
configmap/redis-admin created
### --- 查看创建的redis-cluster-operator

[root@k8s-master01 redis-cluster-operator]# kubectl get po  -owide
NAME                                      READY   STATUS    RESTARTS   AGE     IP              NODE           NOMINATED NODE   READINESS GATES
busybox                                   1/1     Running   15         7d21h   172.18.195.25   k8s-master03   <none>           <none>
redis-cluster-operator-6669898858-xqpqq   1/1     Running   0          95s     172.25.92.116   k8s-master02   <none>           <none>
三、创建redis集群(因内存不够导致实验失败)
### --- 创建redis集群

[root@k8s-master01 redis-cluster-operator]# kubectl apply -f deploy/example/redis.kun_v1alpha1_distributedrediscluster_cr.yaml 
distributedrediscluster.redis.kun/example-distributedrediscluster created
### --- 查看集群;显示是pending状态,查看记录,发现是内存不够
~~~     注:显示内存不够

[root@k8s-master01 redis-cluster-operator]# kubectl get po -owide
NAME                                      READY   STATUS    RESTARTS   AGE     IP              NODE           NOMINATED NODE   READINESS GATES
drc-example-distributedrediscluster-0-0   0/1     Pending   0          63s     <none>          <none>         <none>           <none>
drc-example-distributedrediscluster-1-0   0/1     Pending   0          13m     <none>          <none>         <none>           <none>
drc-example-distributedrediscluster-2-0   0/1     Pending   0          13m     <none>          <none>         <none>           <none>
redis-cluster-operator-6669898858-xqpqq   1/1     Running   0          31m     172.25.92.116   k8s-master02   <none>           <none>
[root@k8s-master01 redis-cluster-operator]# kubectl delete po drc-example-distributedrediscluster-0-0 
  Warning  FailedScheduling  16s   default-scheduler  0/5 nodes are available: 5 Insufficient memory.

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(31)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示