Deploy a Spring Boot Application Into Kubernetes

Hello folks,

In this article we will deploy a simple Spring Boot based application inside a K8S cluster.

To take the best of this article you should have a basic understanding of these subjects :

  • Docker because we will be using it as the runtime to containerise the app.
  • A K8S cluster (standalone or MiniKube) running in your local machine or use some of the cloud providers like
  • A basic understanding of Java and Spring boot

Prepare the simple app :

First things first let’s prepare the application. We will expose a greeting endpoint that we can later consume by calling the path /hello

Image for post

/hello endpoint

To make it simple i implemented the endpoint directly in the entry point of the application which it’s not a good practice, you know SOC or SOR ( yes you’re right, one of the SOLID principales).

so let’s move to the next step

Prepare the image specification :

To make it easy i didn’t make a multi stage docker build as the aim of this article isn’t focused on Docker but on Kubernetes. bellow the image specification (aka the Dockerfile ).

Image for post

Docker image specification

Since i’m using Java 11 i based my app on the liberica-openjdk-debian image that has more than 500K+ downloads on Docker hub.

I’m exposing my application on the port 8090, copying the jar file that we got after the build to the app.jar in my container and running the jar file with the java -jar command.

Build and tag the image :

At the same level of the docker file, use the bellow command to build and tag the image

docker build -t simple-app:1

make sure that your image has been built successfully as follows :

Image for post

A good practice is to run the container and check if the application is running successfully inside the container before taking a step further and deploying it to a K8s cluster ( yes the fail-safe approach ), so let’s do it

Image for post

app running

Here we go the application is running correctly inside to the container. now let’s consume our greeting endpoint:

Image for post

At this point we are sure that our image is ready to be deployed by an orchestrator in our case it’s K8s.

Prepare the deployment specification :

the best way to make a deployment in K8s is by preparing a YAML file that describes the desired state in which our application will be running without any problem

let’s have a look on it :

Image for post

apiVersion : describes the version of the API server of K8S that we will be consuming to create our deployment

kind: the kind of K8s object that we will be using for this specification

metadata : describes information about the app like name and labels (very important information the we will be exploring later on)

#spring-boot #docker #orchestration #kubernetes #java

What is GEEK

Buddha Community

Deploy a Spring Boot Application Into Kubernetes
Christa  Stehr

Christa Stehr

1602964260

50+ Useful Kubernetes Tools for 2020 - Part 2

Introduction

Last year, we provided a list of Kubernetes tools that proved so popular we have decided to curate another list of some useful additions for working with the platform—among which are many tools that we personally use here at Caylent. Check out the original tools list here in case you missed it.

According to a recent survey done by Stackrox, the dominance Kubernetes enjoys in the market continues to be reinforced, with 86% of respondents using it for container orchestration.

(State of Kubernetes and Container Security, 2020)

And as you can see below, more and more companies are jumping into containerization for their apps. If you’re among them, here are some tools to aid you going forward as Kubernetes continues its rapid growth.

(State of Kubernetes and Container Security, 2020)

#blog #tools #amazon elastic kubernetes service #application security #aws kms #botkube #caylent #cli #container monitoring #container orchestration tools #container security #containers #continuous delivery #continuous deployment #continuous integration #contour #developers #development #developments #draft #eksctl #firewall #gcp #github #harbor #helm #helm charts #helm-2to3 #helm-aws-secret-plugin #helm-docs #helm-operator-get-started #helm-secrets #iam #json #k-rail #k3s #k3sup #k8s #keel.sh #keycloak #kiali #kiam #klum #knative #krew #ksniff #kube #kube-prod-runtime #kube-ps1 #kube-scan #kube-state-metrics #kube2iam #kubeapps #kubebuilder #kubeconfig #kubectl #kubectl-aws-secrets #kubefwd #kubernetes #kubernetes command line tool #kubernetes configuration #kubernetes deployment #kubernetes in development #kubernetes in production #kubernetes ingress #kubernetes interfaces #kubernetes monitoring #kubernetes networking #kubernetes observability #kubernetes plugins #kubernetes secrets #kubernetes security #kubernetes security best practices #kubernetes security vendors #kubernetes service discovery #kubernetic #kubesec #kubeterminal #kubeval #kudo #kuma #microsoft azure key vault #mozilla sops #octant #octarine #open source #palo alto kubernetes security #permission-manager #pgp #rafay #rakess #rancher #rook #secrets operations #serverless function #service mesh #shell-operator #snyk #snyk container #sonobuoy #strongdm #tcpdump #tenkai #testing #tigera #tilt #vert.x #wireshark #yaml

Were  Joyce

Were Joyce

1624442460

Automate Spring Boot application deployments to Azure!

Today, we’re excited to announce the availability of the Azure Pipeline Task for deploying Spring Boot applications to Azure Spring Cloud. You can get started by building your pipelines using the Azure Spring Cloud task to automate Spring Boot application deployments to any number of environments and Azure Regions.

Over the past 18 months, we worked with many enterprise customers to learn about their scenarios including thoughts on automating end-to-end from idea to provisioning Azure resources to building Spring Boot applications to deploying those applications to production. Many of these customers have thousands of Spring Boot applications running in on-premises data centers. As they migrate these applications to the cloud, they need everything automated end-to-end to ensure repeatability and meet the requirements set forth by their IT departments and/or regulatory bodies. They require a fully-featured Continuous Integration / Continuous Delivery (CI/CD) service that can automatically deploy updated Spring Boot applications to Azure Spring Cloud. In many customer environments, they use Azure CLI in Azure Pipelines to automate Spring Boot application deployments to Azure, and they asked Microsoft for an Azure Spring Cloud task to ease their automation effort and delegate the maintenance of the deployment task to Microsoft. Now, using the new Azure Spring Cloud task, anyone can automate deployments straight to production or automate blue-green strategies to stage for testing and then set to production.

#[object object] #spring boot #azure #application deployments #automate spring boot application deployments to azure!

Were  Joyce

Were Joyce

1620751200

How to Configure the Interceptor With Spring Boot Application

In the video in this article, we take a closer look at how to configure the interceptor with the Spring Boot application! Let’s take a look!

#spring boot #spring boot tutorial #interceptor #interceptors #spring boot interceptor #spring boot tutorial for beginners

Were  Joyce

Were Joyce

1620720872

Spring vs Spring BooDifference Between Spring and Spring Boot

As an extension of the Spring Framework, Spring Boot is widely used to make development on Spring faster, more efficient and convenient. In this article, we will look at some of the parameters were using Spring Boot can drastically reduce the time and effort required in application development.

What is Spring?

Spring Boot

Difference between Spring and Spring Boot

Advantages of Spring Boot over Spring

Conclusion

#full stack development #spring #spring and spring boot #spring boot