-
Notifications
You must be signed in to change notification settings - Fork 3
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
Redis updates #161
Redis updates #161
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,15 +1,31 @@ | ||||||||||
# Migrating Redis database from Heroku infrastructure | ||||||||||
# Migrating Redis databases | ||||||||||
|
||||||||||
**General considerations:** | ||||||||||
There are two templates examples in this repo: | ||||||||||
- `redis` - basic non-persistent template. It is good for review-apps or staging or where no persistence is required | ||||||||||
- `redis2` - basic persistent template. Good for production where persistence is needed, but cluster is overkill. | ||||||||||
|
||||||||||
## Option 1: use SLAVEOF (easier way) | ||||||||||
|
||||||||||
1. create a redis workload that will accept data | ||||||||||
2. execute `SLAVEOF source_host source_port`, if needed use `masterauth` to provide auth details | ||||||||||
3. wait for replication to pick up all changes (usually quickly), use `INFO` or `DBSIZE` to check progress | ||||||||||
4. stop app completely and ensure nothing is writing to any of redises | ||||||||||
5. execute `SLAVEOF no one` to disconnect replication | ||||||||||
6. switch `REDIS_URL` in the app to point to new server | ||||||||||
7. start the app | ||||||||||
|
||||||||||
## Option 2: use Redis-RIOT (harder way, where option 1 is not possible) | ||||||||||
|
||||||||||
### General considerations: | ||||||||||
|
||||||||||
1. Heroku uses self-signed TLS certificates, which are not verifiable. It needs special handling by setting | ||||||||||
TLS verification to `none`, otherwise most apps are not able to connect. | ||||||||||
TLS verification to `none`; otherwise, most apps cannot connect. | ||||||||||
|
||||||||||
justin808 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
2. We are moving to private Redis that don't have a public URL, so have to do it from a Control Plane GVC container. | ||||||||||
|
||||||||||
The tool that satisfies those criteria is [Redis-RIOT](https://developer.redis.com/riot/riot-redis/index.html) | ||||||||||
|
||||||||||
**Heroku Redis:** | ||||||||||
### Heroku Redis: | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure code blocks are surrounded by blank lines for proper formatting. +
### Heroku Redis:
+ Committable suggestion
Suggested change
|
||||||||||
As Redis-RIOT says, master redis should have keyspace-notifications set to `KA` to be able to do live replication. | ||||||||||
To do that: | ||||||||||
|
@@ -23,7 +39,7 @@ Connect to heroku Redis CLI: | |||||||||
heroku redis:cli -a my-app | ||||||||||
``` | ||||||||||
|
||||||||||
**Control Plane Redis:** | ||||||||||
### Control Plane Redis: | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure code blocks are surrounded by blank lines for proper formatting. +
### Control Plane Redis:
+ Committable suggestion
Suggested change
|
||||||||||
Connect to Control Plane Redis CLI: | ||||||||||
|
||||||||||
|
@@ -36,10 +52,10 @@ apt-get update | |||||||||
apt-get install redis -y | ||||||||||
|
||||||||||
# connect to local cloud Redis | ||||||||||
redis-cli -u MY_CONTROL_PLANE_REDIS_URL | ||||||||||
redis-cli -u MY_CONTROL_PLANE_REDIS_URL -p 6379 | ||||||||||
``` | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify the language for the code block to enhance syntax highlighting. + ```bash
55~
redis-cli -u MY_CONTROL_PLANE_REDIS_URL -p 6379
56~
+ ``` |
||||||||||
|
||||||||||
**Useful Redis CLI commands:** | ||||||||||
### Useful Redis CLI commands: | ||||||||||
|
||||||||||
Quick-check keys qty: | ||||||||||
``` | ||||||||||
|
@@ -49,7 +65,7 @@ info keyspace | |||||||||
db0:keys=9496,expires=2941,avg_ttl=77670114535 | ||||||||||
``` | ||||||||||
|
||||||||||
**Create a Control Plane sync workload** | ||||||||||
### Create a Control Plane sync workload | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure code blocks are surrounded by blank lines for proper formatting. +
### Create a Control Plane sync workload
+ Committable suggestion
Suggested change
|
||||||||||
``` | ||||||||||
name: riot-redis | ||||||||||
|
@@ -76,7 +92,7 @@ command args: | |||||||||
live | ||||||||||
``` | ||||||||||
|
||||||||||
**Sync process** | ||||||||||
### Sync process | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure code blocks are surrounded by blank lines for proper formatting. +
### Sync process
+ Committable suggestion
Suggested change
Sync process
|
||||||||||
1. open 1st terminal window with heroku redis CLI, check keys qty | ||||||||||
2. open 2nd terminal window with controlplane redis CLI, check keys qty | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
kind: volumeset | ||
name: redis-data | ||
spec: | ||
fileSystemType: ext4 | ||
initialCapacity: 10 | ||
performanceClass: general-purpose-ssd | ||
--- | ||
kind: workload | ||
name: redis2 | ||
spec: | ||
type: stateful | ||
containers: | ||
- name: redis | ||
args: | ||
- '--appendonly' | ||
- 'yes' | ||
- '--maxmemory' | ||
- 25mb | ||
cpu: 25m | ||
memory: 32Mi | ||
image: "redis:latest" | ||
ports: | ||
- number: 6379 | ||
protocol: tcp | ||
volumes: | ||
- path: /data | ||
recoveryPolicy: retain | ||
uri: cpln://volumeset/redis-data | ||
defaultOptions: | ||
autoscaling: | ||
metric: disabled | ||
minScale: 1 | ||
maxScale: 1 | ||
capacityAI: false | ||
firewallConfig: | ||
internal: | ||
inboundAllowType: same-gvc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List items should be surrounded by blank lines for better readability.
Committable suggestion