Марк
Марк

Reputation: 55

GitLab redis cluster

For tests I need to raise Redis Cluster, I can do it locally, I can deploy it on a third party server too. But I have problems with gitlab, I can't build Redis Cluster for GitLab CI. Because of the inability to make requests to the outside world. Maybe someone has a ready yaml with configuration and can help me out

My GitLab CI yaml:


stages:
  - quality

testing:
  stage: quality
  image: golang:1.23
  services:
    - name: grokzen/redis-cluster:latest
      alias: redis-cluster
  script:
    - go fmt $(go list ./... | grep -v /vendor/)
    - go vet $(go list ./... | grep -v /vendor/)
    - go test -race $(go list ./... | grep -v /vendor/)
  variables:
    REDIS_HOST: redis-cluster:6379

quality:
  stage: quality
  image: golangci/golangci-lint:v1.63.4
  script:
    - golangci-lint --version
    - golangci-lint run

Error:

dial tcp xxx.xxx.xxx.xxx:6379: connect: connection refused

How do I connect using Golang to a Redis Cluster that is brought up during the gitlab CI runtime

redisAddrs := os.Getenv("REDIS_HOST")
spew.Dump(redisAddrs)

rdb := redis.NewClusterClient(&redis.ClusterOptions{Addrs: strings.Split(redisAddrs, ",")})

Upvotes: 1

Views: 29

Answers (1)

Andrew
Andrew

Reputation: 4642

Quoting the docs:

The cluster is 6 redis instances running with 3 master & 3 slaves, one slave for each master. They run on ports 7000 to 7005.

yet you are trying to access port 6379. Change REDIS_HOST to redis-cluster:7000 or another master or slave port, depending your usecase, and it should work.

Upvotes: 0

Related Questions