Kustomize: kubectl seems to fail on replicas

Created on 8 Jan 2020  路  10Comments  路  Source: kubernetes-sigs/kustomize

My specs:
~
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-13T11:51:44Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:13:49Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
~

Hi all,

I am having an issue with 'replicas' in the kustomization file.

If we take the following files as an example:

~yaml
kind: Deployment
apiVersion: apps/v1
metadata:
name: bar
labels:
app: bar
spec:
replicas: 3
~

~~~yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:

  • ../../base
    namespace: foo
    images:
    replicas:
  • name: bar
    count: 1
    ~~~

If I try to apply it using kubectl's built in kustomization, I get:

~ bash
$ kubectl apply -k foo/apps/bar/overlay/poc
error: json: unknown field "replicas"
~

But if I do it the good old fashion way,

~ bash
$ kustomize build foo/apps/bar/overlay/poc| kubectl apply -f -
~

I get

~~~yaml

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: bar
name: bar
namespace: foo
spec:
replicas: 1
~~~

Is this a bug or am I missing something? Thank you for your help.

Most helpful comment

Same here.
Workaround until fix:

kustomize build <kustomize-dir> | kubectl apply -f -

All 10 comments

I've noticed the same problem.

I'm also noticing this with the patches field within patchesJson6902 for inline patches. This occurs when trying to use kustomize resource diff also.

Same here.

Doubt if this is a bug on windows only

I think the problem might be that "replicas" is missing in the kustomize JSON schema at https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/kustomization.json

I think the Kustomize in Kubectl is not up to date. Plenty of the features on the document are not working with Kubectl embedded Kustomize.

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

Same here.
Workaround until fix:

kustomize build <kustomize-dir> | kubectl apply -f -

@robertogyn19 thanks for the work around, can confirm this works well.

A bit of a shame some of these features aren't working, I've just committed to switching our current unruly structure over to kustomize! Hopefully we can get a lil bit of love :)

/remove-lifecycle stale

+1

kubectl is using a very old version of kustomize. Unfortunately we cannot update it now for some technical reasons but we are working on it. Please use latest version of kustomize.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Liujingfang1 picture Liujingfang1  路  4Comments

nicks picture nicks  路  3Comments

bcbrockway picture bcbrockway  路  5Comments

mgoodness picture mgoodness  路  4Comments

drekle picture drekle  路  4Comments