We have an ASP.NET Core app that relies on a Redis cache for optimizing large payload responses. It is designed to tolerate cache failures (i.e it can’t connect or get a key/value pair) which means that non-persistence and a temporarily unavailable cache was not a big deal for us. So I decided to deploy a bare-bones Redis instance to our Kubernetes cluster and save us some money on Elasticache Redis at the same time. The following is a simple tutorial to demonstrate what was done.

My Redis deployment does not use a master/slave replication strategy. For more info on that deployment strategy Kubernetes has a good example that you can find here.

Config Walkthrough

Most of the magic is in one config. Let’s take a look at some of the important parts.

Redis Config

Fixing Security Warnings

The first important line to note is the prometheus.io/port annotation. You’ll notice we need this on both the service and deployment config. If you didn’t include these Prometheus annotations you’ll notice your logs fill up with the following security warning:

This is because Prometheus will attempt to scrape every target port exposed by your service and will send Host commands to your Redis instance on port 6379 .

What if we want actual metrics for Prometheus?