Skip to content

how to add/replace container env in OverridePolicy and keep other envs alive? #3362

@mkloveyy

Description

@mkloveyy

This is part of my deployment:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
      - env:
        - name: CPUS
          value: "1"

This is part of my OverridePolicy:

apiVersion: policy.karmada.io/v1alpha1
kind: OverridePolicy
spec:
  overrideRules:
  - targetCluster:
        clusterNames:
          - sharb-x
      overriders:
        plaintext:
          - path: /spec/template/spec/containers/0/env
            operator: add
            value:
              - name: TEST
                value: captain-test

I wish my cluster sharb-x deployment may be:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
      - env:
        - name: CPUS
          value: "1"
        - name: TEST
          value: captain-test

But actual is:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
      - env:
        - name: TEST
          value: captain-test

CPUS env is missing.

So how can I add or replace container env in OverridePolicy and keep other envs alive?
Thanks!

Environment:

  • Karmada version: v1.4.1-with-lua
  • Kubernetes version: 1.19
  • Others:

Metadata

Metadata

Assignees

Labels

kind/questionIndicates an issue that is a support question.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions