Skip to content

Commit

Permalink
Drop v1beta1 crds for k8s 122 compliance (#1212)
Browse files Browse the repository at this point in the history
* get rid of CRDs in version v1beta1
  • Loading branch information
Thomas authored Aug 8, 2022
1 parent fa431bf commit 6187fbf
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,6 @@ class KubeClientFabric8(
}
}

private def getCrd(name: String, client: KubernetesClient) = {
client
.apiextensions()
.v1beta1()
.customResourceDefinitions()
.inAnyNamespace()
.list()
.getItems()
.asScala
.find { crd =>
val crdName = crd.getMetadata.getName
logger.trace(s"Scanning Custom Resources found: ${name}")
crdName == name
}
}

private def getCloudflowApplicationsClient(client: KubernetesClient) =
Try {
val cloudflowClient = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Fabric8KubeClientSpec extends AnyFlatSpec with Matchers with BeforeAndAfte
.mkString("\n")

server.expect.get
.withPath("/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions")
.withPath("/apis/apiextensions.k8s.io/v1/customresourcedefinitions")
.andReturn(
HttpURLConnection.HTTP_OK,
Source
Expand Down
23 changes: 15 additions & 8 deletions core/cloudflow-crd/src/main/scala/akka/datap/crd/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder
import io.fabric8.kubernetes.api.model.apiextensions.v1.{
CustomResourceDefinitionBuilder,
CustomResourceDefinitionVersion,
CustomResourceDefinitionVersionBuilder
}
import io.fabric8.kubernetes.api.model.{ KubernetesResource, Namespaced, ObjectMeta }
import io.fabric8.kubernetes.client.{ CustomResource, CustomResourceList }
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
import io.fabric8.kubernetes.model.annotation.{ Group, Kind, Plural, Version }

import scala.util.Try

object App {

// GroupName for our CR
Expand Down Expand Up @@ -50,6 +52,15 @@ object App {
final val ProtocolVersionKey = "protocol-version"
final val ProtocolVersion = "7"

val customResourceDefinitionVersion: CustomResourceDefinitionVersion = {
new CustomResourceDefinitionVersionBuilder()
.withName(GroupVersion)
.withNewSubresources()
.withNewStatus()
.endStatus()
.endSubresources()
.build()
}
val customResourceDefinitionContext: CustomResourceDefinitionContext =
new CustomResourceDefinitionContext.Builder()
.withVersion(GroupVersion)
Expand All @@ -73,13 +84,9 @@ object App {
.withPlural(Plural)
.withShortNames(Short)
.endNames()
.withVersion(GroupVersion)
.withVersions(customResourceDefinitionVersion)
.withScope("Namespaced")
.withPreserveUnknownFields(true)
.withNewSubresources()
.withNewStatus()
.endStatus()
.endSubresources()
.endSpec()
.withNewStatus()
.withStoredVersions(GroupVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ object Main extends {
Option(
client
.apiextensions()
.v1beta1()
.v1()
.customResourceDefinitions()
.withName(App.ResourceName)
.get()) match {
case Some(crd) if crd.getSpec.getVersion == App.GroupVersion =>
case Some(crd) if crd.getSpec.getVersions().asScala.exists(_.getName == App.GroupVersion) =>
system.log.info(s"CRD found at version ${App.GroupVersion}")
case _ =>
system.log.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ object Name {
val ofContainerPrometheusExporterPort = max15Chars("prom-metrics")

def ofService(streamletDeploymentName: String) =
truncateTo63CharactersWithSuffix(makeDNS1039Compatible(ofPod(streamletDeploymentName)), "-service")
truncateTo63CharactersWithSuffix(ofPod(streamletDeploymentName), "-service")

def ofAdminService(streamletDeploymentName: String) =
s"${ofPod(streamletDeploymentName)}-admin-service"
Expand Down
2 changes: 1 addition & 1 deletion core/tooling/src/main/scala/cli/CodepathCoverageMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ object CodepathCoverageMain extends App {

Serialization
.jsonMapper()
.readValue("{}", classOf[io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList])
.readValue("{}", classOf[io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionList])

Serialization
.jsonMapper()
Expand Down

0 comments on commit 6187fbf

Please sign in to comment.