Git Product home page Git Product logo

daneshk / microservices-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ballerina-attic/microservices-demo

0.0 1.0 0.0 5.11 MB

Sample cloud-native application with 10 microservices showcasing Kubernetes, Istio, gRPC and OpenCensus.

Home Page: http://35.238.163.103

License: Apache License 2.0

C# 44.27% Dockerfile 1.41% Batchfile 1.65% Shell 2.21% Go 14.78% JavaScript 2.16% Python 19.52% HTML 3.59% Java 2.93% Ballerina 7.48%

microservices-demo's Introduction

Ballerina Hackathon - KubeCon + CloudNativeCon North America 2019

This hackathon is an open invitation to all KubeCon NA 2019 attendees to try out Ballerina with Kubernetes, complete a series of coding challenges, and win some amazing prizes.

Overview

These coding challenges are all about having fun, learning a new programming language, mashing up microservices, and deploying them on Kubernetes. Here are some essential details about this hackathon.

Challenges

The challenges are based on the “Hipster Shop: Cloud-Native Microservices Demo Application” developed by Google Cloud. It is a web-based e-commerce application with 10 microservices written in different programming languages that talk to each other over gRPC. You can refer to the original README.md file to learn more about this application. Here is a brief overview of the service architecture.

Architecture of microservices

All you have to do is implement the following microservices in Ballerina. Order of services indicate how much Ballerina knowledge you will need to implement it as the first service require very little knowledge of Ballerina as well as the lines of code. We recommend you to complete the challenges in the order they appear in the below table to make the learning process easy.

Microservice Original Language Description
adservice Java Provides text ads based on given context words
currencyservice NodeJS Converts a certain amount in one currency to another currency.
checkoutservice Go Retrieves the user cart, prepares the order and orchestrates the payment, shipping and the email notification.

Here’s What You Need to Do

Take a look at the steps for each service below to understand how you need to implement the logic. Check out the original source code for more information.

Microservice Instructions
adservice
  1. Implement a service to generate ads based on given context keys.
currencyservice
  1. Read the conversion data in /src/currencyservice/data/currency_conversion.json (you can copy it to your ballerina project)
  2. Then implement the logic to output the correct conversion
  3. based on the ratios in JSON data. The GetSupportedCurrencies and Convert resources have to be implemented.
checkoutservice
  1. Implement a service to generate ads based on given context keys.
  2. Refer https://github.com/GoogleCloudPlatform/microservices-demo/blob/master/docs/img/architecture-diagram.png

The Getting Started section has more details on how to complete these challenges

Prizes

Here are the cool prizes you can win by completing the 3 challenges.

Read the Judging Criteria to see how you can win!

[TODO] Document eligibility criteria

Getting Started

Prerequisites

Ballerina

IDE Plugins

VSCode
IDEA

Docker and Kubernetes

  • Use Docker for Mac to install on Mac.
  • Use Docker for Windows to install on Windows.
  • Use Minikube to install on Linux.

GitHub Repository

  1. Create a private GitHub repository in your account. Do not fork this repository if you want to keep your code private during the hackathon. An example repository name would be ballerina-hackathon-kubecon-na-19
  2. Run the following commands to merge the microservices-demo content to your newly created repository.
    $ git clone https://github.com/<gitbubusername>/ballerina-hackathon-kubecon-na-19
    
    $ cd ballerina-hackathon-kubecon-na-19
    
    $ git remote add upstream https://github.com/ballerina-guides/microservices-demo.git
    
    $ git pull upstream master
    
    $ git push origin master

