Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kustomize fail to merge .spec.template.spec.containers[].env fields #1730

Closed
shibataka000 opened this issue Dec 25, 2021 · 4 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@shibataka000
Copy link
Contributor

Summary

Kustomize overwrite Rollout's .spec.template.spec.containers[].env fields when overlay. I think kustomize should merge its field instead of overwriting.

Example

Manifests

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- rollouts.yaml
patchesStrategicMerge:
- |-
  apiVersion: argoproj.io/v1alpha1
  kind: Rollout
  metadata:
    name: rollouts-demo
  spec:
    template:
      spec:
        containers:
        - name: rollouts-demo
          image: nginx
          env:
          - name: KEY2
            value: VALUE2
openapi:
 path: rollout_cr_schema.json # Same as https://argoproj.github.io/argo-rollouts/features/kustomize/rollout_cr_schema.json
# rollouts.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  strategy:
    blueGreen:
      activeService: rollouts-demo-service
      previewService: rollouts-demo-service-preview
      autoPromotionEnabled: false
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: rollouts-demo
  template:
    metadata:
      labels:
        app: rollouts-demo
    spec:
      containers:
      - name: rollouts-demo
        image: argoproj/rollouts-demo:blue
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        env:
        - name: KEY1
          value: VALUE1

Expected output of kustomize build command

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: rollouts-demo
  strategy:
    blueGreen:
      activeService: rollouts-demo-service
      autoPromotionEnabled: false
      previewService: rollouts-demo-service-preview
  template:
    metadata:
      labels:
        app: rollouts-demo
    spec:
      containers:
      - env:
        - name: KEY1
          value: VALUE1
        - name: KEY2
          value: VALUE2
        image: nginx
        name: rollouts-demo
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP

Actual output of kustomize build command

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: rollouts-demo
  strategy:
    blueGreen:
      activeService: rollouts-demo-service
      autoPromotionEnabled: false
      previewService: rollouts-demo-service-preview
  template:
    metadata:
      labels:
        app: rollouts-demo
    spec:
      containers:
      - env:
        - name: KEY2
          value: VALUE2
        image: nginx
        name: rollouts-demo
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP

Note

I guess rollout_cr_schema.json lack following annotation at env properties.

"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge",

swagger.json, which is referred by gen-crd-spec, has forementioned annotation at env properties at L5873-L5881. But rollout_cr_schema.json lack forementioned annotation at env properties at following lines.

Diagnostics

$ kustomize version
{Version:kustomize/v4.4.0 GitCommit:63ec6bdb3d737a7c66901828c5743656c49b60e1 BuildDate:2021-09-27T16:24:12Z GoOs:linux GoArch:amd64}

Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritize the issues with the most 👍.

@shibataka000 shibataka000 added the bug Something isn't working label Dec 25, 2021
@huikang
Copy link
Member

huikang commented Dec 28, 2021

Looks like the rollout's kustomize json misses "x-kubernetes-patch-strategy" for all arrays types under the container field, env, ports, volumeDevices

@huikang
Copy link
Member

huikang commented Dec 29, 2021

@alexmt , would you mind taking a look at this one? Thanks.

@harikrongali harikrongali added this to the v1.2 milestone Jan 3, 2022
@huikang huikang self-assigned this Jan 14, 2022
@huikang huikang removed their assignment Mar 19, 2022
@perenesenko
Copy link
Member

This issue could be fixed with #2153

@jessesuen
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants