Pleasue use kubernetes-client to do the same
See this blog-post as an example k8s-operator
Freya is a Scala library to implement custom controllers for Kubernetes (K8s) easily. An implementation of custom controller is also known as Operator Pattern. Freya based on fabric8 kubernetes client and inspired by abstract-operator Java library.
Freya main features:
- Two options to implement your Kubernetes Operator:
- Custom Resource Definition (CRD) based
- ConfigMap based
- Scala Case Classes as Kubernetes resource specification. Serialization and deserialization of case classes is done by Freya using Circe or Jackson Scala Module library.
- Auto-restart of custom controller upon k8s api-server disconnect.
- Auto-deployment of CRDs, no YAML files to be written.
- Auto-deployment of JSON Schema for CRD validation.
- Effect management and Functional Programming powered by Cats-Effect.
- Kerberos Operator: https://github.com/novakov-alexey/krb-operator
Freya supports Scala 2.13 only at the moment. Main dependency:
"io.github.novakov-alexey" %% "freya-core" % "@VERSION@"
Second module has two options: circe or jackson. One of them needs to be added into your dependencies to be able to read custom resource JSON/YAML text or write resource status as JSON
Circe:
"io.github.novakov-alexey" %% "freya-circe" % "@VERSION@"
Jackson:
"io.github.novakov-alexey" %% "freya-jackson" % "@VERSION@"
Microsite: https://novakov-alexey.github.io/freya/docs/