Saturday, 25 July 2026

Setup Valkey (Open Source Redis) Prerequisites in AKS

 Valkey is the open source redis alternative. We have discussed getting AKS instance ready for Valkey in the post "Create AKS Cluster to Setup Valkey Cluster (Open Source Redis)". Let's look at the prerequisites for setting up Valkey.

First step is setting up a namespace for valkey in the AKS cluster.

# Namespace in aks_vnet for Valkey
---
apiVersion: v1
kind: Namespace
metadata:
  name: valkey
  labels:
    shared-gateway-access: "true"

We should create a kubernetes secret with valkey password. Ideally we should setup password with terraform and store it in a key vault. However, for poc let's just create a dummy password.

---
apiVersion: v1
kind: Secret
metadata:
  name: valkey-service-credentials
  namespace: valkey
type: Opaque
stringData:
  password: dummy_valkey_pwd # Use token ${valkey_password}$ and replace in pipline

A priority class should be setup, so that the custom services deployed without any other priority class defintion or specification will be assigned with the default priority class.

# 1 default priority class for system services
---
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: vk-system-highest-priority-linux
value: 10000000
globalDefault: true
description: "This priority class is used for highest priority valkey system services."

Next we need a storage account for Valkey disks.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  labels:
    app.kubernetes.io/instance: valkey
    app.kubernetes.io/name: valkey
    app.kubernetes.io/part-of: valkey
  name: valkey-storage
parameters:
  skuName: Standard_LRS # Premium_LRS is suitable for production workloads
provisioner: disk.csi.azure.com
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer

Once applied above storage class we can see it is created in the AKS cluster.


The next prerequisite we need is a service account to allow list and read pod information. This is required for valkey clsuter intialization and to run reheal job for valkey clsuter. These two jobs we will disucss in future posts. For now lets create the service account.

apiVersion: v1
kind: ServiceAccount
metadata:
  name: valkey-zone-lookup
  namespace: valkey
  labels:
    app.kubernetes.io/name: valkey-zone-lookup
    app.kubernetes.io/instance: valkey
    app.kubernetes.io/component: valkey-zone-lookup
    app.kubernetes.io/part-of: valkey

The service account should be defined with role to list and read pods. Then the role should be bound to the service account with a RoleBinding.

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: valkey-zone-lookup-pod-reader
  namespace: valkey
  labels:
    app.kubernetes.io/name: valkey-zone-lookup
    app.kubernetes.io/instance: valkey
    app.kubernetes.io/component: valkey-zone-lookup
    app.kubernetes.io/part-of: valkey
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["get", "list"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: valkey-zone-lookup-pod-reader
  namespace: valkey
  labels:
    app.kubernetes.io/name: valkey-zone-lookup
    app.kubernetes.io/instance: valkey
    app.kubernetes.io/component: valkey-zone-lookup
    app.kubernetes.io/part-of: valkey
subjects:
  - kind: ServiceAccount
    name: valkey-zone-lookup
    namespace: valkey
roleRef:
  kind: Role
  name: valkey-zone-lookup-pod-reader
  apiGroup: rbac.authorization.k8s.io

The other requirement is setting up nginx-gateway in the AKS cluster. You can refer to below bog posts. Since deploying new nginx gateway, switch from ingress nginx controller parts can be skipped in folowwing posts.


No comments:

Popular Posts