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

kubectl patch fails with Error from server: json: cannot unmarshal string into Go value #56980

Closed
uladzimir-shelhunou opened this issue Dec 9, 2017 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/windows Categorizes an issue or PR as relevant to SIG Windows.

Comments

@uladzimir-shelhunou
Copy link

uladzimir-shelhunou commented Dec 9, 2017

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

kubectl --namespace=dev patch serviceaccount default -p '{"imagePullSecrets":[{"name":"gcr-json-key"}]}'

Fails with

Error from server: json: cannot unmarshal string into Go value of type map[string]interface {}

What you expected to happen:

Service account is updated

How to reproduce it (as minimally and precisely as possible):

  1. Install minikube
  2. choco install kubernetes-cli --version 1.8.5
  3. kubectl create namespace dev
  4. kubectl --namespace=dev create secret docker-registry gcr-json-key --docker-server=https://eu.gcr.io --docker-username=_json_key --docker-password="---PASSWORD---" --docker-email=myemail@gmail.com
  5. kubectl --namespace=dev patch serviceaccount default -p '{"imagePullSecrets":[{"name":"gcr-json-key"}]}'

Environment:

  • Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.1", GitCommit:"f38e43b221d08850172a9a4ea785a86a3ffa3b3a", GitTreeState:"clean", BuildDate:"2017-10-11T23:27:35Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"0b9efaeb34a2fc51ff8e4d34ad9bc6375459c4a4", GitTreeState:"clean", BuildDate:"2017-11-29T22:43:34Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"linux/amd64"}

  • Cloud provider or hardware configuration:
    minikube

  • OS (e.g. from /etc/os-release):
    Windows and minikube

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 9, 2017
@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Dec 9, 2017
@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/windows Categorizes an issue or PR as relevant to SIG Windows. labels Dec 9, 2017
@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Dec 9, 2017
@uladzimir-shelhunou
Copy link
Author

uladzimir-shelhunou commented Dec 10, 2017

I found the issue when I added --v=8.

JSON should be specified in the following way:

kubectl --namespace=dev patch serviceaccount default -p "{\"imagePullSecrets\":[{"name\":\"gcr-json-key\"}]}"

@althafuddin
Copy link

Also I found out from --v=8,

the below worked for me (No qoutes for -p command)

kubectl patch horizontalpodautoscalers.autoscaling qa-master-instance -p {"spec":{"maxReplicas":4}}

@dexterpuru
Copy link

I ran this
kubectl patch configmap/aws-auth -n kube-system --patch /aws-auth-patch.yml
but it shows the same error

@Sunkanmyt
Copy link

Sunkanmyt commented Oct 7, 2022

@dexterpuru where you able to solve the error?

@MeD1100
Copy link

MeD1100 commented Jun 9, 2023

I found the issue when I added --v=8.

JSON should be specified in the following way:

kubectl --namespace=dev patch serviceaccount default -p "{"imagePullSecrets":[{"name":"gcr-json-key"}]}"

I ran into a similar error and this fixed it:
kubectl patch deployment coredns -n kube-system --type json -p="[{"op": "remove", "path": "/spec/template/metadata/annotations/eks.amazonaws.com~1compute-type"}]"
--> deployment.apps/coredns patched

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/windows Categorizes an issue or PR as relevant to SIG Windows.
Projects
None yet
Development

No branches or pull requests

7 participants