添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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 lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

kubectl patch configmap dec --namespace=namespace1 --patch {"data": {"config": {"staticPasswords": {"email": " [email protected] ","hash": "1234"}}}}
zsh: parse error near `}'

kubectl patch --type=json configmap dec --namespace=namespace1 --patch '{"data": {"config": {"staticPasswords": {"email": " [email protected] ","hash": "1234"}}}}'
Error from server (BadRequest): json: cannot unmarshal object into Go value of type jsonpatch.Patch

kubectl patch configmap dec --namespace=namespace1 --patch 'data:\n config:\n staticPasswords:\n - email: [email protected] \n hash: 1234'
error: unable to parse "data:\n configl:\n staticPasswords:\n - email: [email protected] \n hash: 1234": yaml: mapping values are not allowed in this context

What did you expect to happen?

The configmap should have successfully patched and appended the json data

How can we reproduce it (as minimally and precisely as possible)?

run the below commands on a unix system:
kubectl patch configmap dec --namespace=namespace1 --patch {"data": {"config": {"staticPasswords": {"email": " [email protected] ","hash": "1234"}}}}

kubectl patch --type=json configmap dec --namespace=namespace1 --patch '{"data": {"config": {"staticPasswords": {"email": " [email protected] ","hash": "1234"}}}}'

kubectl patch configmap dec --namespace=namespace1 --patch 'data:\n config:\n staticPasswords:\n - email: [email protected] \n hash: 1234'

Anything else we need to know?

No response

Kubernetes version

kubectl version  
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.16", GitCommit:"60e5135f758b6e43d0523b3277e8d34b4ab3801f", GitTreeState:"clean", BuildDate:"2023-01-18T16:01:10Z", GoVersion:"go1.19.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"23+", GitVersion:"v1.23.17-eks-0a21954", GitCommit:"cd5c12c51b0899612375453f7a7c2e7b6563f5e9", GitTreeState:"clean", BuildDate:"2023-04-15T00:32:27Z", GoVersion:"go1.19.6", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

OS version

$ uname -a
noorins@noorinsBMD6R symphony % uname -a
Darwin noorinsBMD6R.vmware.com 21.6.0 Darwin Kernel Version 21.6.0: Thu Mar  9 20:08:59 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_X86_64 x86_64

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

Hi @noorinshaikh,

See Blog post https://kubernetes.io/blog/2021/05/14/using-finalizers-to-control-deletion/#understanding-finalizers which is having example of patch configmap and check where you are doing wrong.

I hope that will be helpful to you.

ConfigMap data is a key-value struct, so you can't patch a nested JSON data. Also you should escape quotes in JSON value.

$ k patch cm dec --patch '{"data": {"config": "{\"staticPasswords\": {\"email\": \"[email protected]\",\"hash\": \"1234\"}}"}}'
configmap/dec patched
$ k get cm dec -o yaml
apiVersion: v1
data:
  config: '{"staticPasswords": {"email": "[email protected]","hash": "1234"}}'
kind: ConfigMap
metadata:
  creationTimestamp: "2023-05-25T05:59:36Z"
  name: dec
  namespace: default
  resourceVersion: "1424"
  uid: 474eb9c7-f52b-4e59-a4b5-59dbafe8343a

/remove-kind bug
/kind support

@iyear Thanks for the response,
However I need it to append something like this:

Before patch:

apiVersion: v1
data:
  config: |
    issuer: xxxxx
    storage:
      type: kubernetes
      config:
        inCluster: true
      http: 0.0.0.0:4444
    logger:
      level: "debug"
      format: text
    oauth2:
      skipApprovalScreen: true
    enablePasswordDB: true
    staticPasswords:
    - email: [email protected]
      hash: 1234
      username: user1
      userID: "1"
    staticClients:
    # https://github.com/dexidp/dex/pull/1664
    - idEnv: IIIIIID
      redirectURIs: ["/login/xyz"]
      name: 'Dec Login App'
      secretEnv: CLIENT_SECRET
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: dec
    meta.helm.sh/release-namespace: default
  creationTimestamp: "2022-11-29T03:11"
  labels:
    app.kubernetes.io/managed-by: Helm
  name: dec
  namespace: auth
  resourceVersion: "98765"
  uid: a9665139-35a5-4567-91bg-1db9eb431def

Patch data:

data:
  config: |
    staticPasswords:
    - email: [email protected]
      hash: 12345
      username: user2

After patch:

apiVersion: v1
data:
  config: |
    issuer: xxxxx
    storage:
      type: kubernetes
      config:
        inCluster: true
      http: 0.0.0.0:4444
    logger:
      level: "debug"
      format: text
    oauth2:
      skipApprovalScreen: true
    enablePasswordDB: true
    staticPasswords:
    - email: [email protected]
      hash: 1234
      username: user1
      userID: "1"
    - email: [email protected]
      hash: 12345
      username: user2
    staticClients:
    # https://github.com/dexidp/dex/pull/1664
    - idEnv: IIIIIID
      redirectURIs: ["/login/xyz"]
      name: 'Dec Login App'
      secretEnv: CLIENT_SECRET
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: dec
    meta.helm.sh/release-namespace: default
  creationTimestamp: "2022-11-29T03:11"
  labels:
    app.kubernetes.io/managed-by: Helm
  name: dec
  namespace: auth
  resourceVersion: "98765"
  uid: a9665139-35a5-4567-91bg-1db9eb431def
          

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed
  • You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage
  • Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

    lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 21, 2024

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed
  • You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage
  • Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle rotten

    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 Feb 20, 2024

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed
  • You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage
  • Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

    @k8s-triage-robot: Closing this issue, marking it as "Not Planned".

    In response to this:

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed
  • You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage
  • Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

    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.

    lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/cli Categorizes an issue or PR as relevant to SIG CLI.