joan38 / kubernetes-client

A Kubernetes client for Scala
Apache License 2.0
121 stars 40 forks source link

Question: Scala Native build #192

Open novakov-alexey opened 1 year ago

novakov-alexey commented 1 year ago

@joan38 , @armanbilge Is it possible to use kubernetes-client with Scala Native? If not - what does prevent us from making this happen? Some particular Java package is not yet available in Scala Native target?

armanbilge commented 1 year ago

Thanks for the ping. This will be blocked by the same reason as:

If we can make it work on Scala.js, then Scala Native can follow closely. Off the top of my head the primary issues are:

  1. circe-yaml uses Snake Yaml, which is a Java dep.
  2. We need a WebSocket client, which http4s Ember does not yet support.
  3. We need to deal with some crypto/security code in SslContexts.

I am still motivated on this, and have been slowly working on it.

  1. circe-scala-yaml can be a replacement for circe-yaml.

  2. I have proposed making an Ember Web Socket client as a Google Summer of Code project for the Scala Center. So hopefully a student will be paid to work on that this summer :)

    We also recently got a Web Socket client in http4s-curl. Unfortunately, Web Socket support in cURL itself is currently experimental, so I don't think that's a great option yet.

    Alternatively, maybe this project can be refactored so that the web socket is optional.

  3. I haven't looked too closely at SslContexts, probably we will just need platform-specific implementations of that.

SInce I last checked the codebase there could be new issues that I missed.

novakov-alexey commented 1 year ago

Great stuff. Thank you for the detailed update and your titanic efforts to get all the things around Scala Native and JS going forward!

As for optional web-sockets support. Kubernetes-client is using web-sockets in PodsApi for running a pod exec command and upload/download files. This functionality can be quite important for Kubernetes Operators, which could be potentially written with help of THIS project and Scala Native.

Looking forwards to updates on this subject.

Also, I will be able to contribute smaller parts related to above list, if you have something to share as small task.

armanbilge commented 1 year ago

This functionality can be quite important for Kubernetes Operators, which could be potentially written with help of THIS project and Scala Native.

Awesome! Yes, this is what I thought—so that Ember Web Socket client will be quite important.

Also, I will be able to contribute smaller parts related to above list, if you have something to share as small task.

Thanks! If you have time, the circe-scala-yaml project I linked needs some basic maintenance work to revive the test suites and stuff. Right now it is mostly a hasty fork of circe-yaml with the parser swapped out :)

armanbilge commented 1 year ago

Something else you can look into, is cross-platform the SSLContext. The good news is we already have cross-platform TLS in FS2, so we probably want to change this API to return an fs2.io.net.tls.TLSContext[F] instead of a Java SSLContext.

https://github.com/joan38/kubernetes-client/blob/caf15b394407996a95a98dadf95808010e9948b3/kubernetes-client/src/com/goyeau/kubernetes/client/util/SslContexts.scala#L20

After that, it looks like it is a matter of getting data out of the KubeConfig and loading it into the TLSContext. This will require platform-specific code, since each platform configures SSL/TLS differently.

armanbilge commented 1 year ago

Google Summer of Code http4s Ember Websocket Client project is now announced! Please spread the word :)

https://github.com/scalacenter/GoogleSummerOfCode#http4s-ember-websocket-client

novakov-alexey commented 1 year ago

@armanbilge I will have a look at the circe-scala-yaml tests