skuber-examples


License

License

GroupId

GroupId

io.skuber
ArtifactId

ArtifactId

skuber-examples_2.11
Last Version

Last Version

2.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

skuber-examples
skuber-examples
Project URL

Project URL

https://github.com/doriordan
Project Organization

Project Organization

io.skuber
Source Code Management

Source Code Management

https://github.com/doriordan/skuber

Download skuber-examples_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/io.skuber/skuber-examples_2.11/ -->
<dependency>
    <groupId>io.skuber</groupId>
    <artifactId>skuber-examples_2.11</artifactId>
    <version>2.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.skuber/skuber-examples_2.11/
implementation 'io.skuber:skuber-examples_2.11:2.5.0'
// https://jarcasting.com/artifacts/io.skuber/skuber-examples_2.11/
implementation ("io.skuber:skuber-examples_2.11:2.5.0")
'io.skuber:skuber-examples_2.11:jar:2.5.0'
<dependency org="io.skuber" name="skuber-examples_2.11" rev="2.5.0">
  <artifact name="skuber-examples_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.skuber', module='skuber-examples_2.11', version='2.5.0')
)
libraryDependencies += "io.skuber" % "skuber-examples_2.11" % "2.5.0"
[io.skuber/skuber-examples_2.11 "2.5.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
io.skuber : skuber_2.11 jar 2.5.0
com.typesafe.akka : akka-actor_2.11 jar 2.5.29
com.typesafe.akka : akka-slf4j_2.11 jar 2.5.29

runtime (1)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.1.3

Project Modules

There are no modules declared in this project.

Build Status Maven Central License

Skuber

Skuber is a Scala client library for Kubernetes. It provides a fully featured, high-level and strongly typed Scala API for managing Kubernetes cluster resources (such as Pods, Services, Deployments, ReplicaSets, Ingresses etc.) via the Kubernetes REST API server.

Features

  • Comprehensive support for Kubernetes API model represented as Scala case classes
  • Support for core, extensions and other Kubernetes API groups
  • Full support for converting resources between the case class and standard JSON representations
  • Client API for creating, reading, updating, removing, listing and watching resources on a Kubernetes cluster
  • The API is asynchronous and strongly typed e.g. k8s get[Deployment]("nginx") returns a value of type Future[Deployment]
  • Fluent API for creating and updating specifications of Kubernetes resources
  • Uses standard kubeconfig files for configuration - see the configuration guide for details

See the programming guide for more details.

Example

This example lists pods in kube-system namespace:

import skuber._
import skuber.json.format._
import akka.actor.ActorSystem
import scala.util.{Success, Failure}

implicit val system = ActorSystem()
implicit val dispatcher = system.dispatcher

val k8s = k8sInit
val listPodsRequest = k8s.listInNamespace[PodList]("kube-system")
listPodsRequest.onComplete {
  case Success(pods) => pods.items.foreach { p => println(p.name) }
  case Failure(e) => throw(e)
}

See more elaborate example here.

Quick Start

Make sure prerequisites are met. There are couple of quick ways to get started with Skuber:

With Ammonite-REPL

Provides you with a configured client on startup. It is handy to use this for quick experiments.

  • using bash

    $ amm -p ./Quickstart.sc
  • from inside ammonite-repl:

    import $file.`Quickstart`, Quickstart._

    Just handy shortcut to import skuber inside ammonite-repl:

    import $ivy.`io.skuber::skuber:2.6.0`, skuber._, skuber.json.format._

Interactive with sbt

  • Clone this repository.

  • Tell Skuber to configure itself from the default Kubeconfig file ($HOME/.kube/config):

    export SKUBER_CONFIG=file

    Read more about Skuber configuration here

  • Run sbt and try one or more of the examples and then:

    sbt:root> project examples
    sbt:skuber-examples> run
    
    Multiple main classes detected, select one to run:
    
     [1] skuber.examples.customresources.CreateCRD
     [2] skuber.examples.deployment.DeploymentExamples
     [3] skuber.examples.fluent.FluentExamples
     [4] skuber.examples.guestbook.Guestbook
     [5] skuber.examples.ingress.NginxIngress
     [6] skuber.examples.job.PrintPiJob
     [7] skuber.examples.list.ListExamples
     [8] skuber.examples.patch.PatchExamples
     [9] skuber.examples.podlogs.PodLogExample
     [10] skuber.examples.scale.ScaleExamples
     [11] skuber.examples.watch.WatchExamples
    
    Enter number:

For other Kubernetes setups, see the configuration guide for details on how to tailor the configuration for your clusters security, namespace and connectivity requirements.

Prerequisites

  • Java 8
  • Kubernetes cluster

A Kubernetes cluster is needed at runtime. For local development purposes, minikube is recommended. To get minikube follow the instructions here

Release

You can use the latest release (for 2.12 or 2.13) by adding to your build:

libraryDependencies += "io.skuber" %% "skuber" % "2.6.0"

Meanwhile users of skuber v1 can continue to use the final v1.x release, which is available only on Scala 2.11:

libraryDependencies += "io.skuber" % "skuber_2.11" % "1.7.1"

NOTE: Skuber 2 supports Scala 2.13 since v2.4.0 - support for Scala 2.11 has now been removed since v2.6.0.

Migrating to release v2

If you have an application using the legacy version v1 of Skuber and want to move to v2, then check out the migration guide.

Building

Building the library from source is very straightforward. Simply run sbt testin the root directory of the project to build the library (and examples) and run the unit tests to verify the build.

License

This code is licensed under the Apache V2.0 license, a copy of which is included here.

Versions

Version
2.5.0
2.4.1
2.4.0
2.3.0
2.2.0
2.1.1
2.1.0
2.0.12
2.0.11
2.0.10
2.0.9
2.0.8
2.0.7
2.0.6
2.0.5
2.0.4
2.0.4-RC1
2.0.3
2.0.2
2.0.1
2.0.0
2.0.0-RC2
1.7.1