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

Issues with pre-published Kubernetes secret and Camel-K integration #900

Closed
bfitzpat opened this issue Aug 6, 2019 · 1 comment
Closed

Comments

@bfitzpat
Copy link
Contributor

bfitzpat commented Aug 6, 2019

So I have been able to publish a config-map using kubectl with kubectl create configmap <config-id> --from-file=<config.file> and then run an integration with kamel run --configmap=<config-id> <myintegration.file> and have that work fine.

But when I attempt the same approach with secrets, I'm hitting weird issues.

First, I'm assuming the secret itself is a base64-encoded list of name/value pairs.

Second, I was able to create a secret config-map yaml file by hand and it worked just fine.

If I create the secret yaml file by hand so it looks like what you have in https://camel.apache.org/staging/camel-k/latest/configuration/configmap-secret.html, it works. Run kubectl apply -f my-secret.yaml and then use kamel run --secret=<secret-id-from-my-secret-yaml> <myintegration.file>. That works great.

Unfortunately I run into issues if I go a slightly different route...

If I create my secret with kubectl create secret generic <secret-id> --from-file=<base64-encoded-secret.file>, I see the secret in my Kubernetes system. And then I use kamel run --secret=<secret-id> <myintegration.file>, I'm getting very weird results.

Two new config maps are created -- -properties and -source-000 --
and I'm seeing errors in the camel log...

Is there a structure to the secret file that I feed to kubectl create secret generic that I need to follow?

Exception in thread "main" org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException: PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [telegram.APIKey] not found in properties from text: telegram:bots/{{telegram.APIKey}}?chatId={{telegram.chatID}}
	at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:52)
	at org.apache.camel.model.RouteDefinitionHelper.initRouteInput(RouteDefinitionHelper.java:445)
	at org.apache.camel.model.RouteDefinitionHelper.prepareRouteImp(RouteDefinitionHelper.java:361)
	at org.apache.camel.model.RouteDefinitionHelper.prepareRoute(RouteDefinitionHelper.java:333)
	at org.apache.camel.model.RoutesDefinition.route(RoutesDefinition.java:193)
	at org.apache.camel.model.RoutesDefinition.from(RoutesDefinition.java:164)
	at org.apache.camel.builder.RouteBuilder.from(RouteBuilder.java:212)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
	at org.apache.camel.k.loader.groovy.dsl.IntegrationConfiguration.from(IntegrationConfiguration.groovy:72)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1217)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:821)
	at org.apache.camel.k.loader.groovy.dsl.IntegrationConfiguration.invokeMethod(IntegrationConfiguration.groovy)
	at groovy.util.DelegatingScript.invokeMethod(DelegatingScript.java:110)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:70)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:168)
	at Script1.run(Script1.groovy:7)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
	at org.apache.camel.k.loader.groovy.GroovyRoutesLoader$1$_configure_closure1.doCall(GroovyRoutesLoader.groovy:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
	at groovy.lang.Closure.call(Closure.java:405)
	at groovy.lang.Closure.call(Closure.java:421)
	at org.codehaus.groovy.runtime.IOGroovyMethods.withCloseable(IOGroovyMethods.java:1608)
	at org.codehaus.groovy.runtime.dgm$913.doMethodInvoke(Unknown Source)
	at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
	at org.apache.camel.k.loader.groovy.GroovyRoutesLoader$1.configure(GroovyRoutesLoader.groovy:52)
	at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:442)
	at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:409)
	at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:390)
	at org.apache.camel.impl.engine.AbstractCamelContext.lambda$addRoutes$0(AbstractCamelContext.java:1077)
	at org.apache.camel.impl.engine.AbstractCamelContext.doWithDefinedClassLoader(AbstractCamelContext.java:2404)
	at org.apache.camel.impl.engine.AbstractCamelContext.addRoutes(AbstractCamelContext.java:1077)
	at org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:779)
	at org.apache.camel.main.MainSupport.initCamelContext(MainSupport.java:646)
	at org.apache.camel.main.Main.doInit(Main.java:108)
	at org.apache.camel.support.service.ServiceSupport.init(ServiceSupport.java:61)
	at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:88)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:196)
	at org.apache.camel.k.main.ApplicationRuntime.run(ApplicationRuntime.java:70)
	at org.apache.camel.k.main.Application.main(Application.java:44)
Caused by: java.lang.IllegalArgumentException: PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [telegram.APIKey] not found in properties from text: telegram:bots/{{telegram.APIKey}}?chatId={{telegram.chatID}}
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:247)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:144)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:103)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:87)
	at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:57)
	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:219)
	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:171)
	at org.apache.camel.impl.engine.AbstractCamelContext.resolvePropertyPlaceholders(AbstractCamelContext.java:1682)
	at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:734)
	at org.apache.camel.model.RouteDefinitionHelper.initRouteInput(RouteDefinitionHelper.java:443)
	... 53 more```

@bfitzpat
Copy link
Contributor Author

This was an issue on our side, not on the Camel K side. We now support starting an integration in the Camel K VS Code extension with the --configmap or --secret flag referencing a designated configMap or secret available in the Kubernetes system. See https://github.com/camel-tooling/vscode-camelk#start-apache-camel-k-integration-menu-results and https://github.com/camel-tooling/vscode-camelk#running-with-kubernetes-configmaps-or-secrets

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

1 participant