Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add redis auth support #1026 auto commit #2179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,12 @@ The internal redis server has been removed from the image. Please use a [linked

The image can be configured to use an external redis server. The configuration should be specified using environment variables while starting the GitLab image.

*Assuming that the redis server host is 192.168.1.100*
*Assuming that the redis server host is 192.168.1.100*, and configured to use authentication*

```bash
docker run --name gitlab -it --rm \
--env 'REDIS_HOST=192.168.1.100' --env 'REDIS_PORT=6379' \
--env 'REDIS_PASSWORD=p4ssw0rd' \
sameersbn/gitlab:13.0.6
```

Expand Down
2 changes: 1 addition & 1 deletion assets/runtime/config/gitlabhq/resque.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test:
url: redis://localhost:6379
production:
# Redis (single instance)
url: redis://{{REDIS_HOST}}:{{REDIS_PORT}}/{{REDIS_DB_NUMBER}}
url: redis://{{REDIS_PASSWORD}}{{REDIS_HOST}}:{{REDIS_PORT}}/{{REDIS_DB_NUMBER}}
##
# Redis + Sentinel (for HA)
#
Expand Down
13 changes: 11 additions & 2 deletions assets/runtime/functions
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,12 @@ gitlab_finalize_redis_parameters() {
}

gitlab_check_redis_connection() {
REDIS_FLAG=""
if [[ -n ${REDIS_PASSWORD} ]]; then
REDIS_FLAG="-a ${REDIS_PASSWORD}"
fi
timeout=60
while ! redis-cli -h ${REDIS_HOST} -p ${REDIS_PORT} -n ${REDIS_DB_NUMBER} ping >/dev/null 2>&1
while ! redis-cli -h ${REDIS_HOST} ${REDIS_FLAG} -p ${REDIS_PORT} -n ${REDIS_DB_NUMBER} ping >/dev/null 2>&1
do
timeout=$(expr $timeout - 1)
if [[ $timeout -eq 0 ]]; then
Expand All @@ -226,10 +230,15 @@ gitlab_configure_redis() {
gitlab_finalize_redis_parameters
gitlab_check_redis_connection

if [[ -n ${REDIS_PASSWORD} ]]; then
REDIS_PASSWORD=':'${REDIS_PASSWORD}'@'
fi

update_template ${GITLAB_RESQUE_CONFIG} \
REDIS_HOST \
REDIS_PORT \
REDIS_DB_NUMBER
REDIS_DB_NUMBER \
REDIS_PASSWORD
}

gitlab_configure_gitaly() {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
image: redis:5.0.9
command:
- --loglevel warning
- --requirepass "p4ssw0rd"
volumes:
- redis-data:/var/lib/redis:Z

Expand Down