Skip to content

Commit 5e9e7d0

Browse files
authored
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.
1 parent 5328fdf commit 5e9e7d0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

content/en/docs/reference/kubectl/cheatsheet.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ kubectl get pods --selector=app=cassandra -o \
177177
kubectl get configmap myconfig \
178178
-o jsonpath='{.data.ca\.crt}'
179179

180+
# Retrieve a value with dashes instead of underscores.
181+
kubectl get secret mysecret --template='{{index .data "key-name-with-dashes"}}'
182+
180183
# Get all worker nodes (use a selector to exclude results that have a label
181184
# named 'node-role.kubernetes.io/master')
182185
kubectl get node --selector='!node-role.kubernetes.io/master'

0 commit comments

Comments
 (0)