Multi-instance WordPress usingn Memcached to handle sessions requests login every time a requests is handled by a different server

The problem was that my *_KEY tokens were being generated each time Kubernetes was creating a new instance, as @Rup and @Tom-J-Nowel rightly pointed.

Because my docker image evolved from having an wp-config.php template included to having it generated by the official wordpress docker image I was struggling to see this was a variable. After double-checking following the advice I was given I realised it was indeed different in each instance.

Therefore, the solution was as simple as making sure that the values of the following variables were the same in all the instances:

define( 'AUTH_KEY',         '<auth_key_token>');
define( 'SECURE_AUTH_KEY',  '<secure_auth_key_token>');
define( 'LOGGED_IN_KEY',    '<logged_in_key_token>');
define( 'NONCE_KEY',        '<nonce_key_token>');
define( 'AUTH_SALT',        '<auth_salt_token>');
define( 'SECURE_AUTH_SALT', '<secure_auth_salt_token>');
define( 'LOGGED_IN_SALT',   '<logged_in_salt_token>');
define( 'NONCE_SALT',       '<nonce_salt_token>');

Which in my kubernetes object looked something like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: k8s-web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: k8s-web
  template:
    metadata:
      labels:
        app: k8s-web
    spec:
      containers:
        - image: wordpress:php7.4-apache
          name: web-container
          env:
            - name: WORDPRESS_DB_HOST
              value: <wordpress_db_host>
            - name: WORDPRESS_DB_NAME
              value: <wordpress_db_name>
            - name: WORDPRESS_DB_USER
              value: <wordpress_db_user>
            - name: WORDPRESS_DB_PASSWORD
              value: <wordpress_db_password>
            - name: WORDPRESS_TABLE_PREFIX
              value: <wordpress_table_prefix>
            - name: WORDPRESS_AUTH_KEY
              value: <wordpress_auth_key>
            - name: WORDPRESS_AUTH_SALT
              value: <wordpress_auth_salt>
            - name: WORDPRESS_SECURE_AUTH_KEY
              value: <wordpress_secure_auth_key>
            - name: WORDPRESS_SECURE_AUTH_SALT
              value: <wordpress_secure_auth_salt>
            - name: WORDPRESS_LOGGED_IN_KEY
              value: <wordpress_logged_in_key>
            - name: WORDPRESS_LOGGED_IN_SALT
              value: <wordpress_logged_in_salt>
            - name: WORDPRESS_NONCE_KEY
              value: <wordpress_nonce_key>
            - name: WORDPRESS_NONCE_SALT
              value: <wordpress_nonce_salt>