Welcome to the Linux Foundation Forum!

5.3 The API Endpoint

sporteboissportebois Posts: 10
edited January 2017 in LFS258 Class Forum

The snippet from this slide suggests us to ssh the minikube VM then to curl the API.

When I tried this I ran into the issue that minikube VM doesn't come with curl. 

After looking at some docs, I took another approach (and write this here in case other student wonder how to curl the API)

From my host machine, I ran 


kubectl proxy --port=8080 --api-prefix=/

To proxy the api endpoints on my localhost

 

I'm now able to curl the api with 


curl http://localhost:8080/apis | jq

curl http://localhost:8080/api

curl http://localhost:8080/api/va

 

Hope this might save some time to other students with the same issue.

 

Comments

  • sebgoasebgoa Posts: 23
    edited January 2017

    Unfortunately it looks like you are correct.

    The base OS used in minikube changed in v0.15.0 and curl is not available any more.

    I created a bug upstream to get it back: https://github.com/kubernetes/minikube/issues/1059

    In the meantime, I will update the course .

    thanks for reporting this and apologies for the lost time,

    -sebastien

  • Thank you for this!  Out of curiousity, which doc did you find that provided this information?

  • This actually does not seem to work completely for me.  I ran the proxy command and got


    Starting to serve on 127.0.0.1:8080

    which seems to be expected.  Then I opened up another shell and attempted to curl


    <h3>Unauthorized</h3>

    I got the same result when trying to sudo.

  • Figured it out.  I have to hit the endpoints listed above directly.  I couldn't just hit local host on 8080 with specifyin a uri.

  • sebgoasebgoa Posts: 23
    edited February 2017

    Kubernetes developers are putting curl again in the newest version of minikube, so this should not affect folks once there is a new release of minikube.

  • Great news!

    @ryankbales , re your question about the doc... to be honest I don't remember (there are so many docs out there!) I came across this after some googling to try to find out how to make this works ;-) 

  • lalan7lalan7 Posts: 1
    edited October 2017

    This is how you can connect to the api with the minikube 0.22.3



     


    $ APISERVER=$(kubectl config view | grep server | cut -f 2- -d ":" | tr -d " ") $ TOKEN=$(kubectl describe secret $(kubectl get secrets | grep default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d '\t') $ curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure { "kind": "APIVersions", "versions": [ "v1" ], "serverAddressByClientCIDRs": [ { "clientCIDR": "0.0.0.0/0", "serverAddress": "10.0.1.149:443" } ] }
  • sebgoasebgoa Posts: 23
    edited November 2017

    Or you can simply run a proxy `kubectl proxy` and then `curl localhost:8001/api`

  • emanseravemanserav Posts: 3
    edited November 2017

    @sebgoa, the course has not been updated yet, not in the PDF, nor in the course itself.

    Indeed if you run a "kubectl proxy" that will start to serve on your machine on 127.0.0.1:8001 and you can then curl as you mentioned above.  

Sign In or Register to comment.