当前位置:网站首页>OpenShift 4 - Deploy Redis Cluster with Operator
OpenShift 4 - Deploy Redis Cluster with Operator
2022-07-31 14:26:00 【dawnsky.liu】
《OpenShift 4.x HOL教程汇总》
说明:本文已经在OpenShift 4.10 环境中验证
在 OpenShift 中提供了丰富的 PaaS 软件,One of them is the Enterprise Edition Redis 集群软件.企业版 Redis Cluster software is passed OpenShift 的 OperatorHub 安装部署的,本文介绍如何安装 Redis Enterprise Operator,and use its configuration Redis 集群环境.
Redis 企业集群
Redis An enterprise cluster is a group with shared nothing/Nodes with symmetric architecture.“不共享”Refers to the various running inside a node Redis 分片(Redis 实例)互不感知,相互隔离,防止相互影响. “对称”是指 Redis Enterprise Cluster nodes all know the same thing:They each have all the information they need to take over the role of the cluster,This means that the cluster can survive node shutdown or replacement.更重要的是,It can be scaled linearly simply by adding more nodes.
Redis Enterprise clusters provide management API、图形 UI and proxy functions,Provides a single endpoint for applications、Sharded database transparent to developers and applications.It is also responsible for data replication、Shard placement and shard failover in a cluster.
在 Redis Enterprise Operator Contains the following two CRD 对象:
- Redis 企业集群(REC):一个用于创建 Redis enterprise cluster API.每个 Operator Deployment supports only one cluster.
- Redis 企业数据库(REDB):One for creating in Redis running on an enterprise cluster Redis 数据库的 API.
使用 Redis Enterprise Operator 创建 Redis Cluster 和 DB 过程如下:
1.一个 Redis Enterprise Cluster 自定义资源(“CR”)在 Operator 中被创建.
2. 集群 StatefulSet、Service Rigger、集群管理 Secret 、RS/UI 服务被创建.
3. 一个 Redis Enterprise DB 的 CR 在 Operator 中被创建.
4. Redis Enterprise DB created on the cluster,Database access credentials are stored in Kubernetes Secret 对象中.
5. Service Rigger Discover new databases and configure them Kubernetes 服务.
6. Application workloads use databases Secret and services to access Redis 数据.
安装 Redis Operator 并创建 Redis 集群
集群要求
为了在 OpenShift Deploy and run in the cluster Redis 集群,OpenShift The cluster needs to have at least 3 个 Worker 节点.At least there is 3GB Available memory space and 10GB 存储空间.
准备环境
- 创建项目.
$ REDIS_PROJ=my-redis
$ oc new-project $REDIS_PROJ
- 创建 SecurityContextConstraints 对象.
$ cat << EOF | oc -n my-redis apply -f -
kind: SecurityContextConstraints
apiVersion: security.openshift.io/v1
metadata:
name: redis-enterprise-scc
allowPrivilegedContainer: false
allowedCapabilities:
- SYS_RESOURCE
runAsUser:
type: MustRunAs
uid: 1001
FSGroup:
type: MustRunAs
ranges: 1001,1001
seLinuxContext:
type: RunAsAny
EOF
- 执行命令,为 ServiceAccount 提供 redis-enterprise-scc 权限.
$ oc adm policy add-scc-to-user redis-enterprise-scc system:serviceaccount:$REDIS_PROJ
安装 Redis Enterprise Operator,创建 Redis 集群
- 在 OperatorHub 中找到 Redis Enterprise Operator ,然后将其安装到 my-redis 命名空间下.

- 在安装好的 Redis Enterprise Operator Create one with the following configuration RedisEnterpriseCluster 实例.注意:将 uiServiceType 设为 LoadBalancer .
apiVersion: app.redislabs.com/v1
kind: RedisEnterpriseCluster
metadata:
name: rec
namespace: my-redis
spec:
redisEnterpriseNodeResources:
limits:
cpu: 2000m
memory: 2Gi
requests:
cpu: 2000m
memory: 2Gi
bootstrapperImageSpec:
repository: registry.connect.redhat.com/redislabs/redis-enterprise-operator
persistentSpec:
enabled: true
redisEnterpriseServicesRiggerImageSpec:
repository: registry.connect.redhat.com/redislabs/services-manager
redisEnterpriseImageSpec:
imagePullPolicy: IfNotPresent
repository: registry.connect.redhat.com/redislabs/redis-enterprise
nodes: 3
uiServiceType: ClusterIP
username: [email protected]
- 完成后可以在 OpenShift 的 “拓扑” to see deployment resources and status.

- 查看 Service.
$ oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rec ClusterIP None <none> 9443/TCP,8001/TCP 16m
rec-prom ClusterIP None <none> 8070/TCP 16m
rec-ui ClusterIP 172.30.210.112 <none> 8443/TCP 16m
redis-enterprise-operator-service ClusterIP 172.30.189.212 <none> 8443/TCP 17m
- (可选) 根据 rec-ui 服务创建 Route,然后获取 Route 的访问地址.There is also login Redis Username and password for the console.
$ oc create route passthrough rec-ui --service=rec-ui --insecure-policy=Redirect
$ oc get route rec-ui -o jsonpath=https://'{.spec.host}'; echo
$ oc get secret rec -o jsonpath="{.data.username}" | base64 --decode; echo
$ oc get secret rec -o jsonpath="{.data.password}" | base64 --decode; echo
- (可选) 登录 Redis 控制台,可以看到以下 create new database 界面.

