You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes中Helm回滚机制及实现相关问题咨询

How Helm's Rollback Feature Works: A Deep Dive

Great question! Let's break down how Helm's rollback functionality operates, addressing each of your specific concerns clearly:

1. Core Implementation of Rollback

Every time you run helm install, helm upgrade, or even helm rollback, Helm creates a new version entry for your Release. Rollback itself is essentially restoring your cluster resources to the state defined by a specific historical Release version:

  • First, Helm fetches the full configuration of your target version (including Chart templates, custom values, hooks, and metadata) from its storage.
  • It then compares the current state of your cluster resources against the desired state from the target version, calculating exactly what changes are needed—whether that's recreating a deleted Deployment, reverting a ConfigMap's content, or adjusting a Service's ports.
  • After applying these changes, Helm adds a new version entry to the Release's history to log the rollback action (so you can always roll forward again if needed).

2. Data Storage for Old Release Configs

By default, Helm uses Kubernetes ConfigMaps to store all Release history and configuration data. These ConfigMaps live in the kube-system namespace, with a naming pattern like sh.helm.release.v1.<release-name>.v<version>—each version gets its own dedicated ConfigMap.

If you're dealing with sensitive data (like passwords or API keys in your values), you can switch to using Kubernetes Secrets as the storage backend instead. Just add the --storage=secret flag when running helm install or helm upgrade, and Helm will store all Release data in Secrets for enhanced security.

3. Limit on Continuous Rollbacks

Out of the box, Helm retains the last 10 Release versions (this includes versions created by installs, upgrades, and rollbacks). So the maximum number of consecutive rollbacks you can perform depends on how many historical versions are saved—for example, if you have 10 versions, you can roll back 9 times to reach the oldest retained version.

Keep in mind that every rollback creates a new version entry, so rolling back from v10 to v9 adds an v11 entry, which counts towards the history limit.

4. Can You Modify This Limit?

Absolutely! You can adjust the number of retained versions in two ways:

  • Per Release: When installing or upgrading a Release, use the --history-max=<number> flag to set a custom limit for that specific Release. For example:
    helm upgrade my-app ./my-chart --history-max=20
    
    This will keep the last 20 versions for my-app, letting you roll back further than the default.
  • Global Default: Edit your Helm configuration file (typically located at ~/.config/helm/helm.yaml) and add or update the history-max field:
    history-max: 20
    
    This sets a default limit for all new Releases you create, though you can still override it with the per-release flag if needed.

内容的提问来源于stack exchange,提问作者lokanadham100

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:03:37