Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Skatteetaten/kubernetes-reactor-coroutines-client

Repository files navigation

Kubernetes Reactor Couroutines Client

This is a simple http client for talking with kubernetes.

It is using WebClient from Spring Webflux as the http client and has support for Kotlin coroutines

Usage

For a complete list of examples look at the KubernetesClient integration tests, KubernetesUserTokenClientIntegrationTest.

Add @TargetClient(ClientTypes.SERVICE_ACCOUNT) to the place where the instance is injected to get the KubernetesClient configured with service account token. Or @TargetClient(ClientTypes.USER_TOKEN) to provide a TokenFetcher that gets the user token.

Get a resource

val dc = kubernetesClient.get(newDeploymentConfig {
    metadata {
        namespace = ""
        name = ""
    }
})

Get a resource list

val services: List<Service> = kubernetesClient.getMany(newService {
    metadata = newObjectMeta {
        namespace = NAMESPACE
    }
})

Get a resource list with label

val projects: List<Project> =
    kubernetesClient.getMany(newProject { metadata { labels = newLabel("removeAfter") } })

Create/Post a resource

val s = newSelfSubjectAccessReview {
    spec {
        resourceAttributes {
            namespace = ""
            verb = "update"
            resource = "deploymentconfigs"
        }
    }
}
val selfSubjectAccessView = kubernetesClient.post(s)

Delete a resources

val deleted = kubernetesClient.deleteBackground(newApplicationDeployment {
    metadata {
        name = ""
        namespace = NAMESPACE_DEV
    }
})

About

Kubernetes Http Client Using Spring Reactor and Kotlin Coroutines

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages