CC00259.CloudKubernetes——|KuberNetes&中间件容器化及helm.V06|——|中间件.v06|redis.v5.0.4|

本文介绍了如何使用Operator模式在Kubernetes环境中部署Redis集群。首先讲解了Operator的概念,然后详细阐述了创建redis-cluster-operator的过程,并尝试创建Redis集群,但由于内存限制未能成功完成实验。
摘要由CSDN通过智能技术生成
一、使用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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yanqi_vip

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值