GithubHelp home page GithubHelp logo

biswabandhu21 / customerapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nomisbeme/customerapp

0.0 2.0 0.0 24 KB

A simple customer database for a fictitious company. Kubernetes + Java backed by MongoDB. Makes heavy use of Microsoft managed services to keep things easy.

Makefile 1.85% Smarty 5.73% CSS 0.02% Java 92.39%

customerapp's Introduction

Summary

A simple customer database for a fictitious company. Kubernetes + Java backed by MongoDB. Makes heavy use of Microsoft managed services to keep things easy. Traffic to/from the application is secured using TLS.

This is a demonstration application that optimizes for simplicity and learning. Not intended for production use.

Prerequisites

Setup

Provisioning the initial resources can take a little time so I did these steps upfront.

  1. Download and setup the command-line tools you'll need on your computer. The examples below assume Mac but should work on other platforms.
  1. Create an Azure group and an empty Kubernetes cluster in that group
az group create --name bayazure --location eastus
az aks create --name k8s --resource-group bayazure
az aks get-credentials --name k8s --resource-group bayazure
  1. Add some needed components to Kubernetes
$ helm init
$ helm install stable/nginx-ingress
$ helm install --name kube-lego stable/kube-lego --set [email protected] --set config.LEGO_URL=https://acme-v01.api.letsencrypt.org/directory

We use nginx-ingress to route external traffic within our cluster. kube-lego is used to automatically obtain a TLS certificate from Let's Encrypt. Adjust the example values above for your environment and domain.

  1. Next we'll create a CosmosDB MongoDB database to store our application data in.
$ az cosmosdb create --kind MongoDB --name customerdatabase --resource-group bayazure

Building and deploying the application

  1. First create a Kubernetes secret so that the application can connect to MongoDB:
kubectl create secret generic customerdatabasesecret \
    --from-literal="MONGODB_URI=$(\
    az cosmosdb list-connection-strings -n customerdatabase -g bayazure --query "connectionStrings[0].connectionString" \
      --out tsv | tr -d '\n')"
  1. Next we'll build our Spring Boot application code:
mvn clean package

This creates an file target/customerapp-0.1.2.war that contains our application.

  1. Then package the application in a Container image and push it to the Docker Hub:
docker build -t nomisbeme/customerapp:0.1.2 .
docker push nomisbeme/customerapp:0.1.2
  1. Use the Kubernetes package manager, helm, to deploy the resulting application to Kubernetes.
helm install helm/customerapp/ -n capp

Adjust the ingress.host to point to the correct domain name if needed.

  1. Wait for the application to deploy then access it at your domain name.
open http://azure.baleenlabs.com

Updating the application

Kubernetes and Helm make it easy to deploy new versions of an application, so we'll modify the application and deploy the result.

  1. Modify the application. Hint: Uncomment list.jsp

  2. Rebuild the application and push a new version to the Docker Hub:

mvn clean package
docker build -t nomisbeme/customerapp:fixed .
docker push nomisbeme/customerapp:fixed
  1. Now update the existing deployment to reference the new code.
helm upgrade --set image.tag=fixed capp helm/customerapp

Improvements

  • Use Open Service Catalog for Azure to expose Cosmos within the Kubernetes cluster
  • Use the Spotify maven plugins to simplify container image creation
  • Use a private registry e.g. Azure Container Registry to avoid making application code publicly available.
  • Replace kube-lego with the more modern replacement cert-manager

customerapp's People

Contributors

nomisbeme 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.