https://rancher.com/ logo
Title
m

magnificent-oxygen-87068

05/22/2023, 10:10 AM
Hello folks, I'm doing some experiments to develop a rancher extensions and I have some question about it. First of all, I've not found this in the docs (but maybe I've not read it carefully 😇), if there a standard way to persistence store some information, e.g. configuration, of the extension? My use case if the following: The extension I'm working on needs to be configured with an external API endpoint that are not known at build time • I install the extension • At the first run, the ext displays a simple form to input the API URL • Then it starts the main view of the extension calling these API Thanks in advance
🔥 1
s

stocky-account-63046

05/22/2023, 12:35 PM
Extensions are primarily the view layer of the application and interact with existing infrastructure. For your case think maybe just a kube ConfigMap would be best. I'm assuming this is setup info available to all users of your extension?
m

magnificent-oxygen-87068

05/22/2023, 12:38 PM
Yep, thats true! Thanks, but how can the extensions interact with the API of kubernetes in order to create/read configmaps? Can I use the API layer of Rancher? Is there any docs/example?
s

stocky-account-63046

05/22/2023, 12:40 PM
Is your extension located within the
Cluster Explorer
section, a
Global App
or something different?
m

magnificent-oxygen-87068

05/22/2023, 12:42 PM
Global App
s

stocky-account-63046

05/22/2023, 12:45 PM
Ok, you'll need to save / access your configmap in the upstream /
local
cluster by dispatching
create
/
find
actions in the
management
store. There's some more info here, specifically half way down https://rancher.github.io/dashboard/code-base-works/api-resources-and-schemas . For your use case you'd roughly need to 1. dispatch
management/create
with the configmap type. 2. populate the object it returns with your required values 3. call
await <object>.save()
to persist 4. on subsequent loads you can access it via dispatching a
management/find
action this assumes the user who's signed in to the dashboard has the required rights to save config maps
other users of the dashboard who need to access your extension would need read rights on that confimap map too
m

magnificent-oxygen-87068

05/22/2023, 12:48 PM
thanks you 😄 I'll try!!
s

stocky-account-63046

05/22/2023, 12:49 PM
No problem, let us know how you get on