Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scaling out camel-k integrations are not working correctly #1806

Closed
arijitmazumdar opened this issue Nov 7, 2020 · 7 comments
Closed

scaling out camel-k integrations are not working correctly #1806

arijitmazumdar opened this issue Nov 7, 2020 · 7 comments
Labels
kind/question Further information is requested

Comments

@arijitmazumdar
Copy link

Hi
I have written a simple camel-k component which exposes a rest endpoint, which responds back.

import org.apache.camel.builder.RouteBuilder;

public class BasicRest extends RouteBuilder {
  @Override
  public void configure() throws Exception {

      from("rest:get:hello/{name}")
        .transform().simple("Bye World, ${header.name} from --> ${hostname}!!")
        .log("Got 1 hello");
  }
}

I have deployed the component using kamel run BasicRest.java --dev
I have scaled the integration using kubectl scale it basic-rest --replicas=2
This created 2 instances

$ kubectl  get it
NAME         PHASE     KIT                        REPLICAS
basic-rest   Running   kit-buekus3365fim0fprqeg   2

$ kubectl get po
NAME                               READY   STATUS    RESTARTS   AGE
basic-rest-65cb866cd7-g9lpv        1/1     Running   0          12m
basic-rest-65cb866cd7-tvl77        1/1     Running   0          12m
camel-k-operator-8bd669468-sbpv2   1/1     Running   3          7d2h

I have port-forwarded the service using kubectl port-forward svc/basic-rest 8080:80
But when I am doing a curl to the endpoint I can only see same response.

$curl localhost:8080/hello/arijit 
Bye World, arijit from --> basic-rest-65cb866cd7-g9lpv!!
$ curl localhost:8080/hello/arijit 
Bye World, arijit from --> basic-rest-65cb866cd7-g9lpv!!
$ curl localhost:8080/hello/arijit 
Bye World, arijit from --> basic-rest-65cb866cd7-g9lpv!!

Ideally hostname should be altered for some requests. Am I making any mistakes

@astefanutti
Copy link
Member

The kubectl port-forward svc command is just a convenient wrapper around pod port-forwarding and does not enable to balance traffic on the service endpoints. The Kubernetes API only enables port forwarding for pods. The kubectl port-forward svc command picks a pod from the Service endpoints once, and forwards traffic to that pod.

This is being discussed at the end of kubernetes/kubernetes#15180. To leverage the default round-robin load balancing, standard application traffic must be used, like with Ingress or Route.

@astefanutti astefanutti added the kind/question Further information is requested label Nov 10, 2020
@astefanutti
Copy link
Member

Let me close this as it's been answered.

@arijitmazumdar
Copy link
Author

arijitmazumdar commented Nov 17, 2020

Hi
Sorry for being late. I've tried with exposing the service as node-port, but I am still seeing the same behavior.

$kamel run BasicRest.java -t service.node-port=true --dev

$k get nodes -o wide
NAME       STATUS   ROLES    AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE           KERNEL-VERSION     CONTAINER-RUNTIME
minikube   Ready    master   16d   v1.19.2   192.168.49.2   <none>        Ubuntu 20.04 LTS   5.4.0-53-generic   docker://19.3.8

$ k get svc
NAME         TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
basic-rest   NodePort   10.99.128.250   <none>        80:30802/TCP   41s
 curl 192.168.49.2:30802/hello/arijit
Bye World, arijit from --> basic-rest-75b5458f9-p5bf7!!
$ curl 192.168.49.2:30802/hello/arijit
Bye World, arijit from --> basic-rest-75b5458f9-p5bf7!!
$ curl 192.168.49.2:30802/hello/arijit
Bye World, arijit from --> basic-rest-75b5458f9-p5bf7!!
$ curl 192.168.49.2:30802/hello/arijit
Bye World, arijit from --> basic-rest-75b5458f9-p5bf7!!

I am trying this in minikube. Is this happening because of minikube

@astefanutti
Copy link
Member

Could you please try with:

$ kubectl get --raw "/api/v1/namespaces/<NAMESPACE>/services/basic-rest:http/proxy/hello/arijit

This reaches the service through the API server proxy.

@astefanutti astefanutti reopened this Nov 17, 2020
@arijitmazumdar
Copy link
Author

I retested again. I am getting the right result. In the last step I probably missed to scale up the integration component to 2. Thanks a lot for patiently supporting me.

arijit@arijit-HP-ProBook-440-G5:~$ curl 192.168.49.2:30256/hello/arijit 
Bye World, arijit from --> basic-rest-75b5458f9-p5bf7!!
arijit@arijit-HP-ProBook-440-G5:~$ curl 192.168.49.2:30256/hello/arijit 
Bye World, arijit from --> basic-rest-75b5458f9-7pvg7!!
arijit@arijit-HP-ProBook-440-G5:~$ curl 192.168.49.2:30256/hello/arijit 
Bye World, arijit from --> basic-rest-75b5458f9-p5bf7!!
arijit@arijit-HP-ProBook-440-G5:~$ curl 192.168.49.2:30256/hello/arijit 
Bye World, arijit from --> basic-rest-75b5458f9-7pvg7!!
arijit@arijit-HP-ProBook-440-G5:~$ curl 192.168.49.2:30256/hello/arijit 
Bye World, arijit from --> basic-rest-75b5458f9-7pvg7!!
arijit@arijit-HP-ProBook-440-G5:~$ curl 192.168.49.2:30256/hello/arijit 
Bye World, arijit from --> basic-rest-75b5458f9-p5bf7!!

@astefanutti
Copy link
Member

Great! Thanks for the feedback.

@haifzhan
Copy link

haifzhan commented Jan 4, 2022

@arijitmazumdar Hi there, I am facing the same issue my replicas are not able to receive any traffic. Is trait -t service.node-port=true the only configuration required(I already have my service template and the port forwarding has been applied)? Thanks!

I have enabled the trait but my replica still not seeing anything. Would you mind explain what is scale up the integration component to 2 please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants