Quarkus and Service Binding Operator
Quarkus and Service Binding Operator
![~/Documents/photos/logos/png/quarkus.png](~/Documents/photos/logos/png/quarkus.png)
Preparation
Create a kind cluster
Install OLM
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.19.1/install.sh | bash -s v0.19.1
Install SBO
kubectl create -f https://operatorhub.io/install/service-binding-operator.yaml
Install the Postgress Operator
kubectl create -f https://operatorhub.io/install/postgresql.yaml
Create a demo namespace
kubectl create ns demo
kubectl config set-context --current --namespace=demo
Create a postgress cluster
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: postgresql
namespace: demo
spec:
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.4-0
postgresVersion: 13
instances:
- name: instance1
dataVolumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
backups:
pgbackrest:
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-2
repos:
- name: repo1
volume:
volumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
- name: repo2
volume:
volumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
proxy:
pgBouncer:
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.15-2
kubectl apply -f ~/pg-cluster.yml
Demo Quarkus ServiceBinding generation
Clone the examples
cd
mkdir -p ~/demo
git clone [email protected]:quarkusio/quarkus-quickstarts.git ~/demo/quarkus-quickstarts
Pick up a postgres example
cp -r ~/demo/quarkus-quickstarts/hibernate-orm-panache-quickstart ~/demo/hibernate-orm-panache-quickstart
cd ~/demo/hibernate-orm-panache-quickstart
Add kubernetes and service binding extensions
quarkus ext add -B kubernetes kubernetes-service-binding container-image-docker
Set the Image Pull Policy
echo "quarkus.kubernetes.image-pull-policy=IfNotPresent" >> src/main/resources/application.properties
Create the container image
mvn clean install -Dquarkus.container-image.build=true -DskipTests
kind load docker-image iocanel/hibernate-orm-panache-quickstart:1.0.0-SNAPSHOT
Configure Service Binding
cat <<'EOF' >>src/main/resources/application.properties
quarkus.kubernetes-service-binding.services.my-db.api-version=postgres-operator.crunchydata.com/v1beta1
quarkus.kubernetes-service-binding.services.my-db.kind=PostgresCluster
quarkus.kubernetes-service-binding.services.my-db.name=postgresql
EOF
Deploy
mvn clean install -Dquarkus.kubernetes.deploy=true -DskipTests
Verify
kubectl port-forward service/hibernate-orm-panache-quickstart 8080:80
How we can further improve the experience ?
![~/Documents/photos/magic.png](~/Documents/photos/magic.png)
Demo Quarkus Automagic ServiceBinding generation
Overview
- Preview of Quakus automagic binding
- Explain convetions
- Talk about customization
Check the generated resources
(delete-other-windows)
(find-file-other-window "~/demo/hibernate-orm-panache-quickstart/target/kubernetes/kubernetes.yml")
(shrink-window 75 t)
Remove ALL service binding configuration
sed -i '/^quarkus.kubernetes-service-binding/d' src/main/resources/application.properties
Rebuild the application
mvn clean install -DskipTests