Apache Ignite and Spring on your Kubernetes Cluster Part 3: Testing the application
On the previous blog we created our Kubernetes deployment files for our Ignite application. On this blog we shall deploy our Ignite application on Kubernetes. I will use minikube on this.
Let’s build first
1 | mvn clean install |
I shall create a simple docker image, thus a Dockerfile is neeeded.
Let’s add a Dockerfile to the root of our project.
1 2 3 4 5 | FROM adoptopenjdk /openjdk11 COPY target /job-api-ignite-0 .0.1-SNAPSHOT.jar app.jar ENTRYPOINT [ "java" , "-jar" , "app.jar" ] |
Now we want to deploy this to our local Κubernetes. Follow this guide on how to use local images on Kubernetes.
Then let’s build our app
1 | docker build -f Dockerfile -t job-api:1.0 . |
Time to apply our Kubernetes yaml files.
1 2 3 | kubectl apply -f job-cache-rbac.yaml kubectl apply -f job-api-deployment.yaml kubectl apply -f job-api-service.yaml |
Give it some time and check your pods
1 2 3 4 | > kubectl get pods NAME READY STATUS RESTARTS AGE job-api-deployment-86f54c9d75-dpnsc 1 /1 Running 0 11m job-api-deployment-86f54c9d75-xj267 1 /1 Running 0 11m |
Let’s issue a request through the first pod. This request will reach github and then shall cache the results in memory.
1 | kubectl exec -it job-api-deployment-86f54c9d75-dpnsc -- curl localhost:8080 /jobs/github/1 |
Then we shall use the other endpoint in order to fetch data straight from ignite.
1 | kubectl exec -it job-api-deployment-86f54c9d75-xj267 -- curl localhost:8080 /jobs/github/ignite/1 |
So we are successful, which means that our Ignite cluster is running in our Kubernetes workloads. The data are cached and shared between the nodes.
You can find the code on GitHub.
Published on Java Code Geeks with permission by Emmanouil Gkatziouras, partner at our JCG program. See the original article here: Apache Ignite and Spring on your Kubernetes Cluster Part 3: Testing the application Opinions expressed by Java Code Geeks contributors are their own. |