Also accessible cluster 和 nodes 查看.
- Create the following configuration RedisEnterpriseDatabase 实例
apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
name: redb
namespace: my-redis
spec:
redisEnterpriseCluster:
name: rec
tlsMode: disable
- 完成后可以在 “所有实例” 中查看状态.

此时在 Redis The console is also available database 中看到 redb .
- 查看 Service 和 Pod,Confirm name rec-0、rec-1、rec-2 的 Pod 中的 2 个容器都运行正常.
$ oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rec ClusterIP None <none> 9443/TCP,8001/TCP 76m
rec-prom ClusterIP None <none> 8070/TCP 76m
rec-ui ClusterIP 172.30.210.112 <none> 8443/TCP 76m
redb ClusterIP 172.30.105.156 <none> 17933/TCP 60m
redb-headless ClusterIP None <none> 17933/TCP 60m
redis-enterprise-operator-service ClusterIP 172.30.189.212 <none> 8443/TCP 76m
$ oc get pod
NAME READY STATUS RESTARTS AGE
rec-0 2/2 Running 0 65m
rec-1 2/2 Running 0 64m
rec-2 2/2 Running 0 58m
rec-services-rigger-fdff5f664-z2k68 1/1 Running 0 65m
redis-enterprise-operator-767d5f6b67-lxg8r 2/2 Running 0 75m
- 获取访问 redb 的端口和密码
$ oc get secret redb-redb -o jsonpath="{.data.service_names}" | base64 --decode
redb, redb-headless
$ oc get secret redb-redb -o jsonpath="{.data.port}" | base64 --decode
17933
$ oc get secret redb-redb -o jsonpath="{.data.password}" | base64 --decode
PW7WIEKQ
- 进入名为 rec-0 的 pod,然后使用 redis-cli command and corresponding port and password access redb,Finally set and get name.
$ oc debug pod/rec-0
Defaulting container name to redis-enterprise-node.
Use 'oc describe pod/rec-0-debug -n redis' to see all of the containers in this pod.
Starting pod/rec-0-debug ...
Pod IP: 10.130.0.19
If you don't see a command prompt, try pressing enter.
sh-4.4$ redis-cli -h redb -p 17933
redb:17933> auth PW7WIEKQ
OK
redb:17933> set name lxy
OK
redb:17933> get name
"lxy"
参考
https://medium.com/@moreal70/redis-on-openshift-at-ibm-cloud-2c9a34f46b2b
https://community.intel.com/t5/Blogs/Thought-Leadership/Big-Ideas/Validating-Redis-Enterprise-Operator-on-Bare-Metal-with-Red-Hat/post/1386198
https://developer.redis.com/create/openshift/
https://darshanadinushal.blogspot.com/2021/02/redis-enterprise-on-openshift-to-manage.html
https://developer.redis.com/create/kubernetes/kubernetes-operator/
边栏推荐
- C# Get network card information NetworkInterface IPInterfaceProperties
- [Pytorch] torch.argmax() usage
- The paper manual becomes 3D animation in seconds, the latest research of Wu Jiajun of Stanford University, selected for ECCV 2022
- The use of thread pool two
- Unity学习笔记 关于AVPro视频跳转功能(Seeking)的说明
- leetcode:2032. 至少在两个数组中出现的值
- OpenShift 4 - 用 Operator 部署 Redis 集群
- redhat/openssl生成自签ca证书并使用
- "Listen to me, thank you" can be said in ancient poetry?Tsinghua University has developed an artifact of "Searching Sentences According to Meaning", which can search for the famous sayings you want wi
- Sentinel流量控制
猜你喜欢

多智能体协同控制研究中光学动作捕捉与UWB定位技术比较

The JVM a class loader

C# using ComboBox control

OpenShift 4 - 用 Operator 部署 Redis 集群

Motion capture system for end-positioning control of flexible manipulators

Open Inventor 10.12 重大改进--和谐版

IDEA连接MySQL数据库并使用数据

The Selenium IDE of the Selenium test automation

"Listen to me, thank you" can be said in ancient poetry?Tsinghua University has developed an artifact of "Searching Sentences According to Meaning", which can search for the famous sayings you want wi

OAuth2:搭建授权服务器
随机推荐
Resnet&API
NPM Taobao mirror (latest version) released a new version of npm mirror at 2021-11-21 16:53:52 [easy to understand]
The paper manual becomes 3D animation in seconds, the latest research of Wu Jiajun of Stanford University, selected for ECCV 2022
技能大赛训练题:ftp 服务攻防与加固
Motion capture system for end-positioning control of flexible manipulators
使用CompletableFuture进行异步处理业务
ADS communicate with c #
一篇文章讲清楚!数据库和数据仓库到底有什么区别和联系?
对数字化时代的企业来说,数据治理难做,但应该去做
已解决(pymysqL连接数据库报错)pymysqL.err.ProgrammingError: (1146,“Table ‘test.students‘ doesn‘t exist“)
Shell脚本经典案例:文件的备份
MySQL玩到这种程度,难怪大厂抢着要!
Nuget打包并上传教程
Detailed guide to compare two tables using natural full join in SQL
使用NVM进行node版本切换管理
The magic of SQL MERGE statement (detailed instructions)
The role of /etc/profile, /etc/bashrc, ~/.bash_profile, ~/.bashrc files
Network cable RJ45 interface pins [easy to understand]
Sentinel热点参数限流
2021 OWASP TOP 10 漏洞指南