onyxia icon indicating copy to clipboard operation
onyxia copied to clipboard

Connect to Kubernetes #272

Open ddecrulle opened this issue 2 years ago • 9 comments

ddecrulle avatar Sep 07 '22 17:09 ddecrulle

Capture d’écran 2022-09-07 à 19 48 01 Capture d’écran 2022-09-07 à 19 48 07

ddecrulle avatar Sep 07 '22 17:09 ddecrulle

Need to create API Client etc... Can you show me API details ?

I also need some precision for the text

ddecrulle avatar Sep 07 '22 17:09 ddecrulle

Hey Dylan,
Here is the legacy code for this feature: https://github.com/InseeFrLab/onyxia-web/blob/main/src/js/components/cluster/exportCredentialsKub.ts
Maybe you can pull the string from here?
Let me know if you need more info, we'll book a call.

garronej avatar Sep 13 '22 23:09 garronej

@ddecrulle give me rights on his fork so i fix :

  • value
  • configuration of tab like proposition https://github.com/InseeFrLab/onyxia-web/issues/272#issuecomment-1240417262
  • export

@garronej when you have time you can remove the draft status of this PR (I don't have the Edit button) and review 😃

smith-julien avatar Sep 22 '22 19:09 smith-julien

launcher.ts

            assert(
                kubernetes.keycloakParams !== undefined,
                "There is no specific kubernetes config in the region",
            );

            assert(oidcClient.isUserLoggedIn);

            assert(createStoreParams.userAuthenticationParams.method === "keycloak");

            const kubernetesOidcClient = await creatOrFallbackOidcClient({
                "fallback": {
                    "keycloakParams": createStoreParams.userAuthenticationParams.keycloakParams,
                    oidcClient
                },
                "keycloakParams": kubernetes.keycloakParams,
                "evtUserActivity": createStoreParams.evtUserActivity,
            });

            const kubernetesClusterDomain = kubernetes.url;

            const user= dispatch(userAuthenticationThunk.getUser());

            return {
                "K8S_CLUSTER": kubernetesClusterDomain,
                "K8S_USER": user,
                "K8S_SERVER_URL": kubernetes.url,
                "K8S_NAMESPACE": project.id,
                "K8S_TOKEN": kubernetesOidcClient.accessToken,
                "expirationTime": expirationTime,
            };
image

garronej avatar Sep 30 '22 15:09 garronej

Hi @garronej I make all changes requested. You can review the PR 🚀

smith-julien avatar Oct 03 '22 08:10 smith-julien

Hey @garronej , Thank you for reviewing. I make all changes, it's ready 🎯

smith-julien avatar Oct 14 '22 13:10 smith-julien

Hi @garronej , with @alainds & @LoicInsee we are stuck on src/core/usecases/initScriptsGenerator.ts file. We can't export the thunk privatethunk like in userAuthentication.ts. All the code go to error when we add "export" (Line 35). Even if we remove the import of userAuthentication in initScriptsGenerator.ts.

We commit a solution with an intermediate export with thunk.initialize what is not satisfying.

I'll continue discussion on slack.

smith-julien avatar Oct 18 '22 12:10 smith-julien

Hi @smith-julien, @alainds & @LoicInsee,

Well, first of all, I have to apologize, my expectation for this PR wasn’t realistic considering the fact that the similar feature in the codebase, the ability to download init script, was implemented in a very hacky way.
If you took this code as reference, no wonder my review came out as misleading.
Besides, I told you not to put the token in the states, but in reality, it was the right call (not in the launcher states but in the states still). My apologies for that too.

I have reimplemented the storage account tab so you can use it as a foothold for implementing the Kubernetes account tab (later on).

https://user-images.githubusercontent.com/6702424/196569912-8ca5f4f8-b6f4-4513-a6ab-be09480a447c.mov

  • You can find the relevant commit here.
  • In particular, the new slice I created

https://github.com/InseeFrLab/onyxia-web/blob/main/src/core/usecases/s3Credentials.ts

  • The React component that is leveraging it:

https://github.com/InseeFrLab/onyxia-web/blob/main/src/ui/components/pages/Account/tabs/AccountStorageTab/AccountStorageTab.tsx

  • How the tab is disabled if we don't have a S3 server:

https://github.com/InseeFrLab/onyxia-web/blob/ad9cff62b19d5e8a0e3a9441ee07e8e6cf295d8e/src/ui/components/pages/Account/Account.tsx#L41
(we use a synchronous thunk instead of a state because it's not a variable, we either have an s3 server configured on this instance or we haven't, it's not susceptible to change)

As discussed on Slack, we are going to meet a couple of days in Paris for a proper onboarding of the project.
This is great news.
The more you'll have prepared beforehand the more productive these two days are going to be.
I invite you to:

  1. Get familiar with the technical stack: https://docs.onyxia.sh/contributing/onyxia/dependencies
  2. Get familiar with the overall architecture of the project: https://docs.onyxia.sh/contributing/onyxia/architecture

Please watch all the video on both pages and read everything. It took a lot of effort to write and maintain this technical documentation and I did it for you, to help you get up to speed quickly.
I want you to be aware that I don't work at INSEE anymore and I'm currently working remotely from Montpellier.
I'll be coming to Paris especially for you and I'll have to negotiate with my boss that he let me take those two days.
Don't get me wrong, I'm really looking forward to meeting you and I'm sure we'll have a great time coding together but if I see that you've come unprepared I won't feel respected.

I invite you to leave this PR on hold for now, we will complete it together in pair programing when we see each other live.

Best regards,

garronej avatar Oct 19 '22 02:10 garronej

Thank you for you effor and for comming to the meetup!

garronej avatar Nov 23 '22 22:11 garronej