title: kubectl jsonpath expression for named path
body: <p>I have kube service running with 2 named ports like this:</p>
  
  <pre><code>$ kubectl get service elasticsearch --output json
  {
      "apiVersion": "v1",
      "kind": "Service",
      "metadata": {
          ... stuff that really has nothing to do with my question ...
      },
      "spec": {
          "clusterIP": "10.0.0.174",
          "ports": [
               {
                  "name": "http",
                  "nodePort": 31041,
                  "port": 9200,
                  "protocol": "TCP",
                  "targetPort": 9200
              },
              {
                  "name": "transport",
                  "nodePort": 31987,
                  "port": 9300,
                  "protocol": "TCP",
                  "targetPort": 9300
              }
          ],
          "selector": {
              "component": "elasticsearch"
          },
          "sessionAffinity": "None",
          "type": "NodePort"
      },
      "status": {
          "loadBalancer": {}
      }
  }
  </code></pre>
  
  <p>I'm trying to get output containing just the 'http' port:</p>
  
  <pre><code>$ kubectl get service elasticsearch --output jsonpath={.spec.ports[*].nodePort}
  31041 31987
  </code></pre>
  
  <p>Except when I add the test expression as hinted in the cheatsheet here <a href="http://kubernetes.io/docs/user-guide/kubectl-cheatsheet/" rel="nofollow noreferrer">http://kubernetes.io/docs/user-guide/kubectl-cheatsheet/</a> for the name I get an error</p>
  
  <pre><code>$ kubectl get service elasticsearch --output jsonpath={.spec.ports[?(@.name=="http")].nodePort}
  -bash: syntax error near unexpected token `('
  </code></pre>