Skip to content

Commit

Permalink
Sync from main
Browse files Browse the repository at this point in the history
Sync from main
  • Loading branch information
kamal-mohammed authored Jul 24, 2024
2 parents c27cf37 + e724c9e commit 607ccca
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 1 deletion.
1 change: 1 addition & 0 deletions local-dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redis
44 changes: 44 additions & 0 deletions local-dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3"
services:
redis-1:
image: redis
command: ["redis-server","/etc/redis/redis.conf"]
volumes:
- ./redis/node-1/data:/data
- ./redis/node-1/conf/redis.conf:/etc/redis/redis.conf
network_mode: "host"
redis-2:
image: redis
command: ["redis-server", "/etc/redis/redis.conf"]
volumes:
- ./redis/node-2/data:/data
- ./redis/node-2/conf/redis.conf:/etc/redis/redis.conf
network_mode: "host"
redis-3:
image: redis
command: ["redis-server", "/etc/redis/redis.conf"]
volumes:
- ./redis/node-3/data:/data
- ./redis/node-3/conf/redis.conf:/etc/redis/redis.conf
network_mode: "host"
redis-4:
image: redis
command: ["redis-server", "/etc/redis/redis.conf"]
volumes:
- ./redis/node-4/data:/data
- ./redis/node-4/conf/redis.conf:/etc/redis/redis.conf
network_mode: "host"
redis-5:
image: redis
command: ["redis-server", "/etc/redis/redis.conf"]
volumes:
- ./redis/node-5/data:/data
- ./redis/node-5/conf/redis.conf:/etc/redis/redis.conf
network_mode: "host"
redis-6:
image: redis
command: ["redis-server", "/etc/redis/redis.conf"]
volumes:
- ./redis/node-6/data:/data
- ./redis/node-6/conf/redis.conf:/etc/redis/redis.conf
network_mode: "host"
36 changes: 36 additions & 0 deletions local-dev/init-local-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
PROJECT_NAME=grad-support
# set up redis
REDIS_MASTER_NODE_NAME=redis-1-1
# first clean up, remove artifacts
if [ -d redis ]; then
rm -r redis
fi
# create dirs for cluster
mkdir redis;
for i in $(seq 0 5);
do
mkdir -p redis/node-$((i+1))/{conf,data};
echo "port 700$i
cluster-require-full-coverage no
cluster-migration-barrier 1
protected-mode no
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
requirepass secret
masterauth secret" > redis/node-$((i+1))/conf/redis.conf
done
# fire up docker
docker compose --project-name "$PROJECT_NAME" up -d
CONTAINER_ID=$(docker ps --all --filter name="$PROJECT_NAME-$REDIS_MASTER_NODE_NAME" --format="{{.ID}}" | head -n 1)
CONTAINER_STATUS=$(docker inspect --format "{{json .State.Status }}" "$CONTAINER_ID")
until [ "$CONTAINER_STATUS" = '"running"' ]
do
echo "Waiting for container to start..."
sleep 1
done
echo "Container up, initiating cluster..."
docker exec "$CONTAINER_ID" redis-cli -a secret --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1 --cluster-yes

31 changes: 31 additions & 0 deletions local-dev/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Local development support tools for GRAD
Most GRAD apis rely on the support of services like nats and redis in order to function correctly. This directory contains scripts that provision dockerized support for developers local environments.
### Prerequisites
In order to use the scripts in this directory, it will require:

### Windows

**Install Ubuntu 24.xx.xx using WSL2**. Information can be found [here](https://learn.microsoft.com/en-us/windows/wsl/install)

After Ubuntu install, a few things to make life easier, set up your linux environment
1. ensure bash is your default shell\
`chsh -s /bin/bash`
2. install docker compose\
`sudo apt install docker-compose`
3. enable docker without sudo\
`sudo groupadd docker`\
`sudo usermod -aG docker $USER`

**Install Docker Desktop version > v4.32.0**
Ensure the following features are enabled:\
Go to *Settings / Resources / WSL integrations* and ensure your WSL2 Ubuntu 24.xx.xx integration is selected\
Go to *Settings / Features in development / Enable host networking*

### Running the setup
1. Ensure docker desktop is running
2. Open your WSL linux distro and navigate to this directory (remember your windows drives can be found under /mnt)
3. Run the init-local-dev.sh script:\ `sudo ./init-local-dev.sh`

The script will provision the necessary volume structure and set up the necessary docker containers etc.


3 changes: 2 additions & 1 deletion redis/redis-ha.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ objects:
appendonly yes
protected-mode no
requirepass ${REDIS_PASSWORD}
masterauth ${REDIS_PASSWORD}
- kind: Secret
apiVersion: v1
metadata:
Expand Down Expand Up @@ -153,4 +154,4 @@ parameters:
description: Password for the Redis connection user.
generate: expression
from: '[a-zA-Z0-9]{16}'
required: true
required: true

0 comments on commit 607ccca

Please sign in to comment.