<p>I'm using the excellent Redis based <a href="https://github.com/OptimalBits/bull" rel="noreferrer">Bull.js</a> as a job queue on Kubernetes.</p>

<p>It's configured as a cluster:</p>

<p><a href="https://i.stack.imgur.com/yZ4qm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yZ4qm.png" alt="enter image description here"></a></p>

<p>When Kubernetes restarts upon deployments, I run into this following error:</p>

<pre><code>BRPOPLPUSH { ReplyError: MOVED 2651 &lt;IP_ADDRESS&gt;:6379
at parseError (/usr/src/app/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/usr/src/app/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:302:14)
command:
{ name: 'brpoplpush',
args:
[ '{slack}:slack notifications:wait',
'{slack}:slack notifications:active',
'5' ] } }
</code></pre>

<p>Where <code>&lt;IP_ADDRESS&gt;</code> is, I <em>think</em> the cluster IP? I didn't configure this, but I'm trying to debug this. I want to know if I need to enable cluster mode for Bull.js or if this is a configuration issue outside of the Bull.js project?</p>

<p>Or is it a networking issue with K8s? </p>

<p>Would enabling: <a href="https://github.com/OptimalBits/bull#cluster-support" rel="noreferrer">https://github.com/OptimalBits/bull#cluster-support</a> be the solution? Is this the right approach?</p>

<p>Here is my code:</p>

<pre><code>import Queue from 'bull';
import config from 'config';
import { run as slackRun } from './tasks/send-slack-message';
import { run as emailRun } from './tasks/send-email';

const redisConfig = {
  redis: {
    host: config.redis.host,
    port: config.redis.port
  }
};

const slackQueue = new Queue('slack notifications', { ...redisConfig, ...{ prefix: '{slack}' } });
const emailQueue = new Queue('email notifications', { ...redisConfig, ...{ prefix: '{email}' } });

slackQueue.process(slackRun);
emailQueue.process(emailRun);

emailQueue.on('completed', (job, result) =&gt; {
  job.remove();
});

export { emailQueue, slackQueue };
</code></pre>

<pre><code>import { emailQueue, slackQueue } from 'worker/worker';

const queueOptions = {
  attempts: 2,
  removeOnComplete: true,
  backoff: {
    type: 'exponential',
    delay: 60 * 1000
  }
};

emailQueue.add(
  {
    params: {
      from: email,
      fromname: name,
      text: body
    }
  },
  queueOptions
);
slackQueue.add(
  {
    channelId: SLACK_CHANNELS.FEEDBACK,
    attachments: [
      {
        text: req.body.body
      }
    ]
  },
  queueOptions
);
</code></pre>

<p>This is the configmap:</p>

<pre><code>Name:         redis-cluster-config
Namespace:    default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;

Data
====
update-node.sh:
----
#!/bin/sh
REDIS_NODES="/data/nodes.conf"
sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" ${REDIS_NODES}
exec "$@"

redis.conf:
----
cluster-enabled yes
cluster-require-full-coverage no
cluster-node-timeout 15000
cluster-config-file nodes.conf
cluster-migration-barrier 1
appendonly yes
# Other cluster members need to be able to connect
protected-mode no

Events:  &lt;none&gt;
</code></pre>

bob_cobb
<p><a href="https://stackoverflow.com/questions/56140999/redis-master-slave-setup-on-kubernetes-throwing-error-brpoplpush-replyerror?noredirect=1#comment99043715_56140999">Hitobat</a> is right though.</p>

<p>If this doesn't help:</p>

<pre class="lang-js prettyprint-override"><code>const Redis = require('ioredis');
...
const ioCluster = new Redis.Cluster([redisConfig.redis]);
const slackQueue = new Queue('slack notifications', {
  prefix: '{slack}' ,
  createClient: () =&gt; ioCluster
});
const emailQueue = new Queue('email notifications', {
  prefix: '{email}' ,
  createClient: () =&gt; ioCluster
});
</code></pre>

<p>I would go without ioredis or try to downgrade redis engine to 4.x.</p>
