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

resources: add options to configure mount path and key #554

Merged
merged 1 commit into from
Mar 14, 2019

Conversation

lburgazzoli
Copy link
Contributor

This allows to configure where a resource should be mounted and in case the resource references a config map, the key of the entry (default value content ).

apiVersion: camel.apache.org/v1alpha1
kind: Integration
metadata:
  name: hello
spec:
  resources:
  - contentRef: nexus3
    contentKey: nexus3-persistent-template.yaml
    mountPath: /etc/camel/resources/n3
    name: nexus.yaml
    type: data
  sources:
  - content: |
      <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns="http://camel.apache.org/schema/spring"
              xsi:schemaLocation="
                  http://camel.apache.org/schema/spring
                  http://camel.apache.org/schema/spring/camel-spring.xsd">

          <route id="hello">
              <from uri="timer:hello?period=3s"/>
              <setBody>
                  <constant>Hello World!!!</constant>
              </setBody>
              <to uri="log:info"/>
          </route>

      </routes>
    name: hello.xml

NOTE in case the trait deployer.container-image is set to true the mountPath is relative to the /deployment folder

Copy link
Member

@astefanutti astefanutti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very useful. We'll be able to use it to customise the Prometheus JMX exporter configuration for example.

I wonder whether we could be closer to existing K8s semantic, e.g. instead of:

resources:
  - contentRef: nexus3
    contentKey: nexus3-persistent-template.yaml
    mountPath: /etc/camel/resources/n3
    name: nexus.yaml
    type: data

Writing:

resources:
  - configMap:
      name: nexus3
      subPath: nexus3-persistent-template.yaml
      mountPath: /etc/camel/resources/n3/nexus.yaml
    type: data

@lburgazzoli
Copy link
Contributor Author

lburgazzoli commented Mar 13, 2019 via email

@valdar
Copy link
Member

valdar commented Mar 13, 2019

could we have a resource that is not translated in a configmap? If yes probably I would not bother with changing the syntax...

@astefanutti
Copy link
Member

if subPath is empty, it defaults to \, that the corresponding volume root directory gets mounted, which for a config map is all the keys (c.f. kubernetes/kubernetes#22575). In that case mountPath must be a directory.

An alternative would be to use the path field to specify the file path for a specific ConfigMap item, e.g.:

resources:
  - configMap:
      name: nexus3
      items:
        - key: nexus3-persistent-template.yaml
          path: keys
      mountPath: /etc/camel/resources/n3/
    type: data

See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume.

But the added value of subPath is that you can project a config map key into an existing directory without overriding the whole directory.

We could also reuse the configMapRef field name as in k8s.io/api/core/v1, e.g.:

resources:
  - configMapRef:
      name: nexus3
    subPath: nexus3-persistent-template.yaml
    mountPath: /etc/camel/resources/n3/nexus.yaml
    type: data

@lburgazzoli
Copy link
Contributor Author

lburgazzoli commented Mar 13, 2019 via email

@astefanutti
Copy link
Member

astefanutti commented Mar 13, 2019

This is user provided so he/she/it knows what's the target environment. In Knative (and others), normal mount can be used:

resources:
  - configMap:
      name: nexus3
      items:
        - key: nexus3-persistent-template.yaml
          path: keys
      mountPath: /etc/camel/resources/n3/
    type: data

@astefanutti
Copy link
Member

We can go for the current API and create a new issue to keep track of the possible improvements.

@lburgazzoli
Copy link
Contributor Author

@astefanutti

So I did went through all the hack we have at the moment to make things working on knative 0.3, 0.4 and standard deployment and it is not simple to implement what you suggested.

However, if people agree on #552, we can implement your suggestion (which is great) when we are finally free from the env hack we have in place.

@astefanutti
Copy link
Member

@lburgazzoli sounds good!

@astefanutti astefanutti merged commit 3466736 into apache:master Mar 14, 2019
@lburgazzoli lburgazzoli deleted the resources-path branch March 14, 2019 08:12
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

Successfully merging this pull request may close these issues.

3 participants