Template syntax to retrieve values with dashes (-) in their key names
This template syntax was not obvious to me until someone pointed it out on stackexchange, it should be in the cheatsheet for future users. Because trying to retrieve a value with dashes in its key-name using the normal template syntax will result in an error.
This commit is contained in:
parent
5328fdf797
commit
5e9e7d0b21
|
|
@ -177,6 +177,9 @@ kubectl get pods --selector=app=cassandra -o \
|
|||
kubectl get configmap myconfig \
|
||||
-o jsonpath='{.data.ca\.crt}'
|
||||
|
||||
# Retrieve a value with dashes instead of underscores.
|
||||
kubectl get secret mysecret --template='{{index .data "key-name-with-dashes"}}'
|
||||
|
||||
# Get all worker nodes (use a selector to exclude results that have a label
|
||||
# named 'node-role.kubernetes.io/master')
|
||||
kubectl get node --selector='!node-role.kubernetes.io/master'
|
||||
|
|
|
|||
Loading…
Reference in New Issue