|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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了