Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Full Stack Quarkus and React

You're reading from  Full Stack Quarkus and React

Product type Book
Published in Nov 2022
Publisher Packt
ISBN-13 9781800562738
Pages 324 pages
Edition 1st Edition
Languages
Author (1):
Marc Nuri San Felix Marc Nuri San Felix
Profile icon Marc Nuri San Felix

Table of Contents (21) Chapters

Preface 1. Part 1– Creating a Backend with Quarkus
2. Chapter 1: Bootstrapping the Project 3. Chapter 2: Adding Persistence 4. Chapter 3: Creating the HTTP API 5. Chapter 4: Securing the Application 6. Chapter 5: Testing Your Backend 7. Chapter 6: Building a Native Image 8. Part 2– Creating a Frontend with React
9. Chapter 7: Bootstrapping the React Project 10. Chapter 8: Creating the Login Page 11. Chapter 9: Creating the Main Application 12. Chapter 10: Testing Your Frontend 13. Chapter 11: Quarkus Integration 14. Part 3– Deploying Your Application to the Cloud
15. Chapter 12: Deploying Your Application to Kubernetes 16. Chapter 13: Deploying Your Application to Fly.io 17. Chapter 14: Creating a Continuous Integration Pipeline 18. Index 19. Other Books You May Enjoy Appendix – Answers

Deploying Your Application to Kubernetes

In this chapter, we’ll learn how to deploy our task manager application to Kubernetes. We’ll start by learning about Kubernetes and containers and what the main features that have made these technologies so popular are. Then, we’ll learn how to create a container image for our application and how to push it to an external container registry. Next, we’ll create the required Kubernetes configuration files to be able to deploy our containerized application. Finally, we’ll deploy our application to a minikube Kubernetes cluster.

By the end of this chapter, you should have a basic understanding of Kubernetes and application containers. You should also be able to create container images for your Quarkus applications and deploy them to Kubernetes clusters to make them publicly available.

We will be covering the following topics in this chapter:

  • What is Kubernetes?
  • Creating a container image
  • Creating...

Technical requirements

You will need the latest Java JDK LTS version (Java 17 at the time of writing). In this book, we will be using Fedora Linux, but you can use Windows or macOS as well.

You will need the latest Node.js LTS version (16.15 at the time of writing).

You will need a working Docker environment to be able to run the Quarkus tests and to build and push container images using a Docker daemon. However, we’ll analyze alternatives that won’t require a Docker daemon. There are Docker packages available for most Linux distributions. If you are on a Windows or macOS machine, you can install Docker Desktop.

You can download the full source code for this chapter at https://github.com/PacktPublishing/Full-Stack-Quarkus-and-React/tree/main/chapter-12.

What is Kubernetes?

Kubernetes is an open source solution for container orchestration, initially released by Google in 2014 and later transferred to the Cloud Native Computing Foundation (CNCF). It allows you to deploy, scale, and manage container-based applications in an automated, declarative way.

In the Distributing the application as a monolith versus a microservice section in Chapter 11, Quarkus Integration, we went through the advantages and disadvantages of distributing our application as a monolith or as multiple microservices. We learned that when dealing with a distributed architecture, it’s advisable to rely on tools such as Kubernetes that help you automate and orchestrate the deployment and maintenance tasks for your services since there is a large number of them.

One of the main features of Kubernetes is that it abstracts away the underlying hardware infrastructure, providing a declarative interface to configure it. This allows you to define the requirements...

Creating a container image

Regardless of your application’s architecture, it’s very likely that you need to distribute your application as a container image to be able to leverage any of the available cloud providers since container images are now the standard unit of distribution. As we’ve learned in the What is a container-based application? section, the fact that the operations teams can manage workloads consistently and uniformly by leveraging container technology is shifting part of their responsibilities to developers, who will now have to ship their applications packaged as containers.

In the Kubernetes world, containers and container images are the way to run your application. This means that one of the main requirements to be able to deploy your application is to package it up into one or more container images and push those images to an external registry available to your Kubernetes cluster. When deployed, Kubernetes will download the container image...

Creating the cluster configuration manifests

Cluster configuration manifests are the files used by Kubernetes to be able to generate the required resources for your application. These are usually YAML files that contain a Kubernetes object declarative description that Kubernetes will interpret and try to satisfy by creating the requested objects and their resources using the underlying hardware infrastructure.

Writing and maintaining the cluster configuration files is a complex task that usually requires good knowledge and understanding of the different Kubernetes objects. Luckily for us, Eclipse JKube can also take care of creating these files for our application with a good set of opinionated defaults. Since our application has some special requirements such as a PostgreSQL database connection, we’ll need to provide some minor configuration tweaks to override some of these default values.

Eclipse JKube provides different ways to override the default configuration, including...

Deploying the task manager to minikube

Eclipse JKube’s Kubernetes Maven Plugin includes another goal that allows you to deploy the application into Kubernetes from the generated YAML files without the need for other tools such as kubectl. Let’s do this by executing the following command in the same terminal session we’ve been using so far:

./mvnw k8s:apply

The Maven execution should complete successfully, and we should be able to see Eclipse JKube’s log messages related to the Kubernetes object creations as follows:

Figure 12.9 – A screenshot of the result of the Maven k8s:apply goal execution

The application should be ready and we should be able to navigate to the exposed URL, in our case http://task-manager.192.168.49.2.nip.io, and test our application as follows:

Figure 12.10 – A screenshot of a browser pointing to http://task-manager.192.168.49.2.nip.io/login

Once we’ve finished...

Summary

In this chapter, we learned how to deploy our task manager application to Kubernetes. We started by learning about Kubernetes, and container technologies in general, and what their main advantages are compared to more traditional deployment strategies. Then, we learned how to create a container image for our application and the required cluster configuration manifests to be able to deploy it to Kubernetes using Eclipse JKube. Finally, we deployed the application into a local minikube Kubernetes cluster.

You should now have a basic understanding of Kubernetes. You should be able to create and publish container images for your applications, and know how to deploy them to Kubernetes to expose them to the world. In the following chapter, we’ll learn how to deploy the application to Fly.io, one of the most popular Cloud application platforms with one of its free pricing plans.

Questions

  1. What kind of applications does Kubernetes manage?
  2. What is a container-based application?
  3. What are the main advantages of application containers?
  4. What is a Pod?
  5. What is an Ingress?
  6. Does Jib require Docker?
lock icon The rest of the chapter is locked
You have been reading a chapter from
Full Stack Quarkus and React
Published in: Nov 2022 Publisher: Packt ISBN-13: 9781800562738
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}