Coder Social home page Coder Social logo

ashutoshsahoo / spring-boot-kubernetes Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 5.0 46 KB

Running a spring boot application in Kubernetes

Java 85.38% Dockerfile 14.62%
spring-boot docker kubernetes jenkinsfile microservices lombok jenkins-pipeline jkube jkube-maven-plugin kubernetes-deployment

spring-boot-kubernetes's Introduction

Spring Boot Kubernetes

Sample project to use spring boot application in kubernetes with jkube maven plugin.

  • Build application
mvn clean package

Docker image with layered architecture

For docker image with layered architecture, refer Jenkinsfile and Dockerfile directory.

  • Open shell in project directory and run following command to build docker image.
docker build -f deploy/Dockerfile --build-arg VERSION=7.2.0 -t ashutoshsahoo/spring-boot-kubernetes:7.2.0 .

Kubernetes deployment

  • Deploy to kubernetes
kubectl apply -f deploy/kubernetes.yml
  • Check pod and service status
kubectl get po,svc
  • Verify application status
curl --location --request GET 'http://localhost:31000/api/v5/hello'
  • Delete Kubernetes deployment
kubectl delete -f deploy/kubernetes.yml

Kubernetes Istio service mesh deployment

This is a demonstration of running two different versions of same application and redirecting traffic based on path prefix.

Please follow the instructions here to configure istio inside docker desktop.

  • Deploy app
kubectl apply -f deploy/istio
  • Check application status
kubelet get all
  • Verify application status
curl --location --request GET 'http://localhost/api/v5/hello'
  • Run following command to put some traffic into system.
for i in $(seq 1 100); do curl -s -o /dev/null "http://localhost/api/v5/hello"; done
for i in $(seq 1 100); do curl -s -o /dev/null "http://localhost/api/v6/hello"; done

Open kiali dashboard to view application metrics.

  • Delete deployment
kubectl delete -f deploy/istio
  • Clean up istio configuration

Refer the documentation here to clean up.

Deploy application using jkube maven plugin

  • Application deployment
mvn -Pk8s k8s:build k8s:resource k8s:deploy
  • Verify application
kubectl exec -it deployments.apps/spring-boot-kubernetes -- bash
curl --location --request GET 'http://localhost:8080/api/v5/hello'
  • UnDeploy application
mvn -Pk8s k8s:undeploy

spring-boot-kubernetes's People

Contributors

ashutoshsahoo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.