Giter Club home page Giter Club logo

spring-in-kubernetes's Introduction

Simple SpringBoot in Kubernetes

This simple project demonstrate how springboot application call another application through Kubernetes Sevice Discovery. This project testing environment was using Docker Dekstop for Windows with embeded Kubernetes, but you can use another software like minikube or similar software.

Pre-requisite Software

Docker Dekstop for Windows

https://docs.docker.com/docker-for-windows/install/

You need to enable Kubernetes after Docker Desktop installation alt text

Prepare Docker Image

Maven Base Image

This project build tool is using maven. Building jar file process is inside docker file, to prevent download dependencies process while building docker image, we created base image which is containing dependencies for building jar file.

  • open command line and navigate to maven-base-image folder
  • execute docker image build spring-maven:2.2.0.M4 .
  • to check wether docker image was created use this command docker image ls

Build currency-exchange-service docker image

  • open command line and navigate to currency-exchange-service folder
  • execute docker image build currency-exchange-service:v1 .
  • to check wether docker image was created use this command docker image ls

Build currency-conversion-service docker image

  • open command line and navigate to currency-conversion-service folder
  • execute docker image build currency-conversion-service:v1 .
  • to check wether docker image was created use this command docker image ls

Deploy application to Kubernetes Cluster

Configure kubernetes config :

  • Powershell $Env:KUBECONFIG="C:\Users\<YOUR_USER_NAME>\.kube\config"
  • Command Line setx KUBECONFIG "C:\Users\tarsidi\.kube\config"

To check config already loaded, execute this command kubectl config view

alt text

After config file was loaded, create namespace by execute this command kubectl create namespace spring-cloud

currency-exchange-service

  • open command line and navigate to currency-exchange-service folder
  • execute kubectl apply -f currency-exchange-sevice.yaml
  • to check wether pod & service was created use this command kubectl get pods -n spring-cloud

currency-conversion-service

  • open command line and navigate to currency-conversion-service folder
  • execute kubectl apply -f currency-conversion-sevice.yaml
  • to check wether pod & service was created use this command kubectl get pods -n spring-cloud

Checking Services

You can check the service port use this command kubectl get services -n spring-cloud

alt text

The port number we can access will be greater 30000, so in this case we can use 30920 to access currency-conversion-service and 32042 to access currency-exchange-service

Response from services

  • Currency Conversion Service

alt text

  • Currency Exchange Service

alt text

spring-in-kubernetes's People

Contributors

sidie88 avatar

Watchers

James Cloos 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.