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

Kamelet add support for tolerations #2602

Closed
art-pepper opened this issue Aug 27, 2021 · 5 comments
Closed

Kamelet add support for tolerations #2602

art-pepper opened this issue Aug 27, 2021 · 5 comments

Comments

@art-pepper
Copy link

art-pepper commented Aug 27, 2021

Hi, I am using camel-k 1.5.0 and knative v0.24.0 and I created a kamelet that gets messages from rabbitmq and sends them to a knative service, I would like to configure everything on the kamelet level because it creates the integration which creates the deployment.
I am able to configure a nodeSelector but it is not possible to configure a toleration. Please add support in the kamelet for adding a toleration or let me know about how it is possible on the kamelet/kameletbinding level ( not on the integration/deployment level)
Thank you in advance, appreciate your support on this

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: rabbitmq-message-source-binding
  namespace: default
spec:
  sink:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: my-service
      namespace: default
  source:
    properties:
      address: rabbitmq://myrmqexample.com
      header: ce-type
      header-value: my.header
    ref:
      apiVersion: camel.apache.org/v1alpha1
      kind: Kamelet
      name: rabbitmq-message-source
  integration:
    template:
      spec:
        nodeSelector:
          myApps: "true"
        containers:
          - name: integration

---

apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  labels:
    camel.apache.org/kamelet.type: source
  name: rabbitmq-message-source
  namespace: default
spec:
  definition:
    description: Receive messages from a RabbitMQ Source and set header
    properties:
      address:
        description: The RabbitMQ address with needed parameters
        title: Address
        type: string
      header:
        description: The header for the rabbitmq message
        title: Header Name
        type: string
      header-value:
        description: The header value for the rabbitmq message
        title: Header Value
        type: string
    required:
      - address
      - header
      - header-value
    title: RabbitMQ Message Source
    type: object
  dependencies:
    - camel:rabbitmq
    - camel:kamelet
  flow:
    from:
      steps:
        - set-header:
            constant: '{{header-value}}'
            name: '{{header}}'
        - log:
            message: 'Forwarding to knative service: ${body}'
        - to: kamelet:sink
      uri: '{{address}}'
@astefanutti
Copy link
Member

astefanutti commented Aug 27, 2021

You should be able to configure the toleration trait, e.g.:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: rabbitmq-message-source-binding
  namespace: default
spec:
  sink:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: my-service
      namespace: default
  source:
    properties:
      address: rabbitmq://myrmqexample.com
      header: ce-type
      header-value: my.header
    ref:
      apiVersion: camel.apache.org/v1alpha1
      kind: Kamelet
      name: rabbitmq-message-source
  integration:
    traits:
      - toleration:
         configuration:
           taints:
             - node-role.kubernetes.io/master:NoSchedule
    template:
      spec:
        nodeSelector:
          myApps: "true"

@mmelko would you remember why we didn't add the tolerations field on the Integration PodSpec?

@mmelko
Copy link
Contributor

mmelko commented Aug 27, 2021

@astefanutti Hi, unfortunately I don't, probably we left it among with other things for the next iterations :)

@astefanutti
Copy link
Member

astefanutti commented Aug 27, 2021

@mmelko yes I guess we did not add it as it requires a bit more work and extra care to handle "merging" with the toleration trait.

@art-pepper
Copy link
Author

art-pepper commented Aug 27, 2021

You should be able to configure the toleration trait, e.g.:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: rabbitmq-message-source-binding
  namespace: default
spec:
  sink:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: my-service
      namespace: default
  source:
    properties:
      address: rabbitmq://myrmqexample.com
      header: ce-type
      header-value: my.header
    ref:
      apiVersion: camel.apache.org/v1alpha1
      kind: Kamelet
      name: rabbitmq-message-source
  integration:
    traits:
      - toleration:
         configuration:
           taints:
             - node-role.kubernetes.io/master:NoSchedule
    template:
      spec:
        nodeSelector:
          myApps: "true"

@mmelko would you remember why we didn't add the tolerations field on the Integration PodSpec?

I really appreciate your help and the quick response time, with a small change from your example I was able to make it work :)

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: rabbitmq-message-source-binding
  namespace: default
spec:
  sink:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: my-service
      namespace: default
  source:
    properties:
      address: rabbitmq://myrmqexample.com
      header: ce-type
      header-value: my.header
    ref:
      apiVersion: camel.apache.org/v1alpha1
      kind: Kamelet
      name: rabbitmq-message-source
  integration:
    traits:
      toleration:
        configuration:
            enabled: true
            taints:
              - myApps=true:NoSchedule
    template:
      spec:
        nodeSelector:
          myApps: "true"

@squakez
Copy link
Contributor

squakez commented Sep 7, 2021

Some syntactic sugar for this is provided by annotations: https://camel.apache.org/camel-k/latest/kamelets/kamelets-user.html#_trait_via_annotations. Last resort is to specify the trait in the Integration spec as you've finally done.

Closing the issue, feel free to open a new one if anything else unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants