Code Monkey home page Code Monkey logo

docker-kubernetes-demo's Introduction

Spring Boot, MySQL, JPA, Hibernate Rest API Tutorial

Build Restful CRUD API for a simple Note-Taking application using Spring Boot, Mysql, JPA and Hibernate.

Requirements

  1. Java - 1.8.x

  2. Maven - 3.x.x

  3. Mysql - 5.x.x

Steps to Setup

1. Credits

callicoder

2. Create Mysql database

create database employees

3. Change mysql username and password as per your installation

  • open src/main/resources/application.properties

  • change spring.datasource.username and spring.datasource.password as per your mysql installation

2. Build the app using maven

mvn clean package

Alternatively, you can run the app without packaging it using -

mvn spring-boot:run

The app will start running at http://localhost:8080.

Explore Rest APIs

The app defines following CRUD APIs.

GET /api/employees

POST /api/employees

GET /api/employees/{employeesId}

PUT /api/employees/{employeesId}

DELETE /api/employees/{employeesId}

You can test them using postman or any other rest client.

Docker Images for K8S Demo

Hardcoded Values

spring.datasource.url = jdbc:mysql://mysql-service:3306/hclDatabase?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
spring.datasource.username = hclUser
spring.datasource.password = hclPassword
spring.datasource.platform = mysql
spring.datasource.initialization-mode = always
siddharth67/springboot-mysql:hardcoded

K8S Dynamic Values

spring.datasource.url = jdbc:mysql://${KUBE_CONFIG_HOST}:${KUBE_CONFIG_PORT}/${KUBE_CONFIG_DATABASE}?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
spring.datasource.username = ${KUBE_SECRET_USERNAME}
spring.datasource.password = ${KUBE_SECRET_PASSWORD}
spring.datasource.platform = mysql
spring.datasource.initialization-mode = always
siddharth67/springboot-mysql:dynamic

docker-kubernetes-demo's People

Contributors

sidd-harth avatar

Watchers

 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.