Repository navigation
Description
Description
Add Kubernetes CRD types for configuring Redis storage in the embedded authorization server. This covers the type definitions, generated manifests, and validation webhooks — the foundational schema that the controller/runner integration (covered in #3630) will build on.
Note: Split from #3630, which now covers only controller and runner integration.
Context
The Redis storage backend implemented in #3628 and integration tested in #3629 provides horizontal scaling capabilities for the embedded auth server. This task defines the CRD schema that operators will use to declaratively configure Redis-backed storage.
Parent Issue: https://github.com/stacklok/stacklok-epics/issues/197
Dependencies: #3628 (Core Implementation), #3629 (Integration Testing)
Blocks: #3630 (Controller & Runner Integration)
Related: #3790 (Documentation)
Acceptance Criteria
- CRD types added to
mcpexternalauthconfig_types.go:AuthServerStorageConfigRedisStorageConfigRedisSentinelConfigSentinelServiceRefRedisACLUserConfig
-
EmbeddedAuthServerConfigupdated withStoragefield - Generated manifests updated via
task operator-generateandtask operator-manifests - Validation webhooks implemented for Redis configuration:
- Exactly one of
sentinelAddrsorsentinelServicemust be specified - Timeout values are valid Go duration strings
deploymentModeis "sentinel" andauthTypeis "aclUser"
- Exactly one of
-
task lint,task test, andtask operator-manifestspass - Code reviewed and approved
Technical Approach
Recommended Implementation
Follow existing patterns in mcpexternalauthconfig_types.go for:
- SecretKeyRef pattern for referencing Kubernetes Secrets (lines 369-378)
- Kubebuilder validation annotations for enum constraints
- Optional fields with sensible defaults
Patterns & Frameworks
- Kubebuilder validation: Use
+kubebuilder:validation:Enumfor constrained fields likedeploymentModeandauthType - SecretKeyRef: Follow existing pattern from
mcpexternalauthconfig_types.gofor Secret references
Code Pointers
cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go— Add CRD types following existing patterns (lines 132-176 forEmbeddedAuthServerConfig, lines 369-378 forSecretKeyRef)pkg/authserver/storage/config.go— Reference for storage configuration typesdocs/proposals/THV-0035-auth-server-redis-storage.md— RFC with complete CRD type definitions
Component Interfaces
CRD Types (add to mcpexternalauthconfig_types.go):
// AuthServerStorageConfig configures the storage backend for the embedded auth server
type AuthServerStorageConfig struct {
// Type specifies the storage backend type
// Valid values: "memory" (default), "redis"
// +kubebuilder:validation:Enum=memory;redis
// +kubebuilder:default=memory
Type string `json:"type,omitempty"`
// Redis configures Redis storage backend
// Required when type is "redis"
// +optional
Redis *RedisStorageConfig `json:"redis,omitempty"`
}
// RedisStorageConfig configures Redis connection for auth server storage
type RedisStorageConfig struct {
// DeploymentMode specifies the Redis deployment mode
// Only "sentinel" is supported for high availability
// +kubebuilder:validation:Enum=sentinel
// +kubebuilder:default=sentinel
DeploymentMode string `json:"deploymentMode,omitempty"`
// SentinelConfig holds Sentinel configuration
// Required when deploymentMode is "sentinel"
SentinelConfig *RedisSentinelConfig `json:"sentinelConfig,omitempty"`
// AuthType specifies the authentication method
// Only "aclUser" is supported for secure deployments
// +kubebuilder:validation:Enum=aclUser
// +kubebuilder:default=aclUser
AuthType string `json:"authType,omitempty"`
// ACLUserConfig configures ACL user authentication
// Required when authType is "aclUser"
ACLUserConfig *RedisACLUserConfig `json:"aclUserConfig,omitempty"`
// DialTimeout is the timeout for establishing connections
// +kubebuilder:default="5s"
// +optional
DialTimeout string `json:"dialTimeout,omitempty"`
// ReadTimeout is the timeout for socket reads
// +kubebuilder:default="3s"
// +optional
ReadTimeout string `json:"readTimeout,omitempty"`
// WriteTimeout is the timeout for socket writes
// +kubebuilder:default="3s"
// +optional
WriteTimeout string `json:"writeTimeout,omitempty"`
}
// RedisSentinelConfig configures Redis Sentinel connection
type RedisSentinelConfig struct {
// MasterName is the name of the Redis master monitored by Sentinel
MasterName string `json:"masterName"`
// SentinelAddrs is a list of Sentinel host:port addresses
// Mutually exclusive with SentinelService
// +optional
SentinelAddrs []string `json:"sentinelAddrs,omitempty"`
// SentinelService enables automatic discovery from a Kubernetes Service
// Mutually exclusive with SentinelAddrs
// +optional
SentinelService *SentinelServiceRef `json:"sentinelService,omitempty"`
// DB is the Redis database number
// +kubebuilder:default=0
// +optional
DB int32 `json:"db,omitempty"`
}
// SentinelServiceRef references a Kubernetes Service for Sentinel discovery
type SentinelServiceRef struct {
// Name of the Sentinel Service
Name string `json:"name"`
// Namespace of the Sentinel Service (defaults to same namespace)
// +optional
Namespace string `json:"namespace,omitempty"`
// Port of the Sentinel service
// +kubebuilder:default=26379
// +optional
Port int32 `json:"port,omitempty"`
}
// RedisACLUserConfig configures Redis ACL user authentication
type RedisACLUserConfig struct {
// UsernameSecretRef references a Secret containing the Redis ACL username
UsernameSecretRef *SecretKeyRef `json:"usernameSecretRef"`
// PasswordSecretRef references a Secret containing the Redis ACL password
PasswordSecretRef *SecretKeyRef `json:"passwordSecretRef"`
}Testing Strategy
Unit Tests
- Test CRD validation webhooks for mutual exclusivity of
sentinelAddrsvssentinelService - Test CRD validation for timeout duration format validation
Validation Tests
- Test that exactly one of
sentinelAddrsorsentinelServiceis required - Test that invalid timeout formats are rejected
- Test that missing required fields are rejected
Out of Scope
- Controller and runner integration (covered in Auth Server: Operator Controller & Runner Integration for Redis Storage #3630)
- Documentation (covered in Auth Server: Add Redis Storage Documentation #3790)
- Operator integration tests with real Redis (Phase 5, tracked separately)
- TLS/mTLS configuration for Redis connections (future enhancement)
References
- Epic: https://github.com/stacklok/stacklok-epics/issues/197
- RFC Design Document:
docs/proposals/THV-0035-auth-server-redis-storage.md - Controller & Runner Integration: Auth Server: Operator Controller & Runner Integration for Redis Storage #3630
- Documentation: Auth Server: Add Redis Storage Documentation #3790
- Upstream Dependency (Core): Auth Server: Implement Redis Storage: Core Implementation (Phase 1) #3628
- Upstream Dependency (Integration Tests): Auth Server: Add Redis Storage Integration Tests with Testcontainers (Phase 2) #3629
- Existing CRD Types:
cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
Activity