feat: add Valkey as k8s sidecar for Redis compatibility
- Add Valkey 8.0 alpine container as sidecar in k8s deployment - Configure with appropriate security context (non-root, no privilege escalation) - Add resource limits (256Mi memory, 200m CPU) and requests (128Mi, 50m) - Add health probes using valkey-cli ping command - Configure Redis connection via REDIS_HOST and REDIS_PORT environment variables - Add Redis config to runtime.exs, dev.exs, and test.exs - Valkey runs on localhost:6379 within the same pod as Phoenix app
This commit is contained in:
parent
560370cb0b
commit
eb7b57aa42
4 changed files with 63 additions and 0 deletions
|
|
@ -92,5 +92,10 @@ config :towerops, ToweropsWeb.Endpoint,
|
|||
]
|
||||
]
|
||||
|
||||
# Configure Redis/Valkey for development
|
||||
config :towerops, :redis,
|
||||
host: "localhost",
|
||||
port: 6379
|
||||
|
||||
# Enable dev routes for dashboard and mailbox
|
||||
config :towerops, dev_routes: true
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ if config_env() == :prod do
|
|||
|
||||
host = System.get_env("PHX_HOST") || "example.com"
|
||||
|
||||
# Configure Redis/Valkey connection
|
||||
redis_host = System.get_env("REDIS_HOST") || "localhost"
|
||||
redis_port = String.to_integer(System.get_env("REDIS_PORT") || "6379")
|
||||
|
||||
config :libcluster,
|
||||
topologies: [
|
||||
k8s: [
|
||||
|
|
@ -147,4 +151,8 @@ if config_env() == :prod do
|
|||
|
||||
# Set default sender for all emails
|
||||
config :towerops, :mailer_from, {"Towerops", "hi@towerops.net"}
|
||||
|
||||
config :towerops, :redis,
|
||||
host: redis_host,
|
||||
port: redis_port
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ config :towerops, ToweropsWeb.Endpoint,
|
|||
# Set environment identifier for runtime checks
|
||||
config :towerops, :env, :test
|
||||
|
||||
# Configure Redis/Valkey for testing
|
||||
config :towerops, :redis,
|
||||
host: "localhost",
|
||||
port: 6379
|
||||
|
||||
# Use mocks for testing
|
||||
config :towerops,
|
||||
ping_module: Towerops.Monitoring.PingMock,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ spec:
|
|||
secretKeyRef:
|
||||
name: towerops-secrets
|
||||
key: SECRET_KEY_BASE
|
||||
- name: REDIS_HOST
|
||||
value: "localhost"
|
||||
- name: REDIS_PORT
|
||||
value: "6379"
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: towerops-db
|
||||
|
|
@ -113,3 +117,44 @@ spec:
|
|||
timeoutSeconds: 2
|
||||
successThreshold: 1
|
||||
failureThreshold: 2
|
||||
- name: valkey
|
||||
image: valkey/valkey:8.0-alpine
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
runAsNonRoot: true
|
||||
runAsUser: 999
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
name: valkey
|
||||
resources:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "200m"
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- valkey-cli
|
||||
- ping
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- valkey-cli
|
||||
- ping
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 2
|
||||
successThreshold: 1
|
||||
failureThreshold: 2
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue