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

Created on 9 Dec 2017  ·  3Comments  ·  Source: kubernetes/kubernetes

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---" [email protected]
  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

kinbug sicli siwindows

Most helpful comment

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\"}]}"

All 3 comments

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\"}]}"

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}}

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

errordeveloper picture errordeveloper  ·  3Comments

chowyu08 picture chowyu08  ·  3Comments

cooligc picture cooligc  ·  3Comments

rhohubbuild picture rhohubbuild  ·  3Comments

alexferl picture alexferl  ·  3Comments