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?
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.
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...