
Google Associate Cloud Engineer
Get started today
Ultimate access to all questions.
You're tasked with creating a script to extract the IP address of a Kubernetes Service. Your coworker has shared a code snippet they believe could be useful. Which option would serve as the best foundation for your code?
You're tasked with creating a script to extract the IP address of a Kubernetes Service. Your coworker has shared a code snippet they believe could be useful. Which option would serve as the best foundation for your code?
Real Exam
Explanation:
The correct answer is D because kubectl get svc
retrieves the service data, and jsonpath
is used to parse the data specifically for the IP address. This method is documented in Kubernetes resources for accurately extracting service details. For example, to access services, you might use commands like:
export EXTERNAL_IP=$(kubectl get service bootcamp –output=jsonpath='{.status.loadBalancer.ingress[0].ip}')
export PORT=$(kubectl get services –output=jsonpath='{.items[0].spec.ports[0].port}')
curl "$EXTERNAL_IP:$PORT"
This would return the service's external IP and port, allowing you to interact with the service directly.