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

StatefulSet volumeclaimtemplates added when base did not include it #504

Closed
msau42 opened this issue Oct 25, 2018 · 16 comments
Closed

StatefulSet volumeclaimtemplates added when base did not include it #504

msau42 opened this issue Oct 25, 2018 · 16 comments
Labels
area/api issues for api module kind/bug Categorizes issue or PR as related to a bug. triage/not-reproducible Indicates an issue can not be reproduced as described.

Comments

@msau42
Copy link

msau42 commented Oct 25, 2018

This might be caused to #483

I have a StatefulSet spec that doesn't use volumeClaimTemplates, but when I kustomize it with common labels, it adds it to the spec, which causes it to fail validation:

My base spec:

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: test
spec:
  serviceName: "test"
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - name: nginx
          image: nginx

After kustomize:

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: test
spec:
  serviceName: "test"
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - name: nginx
          image: nginx
  volumeClaimTemplates:
    metadata:
      labels:
        app: my-label

Error:

error validating data: ValidationError(StatefulSet.spec.volumeClaimTemplates): invalid type for io.k8s.api.apps.v1.StatefulSetSpec.volumeClaimTemplates: got "map", expected "array"; if you choose to ignore these errors, turn validation off with --validate=false
@Liujingfang1
Copy link
Contributor

I'll look into this issue. Before we have a fix, you can unblock yourself with following steps to modify the transformer configurations.

kustomize config save -d ~/.kustomize/config

In ~/.kustomize/config/commonlabel.YAML, remove ollowing block or change create from true to false

-path: spec/volumeClaimTemplates/metadata/labels
  create: true
  group: apps
  kind: StatefulSet

When you run kustomize build, using -t to pick up the updated transformer configs.

kustomize build <die> -t ~/.kusotmize/config

@Liujingfang1 Liujingfang1 added the kind/bug Categorizes issue or PR as related to a bug. label Oct 26, 2018
@robbyt
Copy link

robbyt commented Oct 31, 2018

@Liujingfang1 Thank you for the workaround. I also have this same issue, after upgrading to release 1.0.9.

@twz123
Copy link
Contributor

twz123 commented Nov 19, 2018

I also hit this one. Interestingly, kustomize replaces absent volumeClaimTemplates - which are usually an array - with a map. Note the missing hyphen in the above example. I think kustomize's transformer configs miss a distinction between something that is an array vs something that is an object.

In my use case, overriding transformer configs is not helping much, since I have a kustomization that has both statefulsets with and without volumeClaimTemplates. I use a patch instead that explicitly sets volumeClaimTemplates: [].

twz123 added a commit to twz123/kustomize that referenced this issue Dec 9, 2018
If path segments end with the special marker `[]` in transformer configs, this
indicates that the respective path segment is supposed to be an array. That
information may be used to suppress the meaningless creation of non-existent
paths that should be arrays, not objects.
@turbotankist
Copy link

put

spec:
 volumeClaimTemplates: []

in your StatefulSet yml

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 2, 2019
@schweikert
Copy link
Contributor

The workaround described in #504 (comment) doesn't work anymore with kustomize 2.0.3 because the -t option is not supported anymore. Also, it seems that it is not possible to override the configuration of the commonLabels transformer (using configurations:...)

The other workaround of using "volumeClaimTemplates: []" doesn't work for me because kubectl apply complains about a forbidden change.

In other words: we need this fix :) Right now we are stuck with kustomize 1.0.8

@gysel
Copy link

gysel commented May 15, 2019

We're also struggling with this issue.

The workaround using volumeClaimTemplates: [] kind of works but results in for: "STDIN": StatefulSet.apps "xxx" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden. for every deployment.

@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 14, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Djabx
Copy link

Djabx commented Aug 21, 2019

The issue is always here.
/reopen

@k8s-ci-robot
Copy link
Contributor

@Djabx: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

The issue is always here.
/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@HenriTEL
Copy link

HenriTEL commented Feb 6, 2020

As pointed out by @gysel you can set volumeClaimTemplates: [] to make kustomize not generate a wrong StatefulSet.
You can try a kubectl patch to work around the Forbidden: updates to statefulset spec error when the StatefulSet is already deployed.

@arianvp
Copy link

arianvp commented Nov 24, 2020

This issue is still very relevant though right? Kustomize generates a manifest that isn't even valid. Which is kind of the exact opposite of the promise that kustomize tries to make. Can we reopen this?

@Shell32-Natsu Shell32-Natsu reopened this Nov 24, 2020
@Shell32-Natsu Shell32-Natsu added area/api issues for api module and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Nov 24, 2020
@Shell32-Natsu
Copy link
Contributor

I cannot reproduce this issue with latest kustomize. If you are using kustomize shipped with kubectl, please take a look at #1500 and #2506.

@Shell32-Natsu Shell32-Natsu added the triage/not-reproducible Indicates an issue can not be reproduced as described. label Nov 24, 2020
@arianvp
Copy link

arianvp commented Nov 24, 2020

Yep you're right. I cant reproduce either on latest kustomize. Feel free to close this issue then in favour of the other two you just linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api issues for api module kind/bug Categorizes issue or PR as related to a bug. triage/not-reproducible Indicates an issue can not be reproduced as described.
Projects
None yet
Development

Successfully merging a pull request may close this issue.