Skip to content

Conversation

Placeboy
Copy link

@Placeboy Placeboy commented Aug 6, 2025

Ⅰ. Describe what this PR does

This PR implements ConfigMapSet, a sidecar-based multi-version configuration manager that decouples configuration updates from image updates.
For instances of the same workload, while image versions are managed by CloneSet, configuration versions can be managed independently via ConfigMapSet.

This feature is enabled by injecting a sidecar container into each Pod. When the configuration version changes, the sidecar container restarts and rewrites the corresponding configuration version to the mounted path.

Ⅱ. Does this pull request fix one issue?

NONE

Ⅲ. Describe how to verify it

  1. Create a ConfigMapSet (CMS) resource.
  2. Deploy a workload whose label selector matches the CMS.
  3. Adjust the version weights in the CMS to control the distribution of configuration versions.
  4. Verify that:
    • The Pods restart as expected upon configuration version change.
    • Each Pod uses the correct version of the configuration as defined in CMS.

Ⅳ. Special notes for reviews

N/A

@kruise-bot kruise-bot requested review from Fei-Guo and zmberg August 6, 2025 03:58
@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fei-guo for approval by writing /assign @fei-guo in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot
Copy link

Welcome @Placeboy! It looks like this is your first PR to openkruise/kruise 🎉

@Placeboy Placeboy force-pushed the feature/configmapset branch from 31eac8f to 14c9794 Compare August 6, 2025 04:03
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

❌ Patch coverage is 0.11293% with 1769 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.50%. Comparing base (6bc00ac) to head (14c9794).

Files with missing lines Patch % Lines
...controller/configmapset/configmapset_controller.go 0.17% 1136 Missing ⚠️
.../webhook/pod/mutating/pod_create_update_handler.go 0.00% 274 Missing ⚠️
...t/validating/configmapset_create_update_handler.go 0.00% 163 Missing ⚠️
pkg/controller/configmapset/configmapset_utils.go 0.00% 88 Missing ⚠️
...troller/configmapset/configmapset_event_handler.go 0.00% 74 Missing ⚠️
...set/mutating/configmapset_create_update_handler.go 0.00% 21 Missing ⚠️
pkg/webhook/configmapset/validating/webhooks.go 0.00% 6 Missing ⚠️
pkg/webhook/add_configmapset.go 0.00% 3 Missing ⚠️
pkg/webhook/configmapset/mutating/webhooks.go 0.00% 3 Missing ⚠️
pkg/controller/controllers.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2149      +/-   ##
==========================================
- Coverage   44.82%   42.50%   -2.33%     
==========================================
  Files         318      326       +8     
  Lines       32245    34016    +1771     
==========================================
+ Hits        14455    14457       +2     
- Misses      16370    18139    +1769     
  Partials     1420     1420              
Flag Coverage Δ
unittests 42.50% <0.11%> (-2.33%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

// +optional
Partition *intstr.IntOrString `json:"partition,omitempty"` // 旧版本的比例, 多个旧版本的情况不做区分
// +optional
RestartInjectedContainers bool `json:"restartInjectedContainers,omitempty"` // 开启该选项后, 被注入最新配置的容器发生重启
Copy link
Member

Choose a reason for hiding this comment

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

plz consider extract the RestartInjectedContainers field to a separate field in the ConfigMapSetSpec, maybe called "LoadStrategy", with three possible option

  1. RestartAppContainers
  2. RestartReloaderContainer
  3. None

@@ -130,3 +167,324 @@ func (h *PodCreateHandler) Handle(ctx context.Context, req admission.Request) ad
}
return admission.PatchResponseFromRaw(original, marshaled)
}

func (h *PodCreateHandler) injectSidecar4Pod(ctx context.Context, pod *corev1.Pod, cms *appsv1alpha1.ConfigMapSet, revisionKeys *configmapset.RevisionKeys) error {
Copy link
Member

Choose a reason for hiding this comment

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

consider move the pod mutating logic of comfigmapset into a sperate file e.g. configmapset.go

// 创建sidecar容器
newSidecar := corev1.Container{
Name: sidecarName,
Image: "hub.bilibili.co/infra-caster/kratos-demo-wuhao18:reload-sidecar",
Copy link
Member

Choose a reason for hiding this comment

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

how to config the image and possible container configuration such as poststarthook? Maybe we can add another CRD called ReloaderClass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants