Commit 2385c38
feat: add Redis support for rate limiting (#19)
* feat: add Redis support for rate limiting in multi-replica deployments
Adds a new `redis` field to the Instance CRD spec with two modes:
- `managed`: Operator provisions a Redis 7 StatefulSet with PVC, Service,
liveness/readiness probes, and security context (non-root, dropped caps)
- `external`: User provides a Redis URL or Secret reference
The operator injects PAPERCLIP_RATE_LIMIT_REDIS_URL into Paperclip server
pods, enabling shared rate limit state across replicas.
Resources created for managed mode:
- StatefulSet (1 replica, redis:7-alpine, AOF persistence, LRU eviction)
- Service (ClusterIP, port 6379)
- PVC (1Gi default, configurable size and storage class)
Closes #18
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: resolve lint failure and harden Redis implementation
Fix gofmt alignment in redis.go that caused CI lint failure. Also:
- Add Restricted PSS fields (SeccompProfile, drop ALL capabilities)
- Derive Redis maxmemory from container memory limit (75%) instead of
hardcoding 256mb
- Add NetworkPolicy egress rule for managed Redis on port 6379
- Add RedisReady status condition in reconciler
- Add plaintext credential warning to ExternalURL CRD field
- Add 16 unit tests for Redis builders, env vars, and NetworkPolicy
- Regenerate CRD manifests and sync Helm chart
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: security hardening across operator
P0 fixes:
- Fix JSON injection in bootstrap Job by sanitizing adminName before
embedding in shell script JSON payload
- Remove unused pods/exec and pods/log RBAC from operator ClusterRole
(only needed in sandbox Role, not the operator itself)
- Add plaintext credential warning to Database.ExternalURL matching
the existing Redis.ExternalURL warning
P1 fixes:
- Add NetworkPolicies for managed Database and Redis pods restricting
ingress to only Paperclip server pods and denying all egress
- Add automountServiceAccountToken:false to Database, Redis, and
bootstrap Job pods (none need K8s API access)
- Add full SecurityContext to bootstrap Job (was completely missing):
PodSecurityContext + container seccomp, capabilities drop ALL
P2 fixes:
- Add Restricted PSS compliance (seccompProfile RuntimeDefault +
capabilities drop ALL) to Paperclip main container, database
container, and onboard init container
- Add CIDR validation pattern to NetworkPolicy AllowIngressCIDRs
and AllowEgressCIDRs fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 9802926 commit 2385c38
14 files changed
Lines changed: 1279 additions & 31 deletions
File tree
- api/v1alpha1
- charts/paperclip-operator/templates
- crds
- config
- crd/bases
- rbac
- samples
- internal
- controller
- resources
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
211 | 215 | | |
212 | 216 | | |
213 | 217 | | |
| 218 | + | |
| 219 | + | |
214 | 220 | | |
215 | 221 | | |
216 | 222 | | |
| |||
333 | 339 | | |
334 | 340 | | |
335 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
336 | 386 | | |
337 | 387 | | |
338 | 388 | | |
| |||
510 | 560 | | |
511 | 561 | | |
512 | 562 | | |
| 563 | + | |
| 564 | + | |
513 | 565 | | |
514 | 566 | | |
515 | 567 | | |
516 | 568 | | |
| 569 | + | |
| 570 | + | |
517 | 571 | | |
518 | 572 | | |
519 | 573 | | |
| |||
867 | 921 | | |
868 | 922 | | |
869 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
870 | 930 | | |
871 | 931 | | |
872 | 932 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 139 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1672 | 1672 | | |
1673 | 1673 | | |
1674 | 1674 | | |
1675 | | - | |
1676 | | - | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
1677 | 1679 | | |
1678 | 1680 | | |
1679 | 1681 | | |
| |||
5621 | 5623 | | |
5622 | 5624 | | |
5623 | 5625 | | |
| 5626 | + | |
| 5627 | + | |
| 5628 | + | |
| 5629 | + | |
| 5630 | + | |
| 5631 | + | |
| 5632 | + | |
| 5633 | + | |
| 5634 | + | |
| 5635 | + | |
| 5636 | + | |
| 5637 | + | |
| 5638 | + | |
| 5639 | + | |
| 5640 | + | |
| 5641 | + | |
| 5642 | + | |
| 5643 | + | |
| 5644 | + | |
| 5645 | + | |
| 5646 | + | |
| 5647 | + | |
| 5648 | + | |
| 5649 | + | |
| 5650 | + | |
| 5651 | + | |
| 5652 | + | |
| 5653 | + | |
| 5654 | + | |
| 5655 | + | |
| 5656 | + | |
| 5657 | + | |
| 5658 | + | |
| 5659 | + | |
| 5660 | + | |
| 5661 | + | |
| 5662 | + | |
| 5663 | + | |
| 5664 | + | |
| 5665 | + | |
| 5666 | + | |
| 5667 | + | |
| 5668 | + | |
| 5669 | + | |
| 5670 | + | |
| 5671 | + | |
| 5672 | + | |
| 5673 | + | |
| 5674 | + | |
| 5675 | + | |
| 5676 | + | |
| 5677 | + | |
| 5678 | + | |
| 5679 | + | |
| 5680 | + | |
| 5681 | + | |
| 5682 | + | |
| 5683 | + | |
| 5684 | + | |
| 5685 | + | |
| 5686 | + | |
| 5687 | + | |
| 5688 | + | |
| 5689 | + | |
| 5690 | + | |
| 5691 | + | |
| 5692 | + | |
| 5693 | + | |
| 5694 | + | |
| 5695 | + | |
| 5696 | + | |
| 5697 | + | |
| 5698 | + | |
| 5699 | + | |
| 5700 | + | |
| 5701 | + | |
| 5702 | + | |
| 5703 | + | |
| 5704 | + | |
| 5705 | + | |
| 5706 | + | |
| 5707 | + | |
| 5708 | + | |
| 5709 | + | |
| 5710 | + | |
| 5711 | + | |
| 5712 | + | |
| 5713 | + | |
| 5714 | + | |
| 5715 | + | |
| 5716 | + | |
| 5717 | + | |
| 5718 | + | |
| 5719 | + | |
| 5720 | + | |
| 5721 | + | |
| 5722 | + | |
| 5723 | + | |
| 5724 | + | |
| 5725 | + | |
| 5726 | + | |
| 5727 | + | |
| 5728 | + | |
| 5729 | + | |
| 5730 | + | |
| 5731 | + | |
| 5732 | + | |
| 5733 | + | |
| 5734 | + | |
| 5735 | + | |
| 5736 | + | |
| 5737 | + | |
| 5738 | + | |
| 5739 | + | |
| 5740 | + | |
| 5741 | + | |
| 5742 | + | |
| 5743 | + | |
| 5744 | + | |
| 5745 | + | |
| 5746 | + | |
| 5747 | + | |
| 5748 | + | |
| 5749 | + | |
| 5750 | + | |
5624 | 5751 | | |
5625 | 5752 | | |
5626 | 5753 | | |
| |||
5921 | 6048 | | |
5922 | 6049 | | |
5923 | 6050 | | |
| 6051 | + | |
5924 | 6052 | | |
5925 | 6053 | | |
| 6054 | + | |
5926 | 6055 | | |
5927 | 6056 | | |
5928 | 6057 | | |
5929 | 6058 | | |
| 6059 | + | |
5930 | 6060 | | |
5931 | 6061 | | |
| 6062 | + | |
5932 | 6063 | | |
5933 | 6064 | | |
5934 | 6065 | | |
| |||
7762 | 7893 | | |
7763 | 7894 | | |
7764 | 7895 | | |
| 7896 | + | |
| 7897 | + | |
| 7898 | + | |
| 7899 | + | |
| 7900 | + | |
| 7901 | + | |
7765 | 7902 | | |
7766 | 7903 | | |
7767 | 7904 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 28 | | |
35 | 29 | | |
36 | 30 | | |
| |||
0 commit comments