Answer a question

I'm attempting to trigger a Kubeless function (written as a Java method) and it doesn't seem to be working. I've tried everything I can think to try, but I've run out of ideas. Below is the Java method (it's basically an echo service, for now).

package io.kubeless;

import io.kubeless.Context;
import io.kubeless.Event;

public class MyHandler {
    public String handle(Event event, Context context) {
        return event.Data;
    }
}

The method was deployed using the following:

$ kubeless function deploy my-handler --runtime java1.8 --handler MyHandler.handle --from-file src/main/java/io/kubeless/MyHandler.java

I have verified it works by running the following:

$ kubeless function call my-handler --data "It works"
$ kubectl logs my-handler-6f67d567c5-r8cdb
    0 [pool-1-thread-38] INFO io.kubeless.Handler  - Response: It works

I then created a Kafka trigger and published a message to it using the following.

$ kubeless trigger kafka create test --function-selector created-by=kubeless,function=my-handler --trigger-topic test-topic
$ kubeless topic publish --topic test-topic --data "Hello from Kafka"
$ kubectl logs my-handler-6f67d567c5-r8cdb
    0 [pool-1-thread-38] INFO io.kubeless.Handler  - Response: It works

As you can see, the only log entry is the one from the initial call that wasn't triggered by a Kafka pub/sub. I have verified the trigger exists:

$ kubeless trigger kafka ls
NAME    NAMESPACE   TOPIC       FUNCTION SELECTOR
test    default     test-topic  function=my-handler

As far as I can tell, Kafka seems to be running (I've also checked the Kafka logs, to no avail):

$ kubectl get pods --namespace=kubeless
NAME                                          READY   STATUS    RESTARTS   AGE
kafka-0                                       1/1     Running   0          170m
kafka-trigger-controller-f6f7c699f-m6mcd      1/1     Running   0          170m
kubeless-controller-manager-59d484f4d-9wlhq   3/3     Running   10         4d22h
zoo-0                                         1/1     Running   0          170m

Why is publishing not triggering the function? Any suggestions are appreciated and I thank you in advance.

Answers

I nerded out on this and there's an issue with the Kubeless kafka-trigger. Essentially, I'm getting this log when the message is picked up by the controller and tries to trigger the function:

time="2020-07-14T22:00:15Z" level=error msg="Unable to elaborate request: Unable to find the service for function my-handler"

This means that the controller cannot find the my-handler service to trigger the function. If you see the code, you see that it's a call to the K8s API server. So, my guess is that there's an API version mismatch on the newer K8s versions. My server is v1.18.2. I've created this issue to track.

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