10. How Access a Pod Running Quarkus Application inside Jenkins Service

Adarsh BhaskarAdarsh Bhaskar
3 min read

If you're running Quarkus applications within a Jenkins pipeline on Kubernetes, you might be wondering how to access your application from your local machine for testing or debugging. This guide will walk you through the process step by step.

Understanding Where Your Quarkus App Runs

First, it's important to understand that in modern Jenkins setups, your Quarkus application is likely running in dynamically created Kubernetes pods. These pods function as worker nodes that execute your pipeline steps, including running your Quarkus application.

Finding Your Pod

Before you can access your application, you need to find the pod where it's running. You can do this with the following command but make sure to scope it in the namespace where Jenkins is installed:

kubectl get pods -n jenkins

Look for a pod related to your Jenkins job. It will typically have a name that includes your job name or the Kubernetes pod template name specified in your Jenkinsfile.

Accessing Application Logs

Once you've identified your pod, you can view its logs to verify that your Quarkus application is running correctly:

kubectl logs <pod-name>

This will show you all output from the Java process, including Quarkus startup messages.

If your application writes logs to files, you can access those directly within the pod:

kubectl exec -it <pod-name> -- cat /path/to/your/log/file.log

Making Your Quarkus App Accessible Locally

For local development and testing, the simplest way to access your Quarkus application is through port forwarding:

kubectl port-forward <pod-name> 8080:8080

This command forwards port 8080 on your local machine to port 8080 in the pod. After running this command, you can access your Quarkus application at http://localhost:8080. This make it accessible system wide but for testing the quarkus deployments, you usually have another machine that wants to test hence creating a kubernetes service for this pod and exposing this service via NodePort seems the best choice. Since after this the developers can test their quarkus application using postman or flutter clients on their machine.

Remember that port forwarding is intended for testing only and should not be used in production environments.

Creating a Kubernetes Service (For More Stable Access)

For a more stable setup (even during development), you can create a Kubernetes service to expose your application. Here's an example of a NodePort service:

apiVersion: v1
kind: Service
metadata:
  name: quarkus-service
spec:
  type: NodePort
  ports:
    - port: 8080
      targetPort: 8080
      nodePort: 30080 # Choose an available port
  selector:
    # Match the labels of your Quarkus pod
    app: quarkus-app

Save this to a file (e.g., quarkus-service.yaml) and apply it with:

kubectl apply -f quarkus-service.yaml

After applying this service, you can access your Quarkus application at http://[node-ip]:30080, where [node-ip] is the IP address of any node in your Kubernetes cluster.

Accessing Your Application from Client Apps

If you're developing a client application (like a Flutter app) that needs to connect to your Quarkus backend, you can use the same access methods described above. Your client will communicate with your Quarkus app using HTTP requests to the exposed endpoint.

Tips for Effective Development

  • Use the Jenkins console output to monitor your application during builds

  • Consider using a centralized logging system for better log management in larger setups

  • For production environments, use LoadBalancer services or Ingress controllers rather than NodePort or port forwarding

  • Make sure network policies are properly configured to allow traffic to your application

By following these steps, you should be able to effectively access and test your Quarkus application running in Jenkins Kubernetes pods from your local environment.

0
Subscribe to my newsletter

Read articles from Adarsh Bhaskar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Adarsh Bhaskar
Adarsh Bhaskar

Hi there! I’m Adarsh, a passionate information science student with hands-on experience in machine learning, software development, and data analysis. I thrive on solving complex problems and enjoy collaborating with teams to bring innovative solutions to life. Whether it’s developing a recommendation engine or streamlining workflows with automation, I love diving into new technologies. I’m always eager to learn and explore fresh ideas, especially in the world of Flutter app development!