[
https://issues.apache.org/jira/browse/CAMEL-22407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claudio Miranda resolved CAMEL-22407.
-------------------------------------
Resolution: Fixed
> camel-jbang-plugin-kubernetes: --config and --resource fails when setting a
> key or destination file path
> --------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-22407
> URL: https://issues.apache.org/jira/browse/CAMEL-22407
> Project: Camel
> Issue Type: Bug
> Components: camel-jbang
> Reporter: Claudio Miranda
> Assignee: Claudio Miranda
> Priority: Major
>
> camel-jbang-plugin-kubernetes has three parameters to set properties or
> resource files from configmaps or secrets.
> {code}
> --property=<properties> Add a runtime property or properties file from a
> path, a config map or
> a secret (syntax:
>
> [my-key=my-value|file:/path/to/my-conf.
>
> properties|[configmap|secret]:name]).
> --config=<configs> Add a runtime configuration from a ConfigMap or a
> Secret (syntax:
> [configmap|secret]:name[/key],
> where name represents
> the configmap/secret name
> and key optionally
> represents the
> configmap/secret key
> to be filtered).
> --resource=<resources> Add a runtime resource from a Configmap or a
> Secret (syntax:
> [configmap|secret]:name[/key]
> [@path], where name
> represents the
> configmap/secret
> name, key optionally represents
> the configmap/secret
> key to be filtered and path
> represents the
> destination path).
> {code}
> Issues:
> 1) the "--property" doesn't handle the "configmap","secret" or "file"
> options, if they are set, it's ignored or has error parsing:
> {code}
> camel kubernetes run HttpLog.java --property configmap:my-config --verbose
> {code}
> There is this warning and the parameter is ignored
> {code}
> WARN: property 'configmap:my-config'' has a bad format (should be
> 'key=value'), skipping.
> {code}
> If "file:/path.txt" is used, it fails
> {code}
> camel kubernetes run HttpLog.java --property
> file:/etc/my-camel-app/my-file.properties --verbose
> Automatic Kubernetes cluster detection... MINIKUBE
> Exporting application ...
> java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
> {code}
> Looking at the code history, it seems there was no code to handle the
> configmap/secret/file.
> proposal: change the description and remove the configmap/secret/file use
> cases, they will be handled by the "--config" parameter.
> 2) the "--config" or "--resource" with "configmap" or "secret" doesn't work.
> Given the Configmap
> {code}
> kind: ConfigMap
> apiVersion: v1
> metadata:
> name: config-printer
> data:
> application.properties: |
> my-key=Jiu jitsu and rock
> {code}
> The command:
> {code}
> camel kubernetes run HttpLog.java --config configmap:config-printer --verbose
> {code}
> The pod fails with:
> {code}
> IllegalArgumentException: Property with key [my-key] not found in properties
> from text: from configmap: my-key={{my-key}}
> {code}
> I had to set the "camel.component.properties.location" property for the camel
> runtime to load the properties file.
> {code}
> camel kubernetes run HttpLog.java --config configmap:config-printer --verbose
> --property
> camel.component.properties.location=file:/etc/camel/conf.d/_configmaps/config-printer/application.properties
> {code}
> Or in the case with "--resource" the parameter is:
> "camel.component.properties.location=file:/etc/camel/resources.d/_configmaps/config-printer/application.properties"
> proposal: set the "camel.component.properties.location" parameter accordinly
> to the configmap/secret/path.
> 3) the "--config" with "configmap" doesn't work when there is a "/key" option.
> Given the Configmap
> {code}
> kind: ConfigMap
> apiVersion: v1
> metadata:
> name: my-config
> data:
> remote-file: |
> brokers=172.30.170.240:9092
> topic=log1-topic
> s3.region=EU_WEST_1
> test-route: |
> foo.application.custom = my-custom-value
> foo.myroute.endpoint = http://my-site.com
> {code}
> The command to set the "key" option to "remote-file"
> {code}
> camel kubernetes run file.java --config configmap:my-config/remote-file
> --verbose
> {code}
> The generated deployment manifest
> {code}
> .camel-jbang-run/http-log/target/kubernetes/kubernetes/http-log-deployment.yml
> volumeMounts:
> - mountPath: /etc/camel/conf.d/_configmaps/my-config/remote-file
> name: remote-file
> readOnly: true
> subPath: /remote-file
> volumes:
> - configMap:
> items:
> - key: /remote-file
> path: /remote-file
> name: my-config/remote-file
> name: remote-file
> {code}
> The pod fails with:
> {code}
> pod fails: Deployment.apps "http-log" is invalid:
> [spec.template.spec.volumes[0].configMap.items[0].path: Invalid value:
> "/remote-file": must be a relative path,
> spec.template.spec.containers[0].volumeMounts[0].name: Not found:
> "remote-file"
> {code}
> 4) the "--resource" with "configmap" doesn't work when there is a "/key" or
> "@path" option.
> {code}
> camel kubernetes run HttpLog.java --resource
> configmap:my-config/test-route@/my-file.properties --verbose
> {code}
> The generated deployment manifest
> {code}
> volumeMounts:
> - mountPath: '@/my-file.properties'
> name: my-file
> readOnly: true
> subPath: my-file
> volumes:
> - configMap:
> items:
> - key: /test-route
> path: my-file
> name: my-config/test-route@/my-file.properties
> name: my-file
> {code}
> The pod fails:
> {code}
> pod fails: MountVolume.SetUp failed for volume "my-file" : failed to sync
> configmap cache: timed out waiting for the condition
> {code}
> The last two issues seems related to wrong regular expression parsing.
> In addition to fixing the code, tests should be added and add examples to
> "camel jbang kubernetes" documentation page.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)