<p>I can get all the things of a list of objects, such as <code>Secrets</code> and <code>ConfigMaps</code>.</p>

<pre><code>{
"kind": "SecretList",
"apiVersion": "v1",
"metadata": {
    "selfLink": "/api/v1/namespaces/kube-system/secrets",
    "resourceVersion": "499638"
},
"items": [{
    "metadata": {
        "name": "aaa",
        "namespace": "kube-system",
        "selfLink": "/api/v1/namespaces/kube-system/secrets/aaa",
        "uid": "96b0fbee-f14c-423d-9734-53fed20ae9f9",
        "resourceVersion": "1354",
        "creationTimestamp": "2020-02-24T11:20:23Z"
    },
    "data": "aaa"
}]
}
</code></pre>

<p>but I only want the name list, for this example :<code>"aaa"</code>. Is there any way?</p>

qinghai5060
<p>Yes, you can achieve it by using <code>jsonpath</code> output. Note that the specification you posted will look quite differently once applied. It will create one <code>Secret</code> object in your <code>kube-system</code> namespace and when you run:</p>

<pre><code>$ kubectl get secret -n kube-system aaa -o json
</code></pre>

<p>the output will look similar to the following:</p>

<pre><code>{
    "apiVersion": "v1",
    "kind": "Secret",
    "metadata": {
        "creationTimestamp": "2020-02-25T11:08:21Z",
        "name": "aaa",
        "namespace": "kube-system",
        "resourceVersion": "34488887",
        "selfLink": "/api/v1/namespaces/kube-system/secrets/aaa",
        "uid": "229edeb3-57bf-11ea-b366-42010a9c0093"
    },
    "type": "Opaque"
}
</code></pre>

<p>To get only the <code>name</code> of your <code>Secret</code> you need to run:</p>

<pre><code>kubectl get secret aaa -n kube-system -o jsonpath='{.metadata.name}'
</code></pre>
