how can I use curl to test kubernetes API on ICp

2/7/2018

In kubernetes, master node provide kube-apiserver process to accept REST API requests. What about ICp? can we use curl command to quickly test k8s REST APIs on ICp master node as well?

-- Terry Hu
ibm-cloud-private
kubernetes
rest

1 Answer

2/7/2018

The answer is yes. But first you may need to pay attention to the default port for --insecure-port and --secure-port. By default, if you didn't change it in config.yaml file, ICp use below ports to accept REST requests:

--insecure-port=8888

--secure-port=8001

netstat -anp|grep 8888

or

netstat -anp|grep 8001

Or you can

ps -ef|grep apiserver

result something like:

root      5462  5442  9 Jan29 ?        22:48:09 /hyperkube apiserver
--secure-port=8001 --bind-address=0.0.0.0 --advertise-address=10.0.14.94 --insecure-port=8888 --insecure-bind-address=127.0.0.1 ......

Once you find the port, on master node, you can issue the curl quickly, first try via a insecure port:

curl http://localhost:8888/api

result something like:

{
  "kind": "APIVersions",
  "versions": [
    "v1"
  ],
  "serverAddressByClientCIDRs": [
    {
      "clientCIDR": "0.0.0.0/0",
      "serverAddress": "10.0.14.94:8001"
    }
  ]
}

further call to /api/v1 and /api/v1/pods, /api/v1/services are as you like.

But you cannot do the same on other node. On other node, you may have to use secure port, but with a -k parameter to ignore the certificate:

on client or other node:

curl -k https://10.0.14.94:8001/api

result should be the same unless you specify the ca certificate.

-- Terry Hu
Source: StackOverflow