Topics

Adding annotations and limits of kafka connect created pods

alonisser@...
 

Trying to add pod annotations (for our log connector) and resource request/limits to the KafkaConnect created resources
What should I add in the resource so it would create the pods/deployment with them(I suspect I already sent this message but can't find it now)

Jakub Scholz
 

Hi,

For specifying the resources, you can do something like this:
apiVersion: kafka.strimzi.io/v1alpha1
kind: KafkaConnect
metadata:
  name: my-connect
  # ...
spec:
  # ...
  resources:
    requests:
      memory: 1Gi
      cpu: 500m
    limits:
      memory: 2Gi
      cpu: 1000m
  # ...

For the annotations, it depends what exactly do you want to annotate. But basically you can use this feature: https://strimzi.io/docs/latest/full.html#assembly-customizing-deployments-str
Your YAML would look something like this:
kind: KafkaConnect
metadata:
  name: my-connect
  # ...
spec:
  # ...
  template:
    deployment:
      metadata:
        annotations:
          myanno: myvalue
    pod:
      metadata:
        annotations:
          myanno: myvalue
  # ...

Thanks & Regards
Jakub




On Sun, Feb 23, 2020 at 10:42 AM <alonisser@...> wrote:
Trying to add pod annotations (for our log connector) and resource request/limits to the KafkaConnect created resources
What should I add in the resource so it would create the pods/deployment with them(I suspect I already sent this message but can't find it now)

alonisser@...
 

Thanks I would try that! I was missing the pod/deployment sub level

alonisser@...
 

Thanks, following  your advice I've added:
template:
pod:
metadata:
annotations:
ad.datadoghq.com/kafka-connect-container-name.logs: [{"type":"file", "source":"java","sourcecategory":"sourcecode", "service":"kafka-connect"}]

And it didn't work and I saw errors in the pods of the operator
following the error log 
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: io.fabric8.kubernetes.api.model.WatchEvent["object"]->io.strimzi.api.kafka.model.KafkaConnect["spec"]->io.strimzi.api.kafka.model.KafkaConnectSpec["template"]->io.strimzi.api.kafka.model.template.KafkaConnectTemplate["pod"]->io.strimzi.api.kafka.model.template.PodTemplate["metadata"]->io.strimzi.api.kafka.model.template.MetadataTemplate["annotations"]->java.util.LinkedHashMap["ad.datadoghq.com/kafka-connect-container-name.logs"])

I've guessed it's about the array, so wrapping the array as a quoted string fixed the issue 
Thanks for the help again, and I'll hope this would be useful for someone else

Jakub Scholz
 

Yeah, the annotations are strings. So you need to wrap it into quotes to make it a string. Without them it will be interpreted as array.


On Fri, Feb 28, 2020 at 2:04 PM <alonisser@...> wrote:
Thanks, following  your advice I've added:
template:
pod:
metadata:
annotations:
ad.datadoghq.com/kafka-connect-container-name.logs: [{"type":"file", "source":"java","sourcecategory":"sourcecode", "service":"kafka-connect"}]

And it didn't work and I saw errors in the pods of the operator
following the error log 
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: io.fabric8.kubernetes.api.model.WatchEvent["object"]->io.strimzi.api.kafka.model.KafkaConnect["spec"]->io.strimzi.api.kafka.model.KafkaConnectSpec["template"]->io.strimzi.api.kafka.model.template.KafkaConnectTemplate["pod"]->io.strimzi.api.kafka.model.template.PodTemplate["metadata"]->io.strimzi.api.kafka.model.template.MetadataTemplate["annotations"]->java.util.LinkedHashMap["ad.datadoghq.com/kafka-connect-container-name.logs"])

I've guessed it's about the array, so wrapping the array as a quoted string fixed the issue 
Thanks for the help again, and I'll hope this would be useful for someone else