I have a kubernetes config file with some user info, like this:
users:
- name: arn:aws:eks:eu-west-1:123456789012:cluster/cluster1
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- --region
- eu-west-1
- eks
- get-token
- --cluster-name
- cluster1
command: aws
env:
- name: AWS_PROFILE
value: profile1
- name: arn:aws:eks:eu-west-1:210987654321:cluster/cluster2
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- --region
- eu-west-1
- eks
- get-token
- --cluster-name
- cluster2
command: aws
env:
- name: AWS_PROFILE
value: profile2
I’d like to remove the env part from both users but I can’t find the way to do it with kubectl config unset
.
For example, I can delete the full exec part from the user with name arn:aws:eks:eu-west-1:123456789012:cluster/cluster1 with:
kubectl config unset users.arn:aws:eks:eu-west-1:123456789012:cluster/cluster1.exec
users:
- name: arn:aws:eks:eu-west-1:123456789012:cluster/cluster1
user: {}
- name: arn:aws:eks:eu-west-1:210987654321:cluster/cluster2
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- --region
- eu-west-1
- eks
- get-token
- --cluster-name
- cluster2
command: aws
env:
- name: AWS_PROFILE
value: profile2
But if I try to delete only the env part with:
kubectl config unset users.arn:aws:eks:eu-west-1:123456789012:cluster/cluster1.exec.env
I get the following error message:
error: unable to parse one or more field values of users.arn:aws:eks:eu-west-1:123456789012:cluster/cluster1.exec.env
The source code for the unset command is at kubectl/unset.go at master · kubernetes/kubectl · GitHub but I’m not a Go guy and can’t guess the right syntax for the PROPERTY_NAME to delete just de env part.
Can someone give me a here?