joan38 / kubernetes-client

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

Can you give me an example of how to simply output a list of pods? #248

Closed bench87 closed 10 months ago

bench87 commented 10 months ago

You're a developer who wrote scalar code a long time ago. Can you give me a simple example so I can get a feel for writing scalar code? The code below is what I wrote, but it doesn't work.

import cats.effect.{IO, IOApp}
import com.goyeau.kubernetes.client.*
import io.k8s.api.apps.v1.*
import io.k8s.api.core.v1.*
import io.k8s.apimachinery.pkg.api.resource.Quantity
import io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger

import java.io.File
import scala.concurrent.ExecutionContext
import scala.concurrent.duration.*
implicit val logger: Logger[IO] = Slf4jLogger.getLogger[IO]

object HelloWorld extends IOApp.Simple {

  val run = {
    val kubernetesClient = KubernetesClient[IO](KubeConfig.standard[IO])
    val podListIO = kubernetesClient.use(_.pods.namespace("infra").listDecoder)
  }
}
joan38 commented 10 months ago
kubernetesClient.use(_.pods.namespace("infra").list())

?

bench87 commented 10 months ago
kubernetesClient.use(_.pods.namespace("infra").list())

?

sorry I'm a very novice scalar developer, so the code I wrote above is probably completely wrong. If you can give me a simple pod list example, I'll start with that code snippet and try to build what I want.

bench87 commented 10 months ago

Sorry about that. It seems that my IDE settings were incorrect and the autocomplete was not working and I was having trouble writing code because of it. I'm closing this issue.

joan38 commented 10 months ago

Glad it helps!