ZIO K8s

ZIO K8s

  • Overview
  • CRDs
  • Operators
  • Internals
  • API
  • About

›Operator

Operator

  • Operator library
  • Implementing operators
  • Auto-registering CRDs
  • Leader election

Auto-registering CRDs

A small helper function provides the capability to register the CRDs supported by the operator at startup. This takes advantage of a feature of zio-k8s-crd that generates a customResourceDefinition effect in the custom client module that retrieves the source YAML of the CRD that was used to generate the module.

In the following example we have a custom resouce called AlertSet generated with zio-k8s-crd as desribed on the CRD page, and the registerIfMissing ZIO effect will register that CRD into the Kubernetes cluster:

import com.coralogix.zio.k8s.operator.Registration
import com.coralogix.zio.k8s.client.com.coralogix.v1.alertsets
import com.coralogix.zio.k8s.client.com.coralogix.definitions.alertset.v1.AlertSet

Registration.registerIfMissing(alertsets.customResourceDefinition)

The registration requires the Logging with Blocking with CustomResourceDefinitions environment.

← Implementing operatorsLeader election →
ZIO K8s
GitHub
Star
Chat with us on Discord
discord
Additional resources
Scaladoc of zio-k8s
Copyright © 2024 ZIO Maintainers