I have a config map that looks like this:
kubectl describe configmap example-config --namespace kube-system
Name: example-config
Namespace: kube-system
Labels: <none>
Annotations: <none>
Data
====
mapRoles:
----
- rolearn: arn:aws:iam::0123456789012:role/user-role-1
username: system:node:{{EC2PrivateDNSName}}
groups:
- system:bootstrappers
- system:nodes
- rolearn: arn:aws:iam::0123456789012:role/user-role-2
username: system:node:{{EC2PrivateDNSName}}
groups:
- system:bootstrappers
- system:nodes
I want to remove user-role-2 from the configmap. I think I need to use kubectl patch with a "remove" operation. What is the syntax to remove a section from a config map?
Here is an example command I can use to append to the config map:
kubectl patch -n=kube-system cm/aws-auth --patch "{\"data\":{\"mapRoles\": \"- rolearn: "arn:aws:iam::0123456789012:role/user-role-3" \n username: system:node:{{EC2PrivateDNSName}}\n groups:\n - system:bootstrappers\n - system:nodes\n\"}}"