Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Multi-Model Redis Database on Minikube for Developers

DZone's Guide to

Multi-Model Redis Database on Minikube for Developers

In this article, I'm going to show you how to quickly get started developing your application with a multi-model Redis database on Kubernetes.

· Database Zone ·
Free Resource

Running out of memory? Learn how Redis Enterprise enables large dataset analysis with the highest throughput and lowest latency while reducing costs over 75%! 

Setting up your development environment is rarely straightforward and hassle-free. What's more, given modern applications' appetite for polyglot persistence and containerized deployment, it becomes quite challenging to bootstrap your laptop with all the infrastructural goodness needed for a simple "Hello, World!" In this article, I'm going to show you how to quickly get started developing your application with a multi-model Redis database on Kubernetes.

A multi-model database is one that supports multiple data models against a single backend. While Redis is, at its core, a key-value-like data structures store. Modules can extend it in almost any conceivable way. Presently, Redis Labs' open-source modules add the following capabilities to Redis:

  • Full-text search, aggregations, and secondary indexing with RediSearch
  • Graph databases and OpenCypher queries with Redis Graph
  • Machine learning model serving with Redis-ML
  • Document store with ReJSON
  • Probabilistic data types with ReBloom

Redis Enterprise already includes all these modules and can readily be deployed and run on Kubernetes. However, up until recently, there was no ready-made open-source Redis container image that delivered the same functionality. So I made one, automated its build, and put it on Docker Hub: https://hub.docker.com/r/redislabs/redismod/

The redismod container provides a default installation (i.e. not production-hardened) of a single-instance Redis server. It is also configured to load all five modules upon startup, but you're more than welcome to override this behavior. Running the container is just a matter of executing the following command at your terminal prompt:

docker run -p 6379:6379 redislabs/redismod

To use the redismod image (alongside your application's) on Kubernetes, assuming you don't have access to Kubernetes deployment, you can use Minikube. As stated by Minikube's documentation:

"Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day."

It takes just five steps to get your Minikube "cluster" up and running the redismod container:

  1. Install Minikube: https://kubernetes.io/docs/tasks/tools/install-Minikube/
  2. Start Minikube:
    Minikube start
  3. Deploy the redismod image:
    kubectl run redismod --image=redislabs/redismod --port=6379
  4. Expose the deployment:
    kubectl expose deployment redismod --type=NodePort
  5. Optionally, check that the pod's status is "running:"
    kubectl get pod

Once that's done, you can connect to the redismod service like so:

$ redis-cli -u $(minikube service --format "redis://{{.IP}}:{{.Port}}" --url redismod)
192.168.99.100:31501> PING
PONG
192.168.99.100:31501> MODULE LIST
1) 1) "name"
   2) "redis-ml"
   3) "ver"
   4) (integer) 9901
2) 1) "name"
   2) "ft"
   3) "ver"
   4) (integer) 10100
3) 1) "name"
   2) "graph"
   3) "ver"
   4) (integer) 1
4) 1) "name"
   2) "ReJSON"
   3) "ver"
   4) (integer) 10001
5) 1) "name"
   2) "bf"
   3) "ver"
   4) (integer) 10100

That's basically all there is to it — all you have to do now is connect to redismod from your application to start modeling your data with multiple modules on Redis. Questions? You can comment below or tweet me.

Running out of memory? Never run out of memory with Redis Enterprise databaseStart your free trial today.

Topics:
database ,redis ,kubernetes ,multi-model databases ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}