양상헌:
Hello all,
jsonpath question in lab;
Question is
Use a JSON PATH query to identify the context configured for the aws-user in the my-kube-config context file and store the result in /opt/outputs/aws-context-name.
my answer is ;
controlplane $ k config view --kubeconfig=my-kube-config -o jsonpath=‘{.contexts[?(@.context.user == “aws-user”)].context}’ > /opt/outputs/aws-context-name
cat /opt/outputs/aws-context-name
{“cluster”:“kubernetes-on-aws”,“user”:“aws-user”}controlplane $
As mentioned in question request, I got the context for aws-user,
But actual answer is the context name for aws-user;
kubectl config view --kubeconfig=my-kube-config -o jsonpath=“{.contexts[?(@.context.user==‘aws-user’)].name}” > /opt/outputs/aws-context-name
controlplane $ kubectl config view --kubeconfig=my-kube-config -o jsonpath=“{.contexts[?(@.context.user==‘aws-user’)].name}”
aws-user@kubernetes-on-awscontrolplane $
Did I miss something ?