Skip to content

fix: allow converting envs from value to valueFrom#643

Merged
samuelvl merged 1 commit intomainfrom
avoid-k8s-merge-bug
Feb 19, 2026
Merged

fix: allow converting envs from value to valueFrom#643
samuelvl merged 1 commit intomainfrom
avoid-k8s-merge-bug

Conversation

@samuelvl
Copy link
Contributor

@samuelvl samuelvl commented Feb 19, 2026

When kvisor is installed to read the cluster id from a configmap:

helm upgrade -i castai-kvisor ./charts/kvisor -n castai-agent \
  --set castai.clusterIdConfigMapKeyRef=castai-agent-metadata

The value is exposed as an environment variable using valueFrom:

- name: CLUSTER_ID
  valueFrom:
    configMapKeyRef:
      key: CLUSTER_ID
      name: castai-agent-metadata

If we now want to read the cluster id directly from a string we can do:

helm upgrade -i castai-kvisor ./charts/kvisor -n castai-agent \
  --set castai.clusterID=foo --reset-then-reuse-values

However this will fail because Helm can't apply valueFrom->value or value->valueFrom since the three-way merge keeps the existing setting and adds the new one, which is invalid (can't have both value and valueFrom defined):

Error: cannot patch "castai-kvisor-agent" with kind DaemonSet: DaemonSet.apps "castai-kvisor-agent" is invalid: spec.template.spec.containers[0].env[6].valueFrom: Invalid value: "": may not be specified when `value` is not empty && cannot patch "castai-kvisor-controller" with kind Deployment: Deployment.apps "castai-kvisor-controller" is invalid: spec.template.spec.containers[0].env[5].valueFrom: Invalid value: "": may not be specified when `value` is not empty

The fix is doing the same as in castai/helm-charts#1092

@samuelvl samuelvl merged commit 032475e into main Feb 19, 2026
3 checks passed
@samuelvl samuelvl deleted the avoid-k8s-merge-bug branch February 19, 2026 16:48
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.

2 participants

Comments