2

I would like to remote debug my custom connector which is part of my Strimzi Kafka operator deployment on top of Kubernetes.

Locally (e.g. with docker image), this could be done by adding the JAVA_TOOL_OPTIONS as an environment parameter with this value: -agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n and expose in the docker run command the 5005 port.

However, in k8s, I should also add port 5005 to the deployment so I can use nodeport (or something else) in order to expose the deployment's debugging port (5005) outside of the cluster (so my IDE could attach to it).

But, I do not have the ability to change the exposed ports of the created Kafka connect deployment (after all, you can only apply the KafkaConnect custom resource and the deployment is created as part of it).

Is there any workaround for remote debugging this connector? Or is there some config value that Strimzi has?

omer bar lev
  • 341
  • 1
  • 4
  • 11

1 Answers1

1

Once you stop strimzi reconciliation it can be done as you usually do remote debug.

When done, delete strimzi.io/pause-reconciliation: "true" from Kafka Connect resource and this will restore cluster to the original state

  1. Adjust Kafka Connect resource 1.1 Add a new environment variable to Kafka Connect resource
    - name: JAVA_TOOL_OPTIONS
    value: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
    1.2 Apply the change and wait for the end of deployment
    1.3 Add a new annotation
    strimzi.io/pause-reconciliation: "true"
    1.4 Apply the change
  2. Update Kafka Connect deployment and add new port (match the one in JAVA_TOOL_OPTIONS)
    • name: debug
      containerPort: 5005
      protocol: TCP
  3. Create a NodePort service that maps port 5005 of Kafka Connect to the some nodePort (say 35005)
  4. Add Remote Debug configuration 3.1 Host should be one of the k8s nodes
    3.2 port same as you defined in the NodePort (35005 in our example)
    3.3 Apply

Now you can just debug using the created configuration.

omer bar lev
  • 341
  • 1
  • 4
  • 11