Code Monkey home page Code Monkey logo

jpetstore-kubernetes's Introduction

Modernize and Extend: JPetStore on IBM Cloud Kubernetes Service

This demo modernizes an existing Java web application (JPetStore) by:

  1. building Docker containers from the legacy stack.
  2. moving the app to Azure Kubernetes Service.

Containerized Applications with IBM Cloud Kubernetes Service

Before you begin

Follow the below steps to create resources used in this demo. You will create a Kubernetes cluster.

  1. Create azure database for mysql servers and note down username, servername and password.
  2. Create kubernetes service from MCMP Store or from azure portal.
  3. Follow the instructions in the Access tab of your cluster to gain access to your cluster using kubectl.

Manual deployment

To manually deploy the demo, follow the below steps.

Clone the demo to your laptop

Clone the demo repository:

git clone https://github.ibm.com/mcmp-demo/jpetstore-kubernetes.git
cd jpetstore-kubernetes

Code structure

Folder Description
jpetstore Traditional Java JPetStore application
helm Helm charts for templated Kubernetes deployments
pet-images Pet images (which can be used for the demo)

Create Kubernetes secrets

Next, use the kubectl command to allow your Kubernetes cluster access to the secrets you just created.

Encode mysql server secrets using base64, put the same in secrets.yaml file and run the following command.

   cd jpetstore
   kubectl apply -f secrets.yaml

Build and push the container images

The docker images for each of the micro-services need to be built and then pushed to a container registry. Here are the steps for pushing to your private registry, but be aware that you could also push them to a public registry.

  1. Add secrets related to repository into values.yaml

  2. Build and push jpetstoredb image. Run these commands as they are.

    # from the jpetstore-kubernetes directory
    cd db
    docker build . -t ${MYREGISTRY}/${MYNAMESPACE}/jpetstoredb
    docker push ${MYREGISTRY}/${MYNAMESPACE}/jpetstoredb
  3. Build and push the jpetstoreweb image. Run these commands as they are. You do not need to replace any of the values belwo:

    # from the jpetstore-kubernetes directory
    cd jpetstore
    docker build . -t ${MYREGISTRY}/${MYNAMESPACE}/jpetstoreweb
    docker push ${MYREGISTRY}/${MYNAMESPACE}/jpetstoreweb
  4. Finally make sure that both images have been successfully pushed to the container registry.

Deploy the application

There are two different ways to deploy the three micro-services to a Kubernetes cluster:

  • Using Helm to provide values for templated charts (recommended)
  • Or, updating yaml files with the right values and then running kubectl create

Option 1: Deploy using YAML files

For this option, you need to update the YAML files to point to your registry namespace.

  1. kubectl apply -f mysqlJob.yaml - This creates predefined schema into mysql database.
  2. kubectl create -f jpetstore.yaml - This creates the JPetstore app microservice

Copy the external ip under jpetstore service and try to open it in browser.

You're Done!

You are now ready to use the UI to shop for a pet or query the store by sending it a picture of what you're looking at:

  1. Access the java jpetstore application web UI for JPetstore using IP provided by kubectl get svc -n <namespace>

Clean up:

# Use "helm delete" to delete the two apps
kubectl delete -f jpetstore.yaml

# Delete the secrets stored in our cluster
kubectl delete secret mysql-creds
  








jpetstore-kubernetes's People

Contributors

mcmpdemo avatar jose-ramirez-mendez avatar smalpani13 avatar karl-ibm avatar estebanhvkyndryl avatar kerednai avatar jameskutty1983 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.