q-shift / backstage-playground

2 stars 6 forks source link

Provide the openai credentials to the chatbot application as a secret #107

Open cmoulliard opened 1 month ago

cmoulliard commented 1 month ago

TODO

Provide the openai credentials to the chatbot application as a secret

cmoulliard commented 1 month ago

a secret

Can the secret be provided as backstage parameter from app-config.yaml ? @iocanel

iocanel commented 1 month ago

a secret Can the secret be provided as backstage parameter from app-config.yaml ? @iocanel

Given, that we don't want the secret to end up in the application source repository I don't think that backstage itself should be involved. For now, I would be happy if the secret was created manually once and then just have the template use it.

cmoulliard commented 1 month ago

Given, that we don't want the secret to end up in the application source repository I don't think that backstage itself should be involved

If you use locally app-config.local.yaml, then the password/token/secret is not at all stored under a github repository

cmoulliard commented 1 month ago

For now, I would be happy if the secret was created manually once and then just have the template use it.

Will the user provide the openai token using a template parameter ?

iocanel commented 1 month ago

Having the openai token in backstage has no practical use to us. The token needs to somehow end up in a secret. I don't see how backstage could help us here, unless it does provide actions to create a secret.

cmoulliard commented 1 month ago

Can you then confirm or amend the following scenario to be implemented ?

Such a scenario should then fix the following error which happens when we launch the chatBot

Caused by: io.smallrye.config.ConfigValidationException: Configuration validation failed:
    SRCFG00014: The config property quarkus.langchain4j.openai.api-key is required but it could not be found in any config source
    at io.quarkiverse.langchain4j.openai.runtime.OpenAiRecorder.chatModel(OpenAiRecorder.java:47)
    at io.quarkus.deployment.steps.OpenAiProcessor$generateBeans801072037.deploy_0(Unknown Source)
    at io.quarkus.deployment.steps.OpenAiProcessor$generateBeans801072037.deploy(Unknown Source)

@iocanel

iocanel commented 1 month ago

I don't see how a kubernetes secret can be create it with fetch:template without having the secret end up in the git repository. All an in all, I am not aware of any way of creating arbitrary resources on kubernetes without adding them to the repo.

So, I think that the secret needs to be configured up front and maybe let the user specify the name of the secret in the template.

cmoulliard commented 1 month ago

I don't see how a kubernetes secret can be create it with fetch:template without having the secret end up in the git repository.

Correct. There are until now only a few kubectl actions able to create resources from a backstage template:

Ideally we should use an external secrets store as vault. Maybe this backstage backend plugin could help us but I need to have a look to see how a secret defined in a component can be next consumed by an application: https://www.npmjs.com/package/@backstage-community/plugin-vault-backend.

A better option is certainly to use Primaza as it allows to use vault as secret storage engine and mount to the target Deployment resource the secret created after we did a query in vault to find the key, credentials, etc.

Finally, this is what we should do

cmoulliard commented 2 weeks ago

An intermediate approach could be to use the devtools plugin (or to create a module for such a purpose) able to expose the the config parameters as endpoint from the backstage config if we agree to store such a AI token there of course and to use a scaffold customField where value is filled from the API call to the config endpoint (to be developed).

Some useful links: