-
Notifications
You must be signed in to change notification settings - Fork 580
Open
Description
π Issue: Incorrect label in kubectl get pods command in Chapter 7 (Service Discovery)
π Context
In Chapter 7: Service Discovery of Terraform: Up & Running, the book provides this command to retrieve the name of the alpaca pod:
$ ALPACA_POD=$(kubectl get pods -l app=alpaca -o jsonpath='{.items[0].metadata.name}')β Problem
The above command fails with the following error:
error: error executing jsonpath "{.items[0].metadata.name}": Error executing template: array index out of bounds: index 0, length 0.
This occurs because no pods match the label app=alpaca.
π Root Cause
The deployment created earlier in the chapter labels the pods with:
labels:
app: alpaca-prodTherefore, the kubectl command is using the wrong label selector.
β Suggested Fix
The corrected command should be:
ALPACA_POD=$(kubectl get pods -l app=alpaca-prod -o jsonpath='{.items[0].metadata.name}')This properly matches the label used in the deployment and allows the command to succeed without an index out-of-bounds error.
π Request
Please update the command in Chapter 7 and/or the example code repository so that readers donβt run into this issue.
Thanks for maintaining such a helpful and practical book!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels