doriordan / skuber

A Scala Kubernetes client library
Apache License 2.0
326 stars 97 forks source link

skuber.networking.Ingress fails on Kubernetes 1.18.x #316

Closed dipanjank closed 3 years ago

dipanjank commented 4 years ago

Hi,

I have encountered two problems with Skuber 2.5.0 when trying to create an ingress object. When I try to create an ingress to an existing service, I get the below exception:

[ERROR] [08/17/2020 09:53:23.348] [default-akka.actor.default-dispatcher-4] [akka.dispatch.Dispatcher] Failure(skuber.api.client.package$K8SException: Status(v1,Status,ListMeta(,,None),Some(Failure),Some(the API version in the data (networking.k8s.io/v1beta1) does not match the expected API version (extensions/v1beta1)),Some(BadRequest),None,Some(400))) (of class scala.util.Failure)
scala.MatchError: Failure(skuber.api.client.package$K8SException: Status(v1,Status,ListMeta(,,None),Some(Failure),Some(the API version in the data (networking.k8s.io/v1beta1) does not match the expected API version (extensions/v1beta1)),Some(BadRequest),None,Some(400))) (of class scala.util.Failure)

I think this is because the companion object in skuber.networking.Ingress.scala (https://github.com/doriordan/skuber/blob/master/client/src/main/scala/skuber/networking/Ingress.scala#L141) is still using the deprecated api group "extensions/v1beta1" instead of "networking.k8s.io/v1beta1" in the class definition. I have experiment with said solution in my dev environment and it works.

The second problem is that when I try to specify a numeric port in Ingress.addHttpRule, it fails with a validation error from Kubernetes. I think this is because the Kubernetes API for creating ingress expects an integer when the port is supposed to be numeric. If it is a string, it expects the name of a Port resource and not the string value of integer port number. skuber.networking.skuber.Backend always expects a string - IMHO it should either accept both int and string or should apply the same validation rule to convert the all numeric port number string to int internally before calling Kubernetes.

Steps to Reproduce


import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import skuber.networking.Ingress
import skuber.api.client.KubernetesClient
import skuber.{ObjectMeta, k8sInit}
import skuber.json.networking.format._
import scala.concurrent.ExecutionContext
import scala.util.Success

object LocalConnect {

  def main(args: Array[String]): Unit = {
    implicit val system: ActorSystem = ActorSystem()
    implicit val ec: ExecutionContext = system.dispatcher
    implicit val materializer: ActorMaterializer = ActorMaterializer()(system)
    val k8s: KubernetesClient = k8sInit

    val metadata: ObjectMeta = ObjectMeta(name="hello-ingress", namespace="default")
    val ingressSpec: Ingress = Ingress(metadata=metadata)
      .addHttpRule(Some("helloservice.acme.com"), Map("/"-> "hello-minikube:8080"))

    k8s.create(ingressSpec).onComplete {
      case Success(_) => println("Successfully created ingress.")
    }
  }
}

Thanks in advance! Please let me know if I can provide any other assistance.

Best, Dipanjan

anzecesar commented 4 years ago

Hi, is there an eta on when the fix for this will be released?

Trying to upgrade, we also ran into this issue.

MPV commented 3 years ago

@doriordan Would you be open to taking a look at #322 which aims to fix this?

Ingresses are broken in 2.6.0 without that fix.

We've resorted to using 2.5.0 for now, but are lacking new features added in 2.6.0.

doriordan commented 3 years ago

Hi @MPV thanks for the PR, I will have a chance to look at this tomorrow

MPV commented 3 years ago

@doriordan Any chance you could take a look again? ❤️

hagay3 commented 3 years ago

This repo seems to have been abandoned. A maintained fork is available here https://github.com/hagay3/skuber Please refer to the new repo which this PR already in place.

Thanks, Hagai