|NO.Z.00260|——————————|CloudNative|——|KuberNetes&中间件容器化及helm.V07|——|中间件.v07|redis.v5.0.4|custom-resources自定义形式创建集群|

一、自定义custom-resources形式创建集群
### --- 自定义custom-resources的形式创建集群
~~~     查看配置文件

[root@k8s-master01 redis-cluster-operator]# more deploy/example/custom-resources.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:                           // 资源请求
  image: redis:5.0.4-alpine
  masterSize: 3
  clusterReplicas: 1
  resources:
    limits:
      cpu: 100m
      memory: 100Mi
    requests:
      cpu: 100m
      memory: 100Mi
二、通过custom-resources的形式创建集群
### --- 通过custom-resources的形式创建集群

[root@k8s-master01 redis-cluster-operator]# kubectl create -f deploy/example/custom-resources.yaml
distributedrediscluster.redis.kun/example-distributedrediscluster created
三、查看service
### --- 查看service
~~~     程序连接的redis;可以在集群的内部去路由,这个集群的片在哪个位置,是可以去路由的
~~~     所以应用程序写的地址就是这个地址

[root@k8s-master01 redis-cluster-operator]# kubectl get svc
NAME                                TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                      AGE
example-distributedrediscluster     ClusterIP      10.100.56.42     <none>          6379/TCP,16379/TCP           27s
example-distributedrediscluster-0   ClusterIP      None             <none>          6379/TCP,16379/TCP           27s
example-distributedrediscluster-1   ClusterIP      None             <none>          6379/TCP,16379/TCP           27s
example-distributedrediscluster-2   ClusterIP      None             <none>          6379/TCP,16379/TCP           27s
example-distributedrediscluster     ClusterIP      10.100.56.42     <none>          6379/TCP,16379/TCP           62s
四、查看这个地址指向的是谁
### --- 查看这个地址指向的是谁
~~~     可以看到这6个实例已经启动完成
~~~     -0-0:表示主节点,-0-1:表示从节点

[root@k8s-master01 redis-cluster-operator]# kubectl get svc example-distributedrediscluster -oyaml
    redis.kun/name: example-distributedrediscluster
[root@k8s-master01 redis-cluster-operator]#  kubectl get po -l redis.kun/name=example-distributedrediscluster -owide
NAME                                      READY   STATUS    RESTARTS   AGE     IP               NODE           NOMINATED NODE   READINESS GATES
drc-example-distributedrediscluster-0-0   1/1     Running   0          2m53s   172.25.92.118    k8s-master02   <none>           <none>
drc-example-distributedrediscluster-0-1   1/1     Running   0          115s    172.27.14.225    k8s-node02     <none>           <none>
drc-example-distributedrediscluster-1-0   1/1     Running   0          2m53s   172.27.14.224    k8s-node02     <none>           <none>
drc-example-distributedrediscluster-1-1   1/1     Running   0          2m10s   172.18.195.33    k8s-master03   <none>           <none>
drc-example-distributedrediscluster-2-0   1/1     Running   0          2m53s   172.17.125.15    k8s-node01     <none>           <none>
drc-example-distributedrediscluster-2-1   1/1     Running   0          2m11s   172.25.244.238   k8s-master01   <none>           <none>

 
 
 
 
 
 
 
 
 

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  阅读(75)  评论(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

导航

统计

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