Code Monkey home page Code Monkey logo

yelb's Introduction

Why Yelb

When experimenting with new technologies you often follow tutorials that let you deploy purpose-built simple demo application. With Yelb I wanted to make this experience the other way around: start with an existing application and adapt it to the various technologies, services and platforms you are learning. I found this to be way more fun and useful.

This was particularly true as I embarked with the challenge of learning different abstractions available in the cloud:

cloud-abstractions

See this blog post for more information.

Yelb can be deployed (potentially) on each of these abstractions from bare metal (EC2) all the way to Lambda (serverless).

Yelb architecture

The current architecture layout is pretty straightforward.

There is a front-end component called yelb-ui that is responsable for vending the JS code to the browser. This code is compiled from an Angular 2 application. Depending on the deployment model this code can be served from an instance (EC2), from a container (Docker, Kubernetes, ECS) or from an S3 bucket (serverless). The yelb-ui component may also include, depending on the deployment model, an nginx proxy.

At the time of this writing the only application component that exists is yelb-appserver. This is a Sinatra application that basically read and write to a cache server (redis-server) as well as a Postgres backend database (yelb-db). Redis is used to store the number of page views whereas Postgres is used to persist the votes. Note that the yelb-db container image is nothing more than Postgres (10) customized to create the database schema the application relies on. In the serverless deployment, new system variables has been introduced to support a DynamoDB backend (as a replacement for both redis and postgres).

The picture below shows the architecture of Yelb:

yelb-architecture

Note: the picture above is representative of the instance (EC2) based deployment model and the container based deployment model. The serverless deployment model is architecturally different.

What does Yelb do?

Yelb allows users to vote on a set of alternatives (restaurants) and dynamically updates pie charts based on number of votes received. In addition to that Yelb keeps track of number of page views as well as it prints the hostname of the yelb-appserver instance serving the API request upon a vote or a page refresh. This allows an individual to demo the application solo, or involving people (e.g. an audience during a presentation) asking them to interact by pointing their browser to the application (which will increase the page count) and voting their favorite restaurant.

This is how the UI looks like at this point:

yelb-ui

The nature of the app allows people to experiment with the statless yelb-ui and yelb-appserver components (think scaling out, blue/green depoyments, etc.) as well as experiment with the stateful redis-server and yelb-db backend components.

How can I use it?

If you intend to use Yelb as a generic application with the ultimate goal of learning and playing with multiple platforms (from cloud instances, to containers through potentially serverless), then you should probably go straight into the deployments folder and specifically in the platformdeployment folder. This is where all the various configuration files for the various platforms are available. This folder will ideally be a continuous work in progress.

If you intend to contribute, fork or understand anyway how the single components work I suggest you dig into each of them looking at the code (and the various dockerfiles) to learn how they work and how they are packaged. In addition to that you should look into the deployments folder how to start the application in development mode and test mode.

Known issues and limitations

  • There is a subtle issue when you browse the app for the first time where the browser console shows errors. This is likely due to problems with variables not initialized properly. This needs further investigation. The app works just fine and there is no evidence of the problem unless you inspect the page and go to the console outputs.
  • There is a ton of optimization that could be achieved both in the application code as well as in the packaging constructs (e.g. Dockerfiles). The package in its current form works but it is far from being considered optmized. All in all, readability is prioritized over optmization.
  • Idempotency may be a problem. While I am trying to explicitly declare container tags and modules versions moving forward, there is a chance that if you try to build your own containers from the Dockerfile provided and/or install the project on a cloud instance, the output may be diverging from one setup to another. Generic commands such as apt-get update, npm install and gem install sinatra may lead to different versions of code and modules being pulled at build and setup times.
  • The cache instance is still named redis-server (this will be renamed yelb-cache in the future for consistency)
  • While the intent was to build an application whose layers could scale out (and scale independently) in a classic microservices scenario, very little testing has gone into scale out deployment scenarios so far. Most of the tests have been done with one (1) instance of service per layer.

yelb's People

Contributors

alexpulver avatar andskli avatar dependabot[bot] avatar hustshawn avatar jritsema avatar mreferre avatar nichtmonti avatar nomisbeme avatar pescerosso avatar pkilpo avatar tobuck-aws avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yelb's Issues

Kubernetes deployments, yelb-ui fails to stay up

Thanks for sharing this cool project!

I've been trying out the various files under https://github.com/mreferre/yelb/tree/master/deployments/platformdeployment/Kubernetes/yaml

I'm using a Kubernetes cluster in my homelab, plain vanilla K8S on Alpine Linux.

I've been trying the various deployments that should work on a local cluster (not in the cloud) and none of them work. In all tests so far, the UI server fails to stay up.

The logs from the yelb-ui container tell me:
[emerg] 11#11 host not found in upstream "yelb-appserver" in /etc/nginx/conf.d/default.conf:5

It's true, the yelb-appserver container needs a while to startup, but even when it's up the yelb-ui container will say it can't find the appserver.

cnawebapp-minikube-ingress.yaml - Not working

