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
trueand updating issuedTo section in Book's status. -
On Deleting any
BookIssueRequest,Bookis updated again and is marked available for issue(by setting issued status tofalse -
Any update in
BookIssueRequestobject would update specifiedBookresource 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 installAs 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.yamlMake 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:devIn 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.yamlThen you should be able to deploy the Operator using this command:
mvn k8s:deploy -PKubernetes