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 replaces spec/template/spec/containers #538

Closed
mtsmfm opened this issue Jun 17, 2020 · 4 comments
Closed

kustomize replaces spec/template/spec/containers #538

mtsmfm opened this issue Jun 17, 2020 · 4 comments

Comments

@mtsmfm
Copy link
Contributor

mtsmfm commented Jun 17, 2020

Deployment keeps image: alpine but Rollout doesn't even if I use transformer described in https://argoproj.github.io/argo-rollouts/features/kustomize/.

Is this intentional?

https://github.com/mtsmfm/argo-rollout-with-kustomize-issue

$ kustomize version
{Version:3.6.1 GitCommit:c97fa946d576eb6ed559f17f2ac43b3b5a8d5dbd BuildDate:2020-05-27T23:39:00+01:00 GoOs:darwin GoArch:amd64}
$ kustomize build test-deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  template:
    spec:
      containers:
      - image: alpine
        name: test
        resources:
          requests:
            memory: 1Mi
$ kustomize build test-rollout
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: test
spec:
  template:
    spec:
      containers:
      - name: test
        resources:
          requests:
            memory: 1Mi
@jessesuen
Copy link
Member

The issue is that kustomize does not support strategic merge patching of custom resources, so the patch you have defined, is actually replacing the entire list of containers. See https://github.com/jessesuen/kustomize-examples/tree/master/strategic-merge-patch-crd-fail for details.

@jessesuen
Copy link
Member

Closing since this is a kustomize limitation. When we reached out to kustomize maintainers about feature parity of native types for CRDs, we were told to follow kubernetes-sigs/kustomize#2339.

@hjanuschka
Copy link

since kubernetes-sigs/kustomize#2339 still not merged, for others who might stumble upon this.

i just used Deployment in the whole kustomize pipeline.
and later on changing resource kind to Rollout

kustomization.yaml

patches:
- path: patches/transform_to_rollout.json
  target:
    group: apps
    version: v1
    kind: Deployment
    name: frontend

transform_to_rollout.json

[
    {
        "op": "replace",
        "path": "/spec/strategy",
        "value": {
            "blueGreen": {
                "autoPromotionEnabled": true,
                "activeService": "frontend"
            }
        }
    },
    {
        "op": "replace",
        "path": "/kind",
        "value": "Rollout"
    },
    {
        "op": "replace",
        "path": "/apiVersion",
        "value": "argoproj.io/v1alpha1"
    }
]

if you'd used "commonLables" you also might need to change/add some of them.

@tsurankov
Copy link

@hjanuschka Unfortunately, this removes configMapGenerator's hash because the kind is changed

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

No branches or pull requests

4 participants