Running Hipster Shop Application (unchanged)

  1. Run the following command to deploy the app. This will take ~10 mins to complete. You will use pre-built container images that are available publicly, instead of building them yourself, which takes a long time

    kubectl apply -f ./release/kubernetes-manifests.yaml
  2. Run kubectl get pods to see whether pods are in a Ready state.

  3. If all the pods are running, kubectl get service/frontend-external

  4. Find the IP address of your application, then visit the application on your browser to confirm installation. (http://localhost:80 )

    kubectl get service/frontend-external

    Note: If you are on minikube, get the hostname by executing minikube ip. Example: <MINIKUBE_IP>:<FRONTEND_EXTERNAL_PORT>

    Congrats, You have successfully installed the default application by now.

  5. Run kubectl delete -f ./release/kubernetes-manifests.yaml to delete what's deployed.

Running Hipster Shop Application with Ballerina Services

To help you get started, We’ve already implemented the recommendation service in Ballerina, and the source code is available in the src/recommendatationservice_ballerina directory.

  1. Run the scripts/start.sh script.

  2. Check pods with kubectl get pods

  3. Access the web UI (http://localhost:80 or http://<minikube_ip>:<port>)

  4. Run the scripts/stop.sh script to delete what's deployed.

Now that you’ve successfully installed and deployed the Hipster Shop application with one microservice written in Ballerina, it’s time to start working on the challenges.

The microservices in this application talk to each other over gRPC. I.e, the microservices that you are implementing will receive requests over gRPC and they will also integrate with other microservices over gRPC. You can find the protocol buffers description here.

The first step would be to generate Ballerina gRPC service skeletons and client stubs. You can follow the following guides to learn more about gRPC support in Ballerina.

Generating Ballerina source code for gRPC protocol buffers

Go to your repository directory and run the following command to generate Services from proto file.

ballerina grpc --input pb/demo.proto  --output stubs --mode service

Now the “stubs” directory will have the generated Ballerina services and client artifacts as below.

Services skeletons

  • AdService_sample_service.bal
  • CheckoutService_sample_service.bal
  • PaymentService_sample_service.bal
  • RecommendationService_sample_service.bal
  • ProductCatalogService_sample_service.bal
  • CurrencyService_sample_service.bal
  • CartService_sample_service.bal
  • EmailService_sample_service.bal
  • ShippingService_sample_service.bal

Client stubs

  • demo_pb.bal

Note: You can copy the relevant service skeleton file and the demo_pb.bal file to your project.

Let’s start by writing the recommendationservice in Ballerina. We’ve already implemented this service for your reference. Here are the steps that we followed. You can repeat the same for all 3 challenges.

Let's start with the Recommendation Service

In Ballerina, the code is structured using projects and modules. A module is a directory which provides collaboration, sharing, and reuse of Ballerina code. Projects can have multiple related modules. Please find more information here.

In this demo, our recommendation is to create a Ballerina project for each microservice. Let’s append “_ballerina” to the name of the microservices that you are working on.

[TODO]

Submission Guidelines

Once you complete all 5 challenges, you can submit the source code and other details via the following mechanism.

  • Document everything that we need to be aware of your solution in the root README.md file of your repository.
  • Download a zip file of your GitHub repository using the GitHub web interface.
  • Then follow the instructions given in this Google form. [TODO]

Judging Criteria

A panel of judges will review each successful submission based on the following criteria.

[TODO]

Rules

  • You have to be a KubeCon North America 2019 attendee to participate in this hackathon.
  • [TODO]

FAQ

  1. How do I get help with queries related to the hackathon?

    If you have general questions on Ballerina, ask them on our Slack channel, Google group, or on Stackoverflow with the tag [ballerina]. If you have specific questions related to the hackathon, please visit the Ballerina booth(P13).

  2. Is this an individual challenge, or can I form a team for this?

    [TODO]

  3. Who can participate in the hackathon?

    You have to be a KubeCon North America 2019 attendee to participate in this hackathon.

  4. [TODO]

Hackathon policies?

[TODO]

microservices-demo's People

Contributors

ahmetb avatar daniel-sanche avatar rghetia avatar mtwo avatar nipunamarcus avatar sameerajayasoma avatar askmeegs avatar warunalakshitha avatar jkwlui avatar daneshk avatar orthros avatar sebright avatar davidstanke avatar jba avatar ymotongpoo avatar michaelawyu avatar kalyanac avatar ocervell avatar maryamzi avatar jan25 avatar howardjohn avatar jsirianni avatar mdelio avatar mehdime avatar mshahat avatar oussemos avatar caulagi avatar riccardomc avatar rvrignaud avatar thesandlord avatar

Watchers

 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.