idangozlan / verdaccio-bitbucket

BitBucket auth plugin for verdaccio
MIT License
7 stars 17 forks source link

Add support for Redis Cluster to be used as a caching node #41

Open warrmr opened 2 years ago

warrmr commented 2 years ago

I am in the process of migrating my self hosted Verdaccio node over to a k8s cluster that will contain a HA redis cluster. This means that the master node could dynamically change.

With my current configuration if redis-0 goes down then verdaccio is not able to access the redis cache, a new master will be elected and then when redis-0 comes back online it will be in Read only slave mode so the caching will stop working.

This is an example of my current config.

    bitbucket:
        allow: SOME_GROUP
        ttl: 604800 # 7 days
        hashPassword: true
        cache: redis
        redis:
            host: redis-0
            port: 6379
            prefix: "verdaccio-bitbucket:"

I prepose an additional config flag to detect if node-redis should use createClient or createCluster, the redis section of the config would still be passed through as it currently does just into a different method.

Example proposed config.

    bitbucket:
        allow: SOME_GROUP
        ttl: 604800 # 7 days
        hashPassword: true
        cache: redis-cluster
        redis:
            rootNodes: 
                - host: redis-0
                - host: redis-1
                - host: redis-2
            defaults: 
                port: 6379
                prefix: "verdaccio-bitbucket:"

The existing redis config will call createClient as it currently does, but then the new config section will call createCluster everything else should work the same.