Skip to content

feat(k8s): require Redis AUTH and restrict ingress with NetworkPolicy - #610

Open
SceptredHead wants to merge 1 commit into
DevNiola:mainfrom
SceptredHead:feat/411-redis-auth-network-policy
Open

SceptredHead wants to merge 1 commit into
DevNiola:mainfrom
SceptredHead:feat/411-redis-auth-network-policy

Conversation

@SceptredHead

Copy link
Copy Markdown

Description

Redis was deployed without authentication and without network isolation, so any pod in the prism namespace could reach it unauthenticated. This PR closes both gaps.

What was implemented

Redis AUTH

  • deploy/k8s/base/secret.yaml — added REDIS_PASSWORD key (empty placeholder; must be set to a strong random value in production via a sealed secret or external secrets operator).
  • deploy/k8s/base/redis-statefulset.yaml — passes --requirepass $(REDIS_PASSWORD) to redis-server, reads the value from the Secret via an env var. Updated the readiness probe to pass -a "$REDIS_PASSWORD" so it still works after AUTH is enabled.
  • deploy/k8s/base/server-deployment.yaml — injects REDIS_PASSWORD from the Secret into the server pod.
  • apps/server/src/config.ts — added buildRedisUrl() which embeds the password into the REDIS_URL when REDIS_PASSWORD is set, so all ioredis and BullMQ clients authenticate automatically with no additional changes.

NetworkPolicy

  • deploy/k8s/base/redis-network-policy.yaml — new NetworkPolicy targeting pods labeled component: redis that restricts port-6379 ingress to pods labeled component: server only. All other pods (including the web frontend and any future workloads) are denied at the network layer.
  • deploy/k8s/base/kustomization.yaml — registered the new manifest.

Closes #411

Redis runs unauthenticated by default, allowing any pod in the namespace to
connect. This commit closes that gap with two changes.

Redis AUTH:
- Added REDIS_PASSWORD to the prism-secrets Secret (empty placeholder; must
  be set to a strong random value before deploying to production).
- Updated redis-statefulset.yaml to pass --requirepass via the REDIS_PASSWORD
  env var so Redis rejects unauthenticated connections.
- Updated the readiness probe to pass -a "$REDIS_PASSWORD" to redis-cli.
- Updated server-deployment.yaml to inject REDIS_PASSWORD from the Secret.
- Extended config.ts with buildRedisUrl() which embeds the password into the
  REDIS_URL when REDIS_PASSWORD is present, so all ioredis/BullMQ clients
  authenticate without further changes.

NetworkPolicy:
- Added deploy/k8s/base/redis-network-policy.yaml with an Ingress policy that
  limits port-6379 access to pods labeled app.kubernetes.io/component: server.
  All other pods in the namespace (and outside) are denied.
- Registered the new manifest in the base kustomization.yaml.

Closes DevNiola#411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DevOps] Add network policies and Redis AUTH to the Kubernetes base

1 participant