My config map looks like this:
apiVersion: v1
data:
my-data.yaml |2-
#data comes here
kind: ConfigMap
Is it possible to extract the content of my-data.yaml
key via
oc get configmap
or any other oc
command?
e.g.
oc get configmap myconfigmap -o=yaml <[only my-data.yaml]>
I'd like to demonstrate an example command, which "coderanger" mentioned before.
This example converted from yaml to json and filtered ".keyname" using "jq" command after that. You can also use "yq" command instead of python one-liner and jq combination.
oc get configmap/myconfigmap \
-o "jsonpath={ .data['my-data\.yaml']}" | \
python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' | \
jq '. | .keyname'
I hope it help you.