Token problem redis cluster on kubernetes

7/19/2019

I had configure redis-cluster on kubernetes githublink I saw my cluster works very well and didn't see any errors First of all did you see any error on my configuration ? I also added kube config and spring boot config redisson java client

Problem is here developer said that only one token didn't replicated properly across nodes. He can login to system properly on the first time and then token is being invalidate when he want to do other operation. Additional problem took place that there is only one token.

Thanks in advance

Kube Side

$ kubectl get pods | grep redis
redis-cluster-0                       1/1     Running            1          10d
redis-cluster-1                       1/1     Running            0          10d
redis-cluster-2                       1/1     Running            1          10d
redis-cluster-3                       1/1     Running            0          10d
redis-cluster-4                       1/1     Running            1          10d
redis-cluster-5                       1/1     Running            1          10d
$ kubectl get pv | grep redis
data-redis-0         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-2                           10d
data-redis-1         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-1                           10d
data-redis-2         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-0                           10d
data-redis-3         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-3                           10d
data-redis-4         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-4                           10d
data-redis-5         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-5                           10d
$ kubectl get pvc | grep redis
data-redis-redis-cluster-0   Bound    data-redis-2         3Gi        RWO                           10d
data-redis-redis-cluster-1   Bound    data-redis-1         3Gi        RWO                           10d
data-redis-redis-cluster-2   Bound    data-redis-0         3Gi        RWO                           10d
data-redis-redis-cluster-3   Bound    data-redis-3         3Gi        RWO                           10d
data-redis-redis-cluster-4   Bound    data-redis-4         3Gi        RWO                           10d
data-redis-redis-cluster-5   Bound    data-redis-5         3Gi        RWO                           10d

$ kubectl get svc | grep redis
redis-cluster        ClusterIP   10.233.3.78     <none>        6379/TCP,16379/TCP                                                                 10d

$ redis-cli -h 10.233.3.78 -c

$ > ping
pong

gt; CLUSTER INFO cluster_state:ok cluster_slots_assigned:16384 cluster_slots_ok:16384 cluster_slots_pfail:0 cluster_slots_fail:0 cluster_known_nodes:6 cluster_size:3 cluster_current_epoch:7 cluster_my_epoch:7 cluster_stats_messages_ping_sent:846761 cluster_stats_messages_pong_sent:854464 cluster_stats_messages_sent:1701225 cluster_stats_messages_ping_received:854464 cluster_stats_messages_pong_received:846745 cluster_stats_messages_fail_received:3 cluster_stats_messages_received:1701212 > CLUSTER NODES 81b6bb05dd66375fa8b0ff571b5f5cdaf98f8c02 10.117.2.131:6379@16379 slave 98fef8bd00cf00316d49d062b0fd503643ba908e 0 1563520808085 2 connected 341b25780a9cca4079ba4db9de5f5085fe5746c6 10.117.2.215:6379@16379 master - 0 1563520815111 3 connected 10923-16383 734b3f058c21f1aff418d5ba10e06a827892eb4c 10.117.2.199:6379@16379 myself,slave 7562f85fa1200370364e25117748623c28d68804 0 1563520811000 1 connected 7562f85fa1200370364e25117748623c28d68804 10.117.2.8:6379@16379 master - 0 1563520814107 7 connected 0-5460 98fef8bd00cf00316d49d062b0fd503643ba908e 10.117.2.52:6379@16379 master - 0 1563520812000 2 connected 5461-10922 91df2126229098dbbc648118204fc914516d57ca 10.117.2.242:6379@16379 slave 341b25780a9cca4079ba4db9de5f5085fe5746c6 0 1563520813103 6 connected

Spring boot redisson side:

@Configuration
@Import({TokenProvider.class})
public class RedisConfiguration {
    public static final String CACHE_PREFIX = "token";

    private static final int CONNECTION_POOL_SIZE = 4;
    private static final int CONNECTION_MINIMUM_IDLE_SIZE = 2;

    @Value("${redis.server.urls}")
    String[] redisServers;

    @Profile({"!local"})
    @Bean
    RedissonClient redissonClusterdClient() {
        Config config = new Config();

        config.setCodec(new SerializationCodec());

        ClusterServersConfig replicatedConfig = config.useClusterServers()
                .setScanInterval(2000)
                .setMasterConnectionPoolSize(CONNECTION_POOL_SIZE)
                .setMasterConnectionMinimumIdleSize(CONNECTION_MINIMUM_IDLE_SIZE)
                .setSlaveConnectionPoolSize(CONNECTION_POOL_SIZE)
                .setSlaveConnectionMinimumIdleSize(CONNECTION_MINIMUM_IDLE_SIZE);
        for (String redisServer : redisServers) {
            replicatedConfig.addNodeAddress(redisServer);
        }

        return Redisson.create(config);
    }

    @Profile({"local"})
    @Bean
    RedissonClient redissonSingleClient() {
        Config config = new Config();

        config.setCodec(new SerializationCodec());

        SingleServerConfig singleServerConfig = config.useSingleServer();
        for (String redisServer : redisServers) {
            singleServerConfig.setAddress(redisServer);
        }

        return Redisson.create(config);
    }
}
-- Babak Mammadov
kubernetes
redis
spring-boot

0 Answers