Skip to content

Conversation

Copy link

Copilot AI commented Oct 10, 2025

Summary

This PR adds support for custom redis.conf configurations to the Redis Operator, allowing users to specify Redis settings tailored to their specific environment requirements through the RedisCluster CRD.

Motivation

Different environments require different Redis configurations (memory policies, persistence settings, timeouts, etc.). Previously, users were limited to the default settings provided by the operator. This enhancement enables users to customize their Redis clusters while maintaining cluster functionality.

Changes

1. CRD Enhancement

Added a new redisConfig field to the RedisClusterSpec:

apiVersion: redis.redis/v1beta1
kind: RedisCluster
metadata:
  name: my-redis-cluster
spec:
  image: redis:7.0
  masters: 3
  replicas: 1
  basePort: 10000
  maxMemory: "512mb"
  # New: Custom redis.conf configuration
  redisConfig:
    maxmemory-policy: "allkeys-lru"
    timeout: "300"
    tcp-keepalive: "60"
    save: "900 1 300 10"
    appendonly: "yes"
    appendfsync: "everysec"

2. Implementation Details

ConfigMap-based Approach:

  • When redisConfig is specified, the operator creates a ConfigMap named rediscluster-{name}-config
  • The ConfigMap contains a redis.conf file generated from user settings
  • Redis pods mount this ConfigMap at /redis-config and start with redis-server /redis-config/redis.conf

Smart Configuration Merging:

  • User-provided settings are applied with highest priority
  • Essential cluster settings are automatically added if not specified:
    • port (derived from basePort)
    • cluster-enabled yes
    • cluster-port (port + 10000)
    • cluster-node-timeout 5000
    • maxmemory (from spec.maxMemory)
    • protected-mode no

New Functions:

  • GenerateRedisConfigMap() - Creates ConfigMap from user configuration
  • CreateOrUpdateRedisConfigMap() - Manages ConfigMap lifecycle
  • Updated GenerateRedisPodDef() - Handles both ConfigMap and command-line based configurations

3. Helm Chart Integration

Updated values.yaml to support the new field:

redisCluster:
  redisConfig:
    maxmemory-policy: "allkeys-lru"
    timeout: "300"
    tcp-keepalive: "60"

4. Documentation

  • Added comprehensive documentation in README.md with usage examples
  • Created sample CRs demonstrating the feature
  • Included important notes about configuration precedence

Backward Compatibility

No breaking changes - Existing RedisCluster deployments without redisConfig continue to work exactly as before, using command-line arguments for Redis configuration.

Testing

  • ✅ Code compiles successfully
  • ✅ No linter warnings
  • ✅ ConfigMap generation logic verified
  • ✅ Backward compatibility maintained

Files Modified

  • api/v1beta1/rediscluster_types.go - Added RedisConfig field
  • api/v1beta1/zz_generated.deepcopy.go - Updated deepcopy methods
  • k8sutils/utils.go - Implemented ConfigMap management and pod configuration logic
  • charts/redis-operator/values.yaml - Added redisConfig field with examples
  • charts/redis-operator/templates/rediscluster.yaml - Updated template to pass redisConfig
  • config/crd/bases/redis.redis_redisclusters.yaml - Updated CRD manifest
  • charts/redis-operator/crds/redis.redis_redisclusters.yaml - Updated Helm CRD
  • config/samples/* - Added sample CRs
  • README.md - Comprehensive documentation

Closes #[issue-number]

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feat] custom redis.conf로 redis operator 사용</issue_title>
<issue_description># Summary
custom redis.conf로 redis operator 사용

Motivation

사용자가 요구하는 redis.conf가 다 상이할 것이기 때문에, 이를 반영하여 클러스터를 구성하는 레디스 파드에 적용
이를 통해, 다양한 환경별 요구사항 만족도 향상

Proposal

  • Redis Cluster CR 필드 추가
  • helm chart values.yaml에 redis.conf 필드 추가
  • k8tutils/utils/GenerateRedisPodDef에 해당 내용 반영
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@jaehanbyun @copilot 안녕

Fixes #9


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@jaehanbyun
Copy link
Owner

@copilot hi

@jaehanbyun
Copy link
Owner

@copilot 안녕? 너의 사용법에 대해서 알려줘

Copilot AI and others added 2 commits October 10, 2025 01:45
Co-authored-by: jaehanbyun <80397512+jaehanbyun@users.noreply.github.com>
Co-authored-by: jaehanbyun <80397512+jaehanbyun@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for custom redis.conf in redis operator [Feat] Add custom redis.conf support to RedisCluster CRD Oct 10, 2025
Copilot AI requested a review from jaehanbyun October 10, 2025 01:50
Copilot finished work on behalf of jaehanbyun October 10, 2025 01:50
Copy link
Author

Copilot AI commented Oct 10, 2025

@copilot hi

안녕하세요! 👋

@copilot 안녕? 너의 사용법에 대해서 알려줘

안녕하세요! 저는 GitHub Copilot으로, PR의 코드 리뷰와 수정을 도와드립니다.

주요 기능:

  • 코드 변경 요청에 대한 구현
  • 버그 수정 및 개선 사항 적용
  • 질문에 대한 답변
  • 테스트 작성 및 문서 업데이트

사용 방법:

  1. PR 코멘트에서 @copilot을 멘션하고 요청사항을 작성하세요
  2. 코드 수정이 필요하면 구체적으로 어떤 부분을 어떻게 바꾸고 싶은지 알려주세요
  3. 질문이 있으면 자유롭게 물어보세요

현재 이 PR에서는 custom redis.conf 지원 기능을 구현했습니다. 추가로 수정이나 개선이 필요한 부분이 있으시면 말씀해주세요!

Copilot finished work on behalf of jaehanbyun October 10, 2025 01:52
@jaehanbyun jaehanbyun marked this pull request as ready for review October 15, 2025 07:32
Copilot AI review requested due to automatic review settings October 15, 2025 07:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for custom redis.conf configurations to the Redis Operator, enabling users to specify Redis settings through the RedisCluster CRD while maintaining backward compatibility.

  • Introduces a new redisConfig field to the RedisClusterSpec for custom Redis configurations
  • Implements ConfigMap-based configuration management with automatic merging of essential cluster settings
  • Updates Helm charts and sample configurations to support the new feature

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
api/v1beta1/rediscluster_types.go Added RedisConfig field to RedisClusterSpec
api/v1beta1/zz_generated.deepcopy.go Updated deepcopy methods for RedisConfig field
k8sutils/utils.go Implemented ConfigMap generation, management, and pod configuration logic
config/crd/bases/redis.redis_redisclusters.yaml Updated CRD schema to include redisConfig field
charts/redis-operator/values.yaml Added redisConfig field with documentation and examples
charts/redis-operator/templates/rediscluster.yaml Updated template to pass redisConfig from values
charts/redis-operator/crds/redis.redis_redisclusters.yaml Updated Helm CRD with redisConfig field
config/samples/redis_v1beta1_rediscluster_with_custom_config.yaml Added sample CR demonstrating custom configuration
config/samples/redis_v1beta1_rediscluster.yaml Updated basic sample with commented redisConfig examples
README.md Added comprehensive documentation for the custom configuration feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

[Feat] custom redis.conf로 redis operator 사용

2 participants