Giter Club home page Giter Club logo

spring-boot-kubernetes's Introduction

Quick sample for building microservice with Spring Boot + Kubernetes and debug remotely

This project will show you how to setup kubernetes cluster by kubeadm , deploy spring boot micro service, and how to debug your code

Setup Kubernetes Cluster

See Setup Kubernetes By Kubeadm

Preparation

  • create cluster role
    kubectl create clusterrolebinding admin --clusterrole=cluster-admin --serviceaccount=default:default
  • Init mongodb
    kubectl apply -f kubernetes/mongodb

How To Deploy

  • build projects mvn clean install
  • build docker images
    bash build.sh
  • push docker images
    bash push.sh Please skip this step if you run locally
  • deploy to cluster
    kubectl apply -f kubernetes/projects
  • deploy ingress
    kubectl apply -f kubernetes/ingress.yaml
  • configure host
    run kubectl cluster-info to get cluster_ip
    add host to /etc/hosts with: <cluster_ip> micro.info

How To Test

  • Init Data:
    curl -d '{"id":1,"id":1,"name":"company name","address":"company address"}' -H 'Content-Type:application/json' shawn.info/organization/

    curl -d '{"organizationId":1,"id":1,"name":"department name"}' -H 'Content-Type:application/json' shawn.info/department/

    curl -d '{"organizationId":1,"departmentId":1,"id":1,"name":"employee"}' -H 'Content-Type:application/json' shawn.info/employee/ .

  • check result:

    curl micro.info/employee/1 .

    curl micro.info/department/1 .

    curl micro.info/department/organization/1/with-employees

How To Debug With Telepresence

Install Telepresence

OS X

brew cask install osxfuse
brew install datawire/blackbird/telepresence

Ubuntu 16.04 or later

curl -s https://packagecloud.io/install/repositories/datawireio/telepresence/script.deb.sh | sudo bash
sudo apt install --no-install-recommends telepresence

for other OS, See More

Configure

  • generate env.json
    telepresence --swap-deployment <service in k8s> --env-json service.env.json
  • load env in IDEA
    you will need to install the Env File plugin. load the service.env.json generated above
  • debug your code as usual
    Refer To: Using Telepresence with IntelliJ

Serverless(Kubeless)

Click Here to check the samples

Monitor(Prometheus,Grafana,Alert)

Click Here

spring-boot-kubernetes's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spring-boot-kubernetes's Issues

Just for clarification

Screen Shot 2022-10-11 at 2 36 23 AM
Hello!
I could not understand why you made two project for the same entity and is it for solving replication problems for database or other purpose? Thanks for your answer!

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.