GithubHelp home page GithubHelp logo

microservicescourse's Introduction

Blog

Part of course in Microservices with Node JS and React.

This repo consists of multiple services that,when run concurrently, fulfills the needs of a blog-app that allows creation of posts and comments.

Development

Every service is dockerized and we use Kubernetes in order to manage the containerized applications. In order to create and then apply the configuration to the resources we use Skaffold.

$ cd ~/infra/k8s

# Without skaffold. Applying all the configuration
$ kubectl apply -f .

# With skaffold:
$ skaffold dev

Perks of using Skaffold

  • With the correct setup, Skaffold applies changes to files on the fly. You don't have to rebuild a docker-image, push it and restart the kubernetes pod with kubectl rollout restart deployment posts-depl
  • When you quit skaffold dev, it takes down all the pods it spun up - saves you the manual destroy.

Local redirect for Kubernetes

In order to run the services locally you'll have to add a redirect from posts.com to localhost. This is done as part of setting up the ingress service ingress-srv.yaml. This way every network-request can be sent to posts.com and be handled by the ingress service which will route the request to the correct service based only on the route destination.

# /etc/hosts
...

127.0.0.1 posts.com

Lessons from project

  • The big challenge in microservices is data
  • There are different way sof sharing data. We are going to focus on async communication.
  • Async communication focuses communicating changes using events sent to an event-bus
  • Async communication encourages each service to be 100% self-sufficient. Relatively easy to handle temporary downtime or new service creation.
  • Docker makes it easy to package up services
  • Kubernetes is a pain to setup, but makes it really easy to deploy + scale services.
  • Create an alias for kubectl: alias k=kubectl

Useful Kubernetes commands

# Print out information about all the running pods
$ kubectl get pods

# Execute the given command in a running pod
$ kubectl eec -it [pod_name] [cmd]

# Print out logs from the given pod
$ kubectl logs [pod_name]

# Delete the given pod
$ kubectl delete pod [pod_name]

# Tell kubernetes to process the configuration
$ kubectl apply -f [config file_name]

# Print useful information about the running pod
$ kubectl describe pod [pod_name]

# Restart a pod. E.g. after having rebuilt and pushed a Docker image to dockerhub
$ kubectl rollout restart [pod_type] [pod_name]
$ kubectl rollout restart deployment posts-depl

microservicescourse's People

Contributors

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