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

Kamelets load properties from ConfigMap #3811

Closed
JayDev9 opened this issue Nov 14, 2022 · 6 comments
Closed

Kamelets load properties from ConfigMap #3811

JayDev9 opened this issue Nov 14, 2022 · 6 comments

Comments

@JayDev9
Copy link

JayDev9 commented Nov 14, 2022

Kamelets can only access ConfigMaps & Secrets properties, if the they get loaded/mounted via the Integration that uses/calls the kamelet. There is no way for a kamelet to load/mount ConfigMaps and Secrets independent from the called integration.

@squakez
Copy link
Contributor

squakez commented Nov 15, 2022

I am not sure to understand the problem. Would you like to "attach" a configmap to a Kamelet directly? The Kamelet are thought to be used by Camel framework even outside the Kubernetes world, if that is what is asked here.

@JayDev9
Copy link
Author

JayDev9 commented Nov 16, 2022

Consider the following simple custom kamelet definition (my own written kamelet):

apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: test-sink
  labels:
    camel.apache.org/kamelet.type: "sink"
spec:
  definition:
    title: "Title..."
    description: "desc..."
    required:
      - param
    properties:
      param:
        type: string

  dependencies:
    - "camel:kamelet"
    - "camel:core"
  template:

    beans:
      - name: myBean
        type: "#class:com.myClass"
        property:
          - key: key
            value: "{{key.value}}"

    from:
      uri: "kamelet:source"
      steps:
        - log:
           message: "--- kamelet Test"

the {{key.value}} in the beans definition section is being defined as a property key in a configMap that is running in the same namespace on the cluster (GKE). This throws an exception when deploying the kamelet, because {{key.value}} is not defined/visible for the kamelet. My question (I think, it's rather an issue) is there way to let a kamelet to load properties defined in a specific configMap? Or can a specific configMap get loaded/mounted in the kamelet definition? Thank you

@squakez
Copy link
Contributor

squakez commented Nov 17, 2022

I think you should make your Kamelet definition agnostic of the place where it will run and the way those parameters are injected. Ideally that key.value should be a parameter of the Kamelet instead and when you use the Kamelet in a KameletBinding or somewhere else you will need to find a way to bind that value to the configmap or any other storage type holding the value.

@squakez squakez removed the status/waiting-for-feedback Needs some feedback label Nov 17, 2022
@JayDev9
Copy link
Author

JayDev9 commented Nov 17, 2022

Thank you @squakez for your reply. Indeed. It works fine if I bind the value in a KameletBinding or in an Integration and inject it to the Kamelet. I was looking for a way to bind system or global variables that can be directly injected to the Kamelet during kamelet deployment independently, because such global variables should not be injected by dedicated Integrations that use the Kamelet.

@lburgazzoli
Copy link
Contributor

Thank you @squakez for your reply. Indeed. It works fine if I bind the value in a KameletBinding or in an Integration and inject it to the Kamelet. I was looking for a way to bind system or global variables that can be directly injected to the Kamelet during kamelet deployment independently, because such global variables should not be injected by dedicated Integrations that use the Kamelet.

I don't think the scenario you are outlining is something that is really feasible as a kamelet is a template so every property needed by a kamelet must be provided in the form on a parameter, otherwise properties gets shared across all kamelets instance.

In your case you can define the key.value as a parameter and then the caller is responsible to set it when invoking a kamelet.

@JayDev9
Copy link
Author

JayDev9 commented Nov 17, 2022

Thank you @lburgazzoli for your comment.

@squakez squakez closed this as completed Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants