PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 5, 2022

[FIXED] How to allocate redis-sentinel pods on different nodes?

 September 05, 2022     kubernetes, redis, redis-sentinel     No comments   

Issue

I'm running the redis chart (https://artifacthub.io/packages/helm/bitnami/redis/15.7.0) as a dependency of a custom chart. I enabled sentinel, then the pods are running two containers (redis and sentinel). I'm using the default values for the chart and I defined 4 replicas. The cluster have 10 nodes and I notice that three redis-sentinel's pods run on a single node and only one runs in another node:

myapp-redis-node-0    2/2    Running    8d     ip    k8s-appname-ctw9v
myapp-redis-node-1    2/2    Running    34d    ip    k8s-appname-ctw9v
myapp-redis-node-2    2/2    Running    34d    ip    k8s-appname-ctw9v
myapp-redis-node-3    2/2    Running    34d    ip    k8s-appname-crm3k

This is the affinity section for the pod's:

spec:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - podAffinityTerm:
          labelSelector:
            matchLabels:
              app.kubernetes.io/component: node
              app.kubernetes.io/instance: myapp
              app.kubernetes.io/name: redis
          namespaces:
          - test
          topologyKey: kubernetes.io/hostname
        weight: 1

How I can do to have each pod on diferent nodes?

Thanks!


Solution

Thank you all for your answers. Finally I solved it with:

spec:
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchLabels:
            app.kubernetes.io/component: node
            app.kubernetes.io/instance: myapp
            app.kubernetes.io/name: redis
        namespaces:
        - test
        topologyKey: kubernetes.io/hostname

BTW, this is generated automatically by the chart by setting in values for master and replicas (I'm using v15.7.0):

podAntiAffinityPreset: hard


Answered By - Martín C.
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing