Making native Kubeless calls via REST

8/31/2017

I want to submit a function (via http-trigger) from a NodeJS process to kubeless but I do not want to use the javascript equivalent of

curl --data '{"term":"Albemarle"}' localhost:8080/api/v1/proxy/namespaces/default/services/bikesearch/ --header "Content-Type:application/json"

because that needs me to know the actual IP address of the service running the function. I want to be able to access the kubeless api that gives me the level of indirection by just knowing the name of the function

kubeless function call bikesearch --data '{"term":"Albemarle"}'

Is there anyway to access the above ( function call ) api via node?

-- House Targaryen
curl
kubernetes
node.js
rest
serverless-framework

2 Answers

9/3/2017

If DNS is correctly configured for your cluster, you can also directly access the Kubernetes master under the kubernetes DNS name.

Another way is environment variables. Kubernetes itself is registered as a service, so you can use the KUBERNETES_SERVICE_HOST environment variable.

For newer Kubernetes versions you have to authenticate, so have a look at how to access the API server from within a pod.

-- user3151902
Source: StackOverflow

9/4/2017

kubeless also creates services for functions, so you should able to just do a http get to http://bikesearch:8080 if your DNS setup is working and your application is in the same namespace. If you are in another namespace you need to use a more qualified name, e.g. bikesearch.<function-namespace>svc.cluster.local

If you want to call the function from outside the k8s cluster, you might want to create an Ingress with kubeless ingress create...

-- slintes
Source: StackOverflow