Redis on Openshift at IBM cloud
Installation, configuration and data manipulation testing
Redis Operator on Openshift
Redis Enterprise Software is enterprise grade, distributed, in-memory NoSQL database server, fully compatible with open source Redis by Redis Labs. Redis Enterprise Software extends open source Redis and delivers stable high performance, zero-downtime linear scaling and high availability, with significant operational savings. Redis Enterprise provides a flexible and cost-effective data platform so developers can focus on rapid, high-quality development for sophisticated use cases that meet the needs of a modern digital enterprise. With Redis Enterprise, you can:
- Enjoy high performance and record-setting low latencies with minimal operational overhead
- Develop highly scalable microservices-based and Kubernetes-orchestrated applications
- Use versatile data structures for a variety of use cases, such as high-speed transactions, user session management, real-time analytics, caching and many more
- Leverage enterprise-grade operational controls for high availability, security and seamless scale
- Automate operational best practices for deploying and managing the Redis Enterprise data platform with built-in Kubernetes Operator support
- Deploy, manage and move applications to and from any cloud for seamless portability
Installation Redis operator
When you search “redis” at operatorHub, there are 2 redis. I selected “Redis Enterprise Operator”, which is validated by Red hat.
Prerequisite
- A minimum of 3 nodes which support the following requirements:
- RAM — At least 3GB with 4GB recommended
- Persistent Storage — At least 10GB of free space with 20GB recommended.
- A kubernetes version of 1.9 or higher
2. Create “SecurityContextConstraints”
https://raw.githubusercontent.com/RedisLabs/redis-enterprise-k8s-docs/master/openshift/scc.yaml
kind: SecurityContextConstraintsapiVersion: security.openshift.io/v1metadata: name: redis-enterprise-sccallowPrivilegedContainer: falseallowedCapabilities: - SYS_RESOURCErunAsUser: type: MustRunAs uid: 1001FSGroup: type: MustRunAs ranges: 1001,1001seLinuxContext: type: RunAsAny
3. Grant permission
oc adm policy add-scc-to-group redis-enterprise-scc system:serviceaccounts:<my-project>
Install & create instance
With default, you can install and create instance continuously as below. But user name, you can change this with yours.
When the installation is completed, there are 5 pods including 3 redis nodes. Each nodes are distributed in Openshift worker nodes automatically.
Setup Redis UI & Create database
- Check services
[root@parkhsu scripts]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rec ClusterIP None <none> 9443/TCP,8001/TCP,8070/TCP 17h
rec-ui ClusterIP 172.21.208.91 <none> 8443/TCP 17h
2. Create route
Secure route option is required, TLS termination-passthrough and Insecure Traffic-Redirect.
3. login Redis UI
Route shows URL for external connection like “https://redis-ui-redis.mycluster-seo01-b-846966-459b20226bb1c287a0d9b56673f326f3-0000.seo01.containers.appdomain.cloud/#/login” .
You can find userid and password at “Secret rec” , rec is Redis cluster name.
4. create database
Access the database “sampledb”
- Check services : when you created sampledb, service will be created automatically. But I am not sure how to use this service, although I have try to do many times.
[root@parkhsu ~]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rec ClusterIP None <none> 9443/TCP,8001/TCP,8070/TCP 19h
rec-ui ClusterIP 172.21.208.91 <none> 8443/TCP 19h
sampledb ClusterIP 172.21.169.64 <none> 15704/TCP 19h
2. And then I create new service with load balancer type . YAML sample is as below.
apiVersion: v1kind: Servicemetadata: name: sampledbspec: ports: - name: redis port: 15704 targetPort: 15704 type: LoadBalancer selector: redis.io/bdb-1: '1'
Load Balancer type Service is created.
[root@parkhsu scripts]# oc get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGErec ClusterIP None <none> 9443/TCP,8001/TCP,8070/TCP 16hrec-ui ClusterIP 172.21.208.91 <none> 8443/TCP 16hsampledb ClusterIP 172.21.169.64 <none> 15704/TCP 16hsampledb-headless ClusterIP None <none> 15704/TCP 16hsampledb-lb LoadBalancer 172.21.71.250 169.56.67.74 15704:30571/TCP 7m25s
3. Installing redis-cli on your remote server. It’s not required to install the redis server, but I want to use “redis-cli” on my remote server, which is ubuntu. The easiest way is to use “apt install redis”
4. logon to redis server
Host IP aress and Port number is defined at route above.
root@parkhsu2:~# redis-cli -h 169.56.67.74 -p 30571 -a password
169.56.67.74:30571> set a 'hello'
OK
169.56.67.74:30571> get a
"hello"
5. Sample cli commands are here for redis-cli. You can test for data manipulation.
infoset 1 "one"set 2 "two"set 3 "three"set 4 "four"set five "five"get 1get 4rename five 5get 5set 11 "eleven"keys 1*randomKeysave
Redis Desktop Manager to access sampledb
Redis Desktop Manager offers you an easy-to-use GUI to access your Redis databases and perform some basic operations:
- View keys as a tree
- CRUD keys
- Analyze memory usage for entire DB or for selected namespace in tree-view (redis-server >= 4.0 is required)
- List connected clients, Pub/Sub channels and Slow log commands
- Execute commands via shell
I installed it with trial version, which is required license with sign up.
- Configuration for sampledb
When you install “Redis Desktop Manager” on your windows desk top, you need to configure it with parameters, which are same with “redis-cli”.
Then you can check the data in sampledb and you can manipulate it directly in your desktop.