This is a simple demo Kubernetes Operator written to mimic Library Management using Quarkus Fabric8 Kubernetes Client Extension. It operates on the following Custom Resources:
- Book
- BookIssueRequest
-
User creates a BookIssueRequest which updates the requested Book setting it's issued status to
true
and updating issuedTo section in Book's status. -
On Deleting any
BookIssueRequest
,Book
is updated again and is marked available for issue(by setting issued status tofalse
-
Any update in
BookIssueRequest
object would update specifiedBook
resource in case it's different from previous value
Both Book
and BookIssueRequest
CustomResources are watched in specified namespace and Operator tries to issue/free any book which is requested via adding/deleting any BookIssueRequest
.
You can build it as any standard maven project
mvn clean install
As an administrator, you would need to create these CRDs in your Kubernetes cluster:
kubectl create -f src/main/resources/k8s/crds/book-crd.yaml
kubectl create -f src/main/resources/k8s/crds/bookissuerequest-crd.yaml
Make sure that you have access to a Kubernetes Cluster(minikube or crc). You can start your Operator locally using standard Quarkus Maven Plugin goals:
mvn quarkus:dev
In order to deploy this Operator to Kubernetes, we will be using Eclipse JKube. First we would need to deploy Role
, RoleBinding
and ServiceAccount
for our Operator to Kubernetes
kubectl create -f src/main/resources/k8s/role.yaml
kubectl create -f src/main/resources/k8s/rolebinding.yaml
kubectl create -f src/main/resources/k8s/serviceaccount.yaml
Then you should be able to deploy the Operator using this command:
mvn k8s:deploy -PKubernetes