This quarkus project is intended to follow the QuarkusTop 10 Kubernetes Features session that was delivered at j4k.io 2020 virtual conference.
Important
|
To run this project on your own, follow the setup instructions in the yaml directory. |
Top 10 features shown include:
-
One-step Kubernetes deployment
-
Remote Live-coding in Kubernetes
-
Direct ConfigMap and Secrets access
-
Health endpoints
-
Kuberentes Client API
-
OpenMetrics support
-
OpenTracing support
-
One-step KNative deployment
-
Functions as a Service with Funqy
-
Efficiency
-
Fast startup time
-
Minimum memory utilization
-
This project includes a few features/details that I couldn’t fit in the 45 minute slot, or even the 52 minutes I took to record it (whups, I went over!). These include:
-
Kubernetes Secrets
-
Database access to show Agroal datasource readiness check and Jaeger Tracing between the application and the database.
-
A custom liveness check, which makes the quarkus health-ui look a bit more populated.
In addition to the setup from the yaml directory, the j4k configmap and j4k-secret map must be configured:
kubectl create cm j4k \
--from-literal=greeting="Hello ConfigMap"
kubectl create secret \
generic \
j4k-secret \
--from-literal=db.user=quarkus \
--from-literal=db.pass=quarkus
cd j4k
mvn clean package -Dquarkus.kubernetes.deploy=true
# We'll use this endpoint quite a bit, so let's save it
URL=`minikube service --url j4k`
# Get the persons (call database), should return JSON array of 3 persons
curl -i ${URL}/person
# Test the metrics endpoint
curl ${URL}/metrics
# Test the health endpoint
curl ${URL}/health
# Test Kube Client API (get pods)
curl ${URL}/kube/pods
# Stream pod events
curl ${URL}/kube/pods/stream
# 2nd terminal
kubectl scale --replicas 2 deployment/j4k
# Wait for pods to come up, then scale back down
kubectl scale --replicas 1 deployment/j4k
Open ${URL}/health-ui to test Health UI.
Open http://localhost:3000 to view grafana dashboard
Open http://localhost:16686 to view Jaeger UI
Important
|
This example uses quay.io, which creates a private image repository by default. If using Quay, go into the repository settings and make it a public repository. Using Docker Hub should work as-is. |
cd funqy
mvn \
clean \
package \
-Dquarkus.kubernetes.deploy=true \
-Dquarkus.kubernetes.deployment-target=knative
Once deployed, find the funqy service endpoint using the kn command line utility, and then curl the resulting endpoint. The URL shown will likely be differet than yours:
kn service list
curl -i http://funqy.default.10.98.14.70.nip.io/message
If you wait a minute or so, the number of pods will scale down to zero (using kubectl get pods -w
).
Scale up the pods dynamically by curling the endpoint again.
Get the name of any running pod using kubectl get pods
and run kubectl logs <POD> funqy
.
The startup time will show there.
This example shows the function starting in 1.1 seconds using the JVM on loaded minikube instance:
exec java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/app.jar
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-09-24 19:49:22,995 INFO [io.quarkus] (main) funqy 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.8.1.Final) started in 1.132s. Listening on: http://0.0.0.0:8080
2020-09-24 19:49:22,997 INFO [io.quarkus] (main) Profile prod activated.
2020-09-24 19:49:22,997 INFO [io.quarkus] (main) Installed features: [cdi, funqy-http, kubernetes]
To view RSS (memory usage) of the JVM instance, run: .Get RSS value
ssh minikube
ps -ef | grep app.jar # get the process id
ps -o rss,command <PID>
RSS COMMAND
118160 java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmana
The JVM process will use 118M of RAM.