Need to add * after / in ingress config portion of YAML.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: yelb-ui-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: yelb.ing.corp.local
http:
paths:
- path: /*
backend:
serviceName: yelb-ui
servicePort: 80

ECS EC2 Deployment - Cloudformation Time Out error

Hi,

We are deploying the Cloudformation template to deploy yelb in an ECS cluster running on EC2.

The template is timing out at the creation of Services in the cluster for UI, App, Redis and DB.

cfn1

cfndeploy

On checking the ECS cluster we found that there were no Container Instances launched.

containerinstance

Are we missing something in the CFN? Because the 4 services failed due to a lack of container instances.

Could you please help us with this issue.

Thanks

yelb-db docker image failing to pull due to expired cert

Hi.
a docker pull of the yelb-db docker images will fail.

docker pull mreferre/yelb-db:0.5

0.5: Pulling from mreferre/yelb-db
3e17c6eae66c: Pulling fs layer
[...]
e7955dbcd645: Waiting
error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/89/8926f16199a8826c4421c48cd6557881112dbb260838c70c5486b8c6d536f975/data?verify=1577484021-l4Ql8suLKdK%2Fst9EkSO41VIFhek%3D: x509: certificate has expired or is not yet valid

All other docker images like yelb-ui still work.

Cheers.

nginx: host not found in upstream

Hello, I'm going through this tutorial on AWS ECS and I'm at the point where I'm attempting to run docker compose up with the ecs context.

Everything is going well up until it attempts to start the yelb-ui container which results in failure consistently. The error I see in the logs is:

nginx: [emerg] host not found in upstream "yelb-appserver" in /etc/nginx/conf.d/default.conf:5

I've googled around and it seems like the consensus is that it's a startup issue and that yelb-appserver must start before yelb-ui. The solutions suggest to use depends-on, but it would appear that's already being used in the docker-compose.yaml file. I'm not sure what else to do.

Architecture Diagram Visualization

Hi @mreferre,

I’m Afonso and I came across your repo and I took the liberty to scan it with the tool that I am currently developing. If I caught your attention, feel free to take a look at the following diagram and let me know your thoughts on this. I am really interested to get your feedback and understand if the diagram we presented matches the architecture you have in mind.

404 Not Found on UI

Hi,

whatever I tried (also with Ingress vs NodePort), hitting the frontend always throws 404 Not Found. May be I´m using the wrong URI? Any trick I´m missing?

image

platformdeployment on Kubernetes using CDK8s - Kubernetes files not generated

I'm following steps for platformdeployment on Kubernetes using CDK8s using below npm commands

npm install
npm run compile

But I'm not able to get Kubernetes yaml file in the dist folder.

singwvin@3c06304afcb0 cdk8s % npm --version
8.19.2

The steps and logs:

singwvin@3c06304afcb0 cdk8s % npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: "Please update to latest v2.3 or v2.2"
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (debug-js/debug#797)

added 680 packages, and audited 688 packages in 8s

26 packages are looking for funding
run npm fund for details

2 moderate severity vulnerabilities

To address all issues, run:
npm audit fix

Run npm audit for details.
singwvin@3c06304afcb0 cdk8s % npm run compile

[email protected] compile
tsc

singwvin@3c06304afcb0 cdk8s % ls
README.md cdk8s.yaml imports main.d.ts main.test.d.ts main.test.ts node_modules package.json
snapshots help jest.config.js main.js main.test.js main.ts package-lock.json tsconfig.json
singwvin@3c06304afcb0 cdk8s %

Error in deploying to Amazon ECS using the Docker Compose file

Steps followed:

git clone https://github.com/mreferre/yelb 
cd ./yelb/deployments/platformdeployment/Docker/
ls
README.md docker-compose.yaml stack-deploy.yaml

Error

WARNING services.scale: unsupported attribute        
WARNING services.scale: unsupported attribute        
WARNING services.scale: unsupported attribute        
WARNING services.scale: unsupported attribute        
WARNING networks.driver: unsupported attribute   
[+] Running 13/13
 ⠿ docker                          DeleteComplete                                                                                                                                      95.1s
 ⠿ RedisserverTaskExecutionRole    DeleteComplete                                                                                                                                      15.1s
 ⠿ Cluster                         DeleteComplete                                                                                                                                      15.1s
 ⠿ YelbuiTaskExecutionRole         DeleteComplete                                                                                                                                      15.1s
 ⠿ YelbnetworkNetwork              DeleteComplete                                                                                                                                      15.0s
 ⠿ CloudMap                        DeleteComplete                                                                                                                                      90.1s
 ⠿ YelbuiTCP80TargetGroup          DeleteComplete                                                                                                                                      14.0s
 ⠿ LogGroup                        DeleteComplete                                                                                                                                      14.0s
 ⠿ YelbdbTaskExecutionRole         DeleteComplete                                                                                                                                      14.0s
 ⠿ YelbappserverTaskExecutionRole  DeleteComplete                                                                                                                                      14.0s
 ⠿ YelbnetworkNetworkIngress       DeleteComplete                                                                                                                                       7.0s
 ⠿ LoadBalancer                    DeleteComplete                                                                                                                                       7.0s
 ⠿ Yelbnetwork80Ingress            DeleteComplete                                                                                                                                       7.0s
A load balancer cannot be attached to multiple subnets in the same Availability Zone (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: InvalidConfigurationRequest; Request ID: 09fda1ca-a71b-4c98-9ed1-0cb0cbbc7ee5; Proxy: null)

Deployment version is out of date

When running helm install I received this error:

Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "Deployment" in version "extensions/v1beta1"

Upon changing the version to "apps/v1", I then received the error:

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec): missing required field "selector" in io.k8s.api.apps.v1.DeploymentSpec

I updated the Deployment spec with selector as such:

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "yelb.fullname" . }}-cache
spec:
selector:
matchLabels:
app: {{ template "yelb.fullname" . }}
replicas: {{ .Values.replicaCount }}
--- etc ---

Then I was able to successfully deploy the chart

Error in starting yelb-db_1 container

It gives error:

yelb-db_1 | runtime: failed to create new OS thread (have 2 already; errno=22)
yelb-db_1 | fatal error: newosproc

I'm running on "localtest" deployment using docker-compose. My local environment is MacOS Monterey version 12.6 Chip: Apple M1.

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.