Giter Site home page Giter Site logo

express-k8s's Introduction

Express-K8s

this is a fully featured/functional application involving routing, authentication, database, migrations, testing, docker and k8s deployment.

For those who like to see the bigger picture, this is for you.

Features

Usage

Running the app

make sure you have Nodejs and Yarn installed on your machine.

To install the Dependencies :

$ yarn install

Now to bootstrap the application :

$ yarn dev

And the application will be running on port 3000

Running inside Docker

First, build the image :

$ docker build . -t express-k8s

Second, run the container :

$ docker run -d -p 3000:3000 --name express-k8s-container express-k8s

Or to run with docker-compose :

$ docker compose up app -d

Running Tests

Make sure you first run app either normally or withing docker.

To run the tests, just run:

$ yarn test:dev # watch mode
$ yarn test:ci # run and exit

Using k8s

Make sure you have minikube and k8s installed.

First, build the image with docker.

Second, load the image in minikube:

$ minikube image load express-k8s

Now we can create the configMap, Secret, Service, Ingress and Deployment:

$ kubectl apply -f ./k8s/app-configMap.yaml
$ kubectl apply -f ./k8s/app-secret.yaml
$ kubectl apply -f ./k8s/app-deployment.yaml # will create deploy and svc

To start receiving connections, there are 2 approaches we can follow:

Using the service ( not recommended )

we can utilize kubectl port-forward feature to access the service like so :

$ kubectl port-forward service/express-k8s 3000:3000

Or we could utilize minikube tunneling :

minikube service express-k8s

Using the ingress

First make sure to enable minikube addons for ingress:

$ minikube addon enable ingress
$ minikube addon enable ingress-dns

Second, create the ingress object:

$ kubectl apply -f ./k8s/app-ingress.yaml

Now, our ingress doesn't actually have an external ip that we can go to, so we need minikube to help us in this matter.

Utilizing the tunnel feature of minikube :

$ minikube tunnel

Minikube now offers 127.0.0.1 as an external ip address for the ingress, but there is one step left, we need to add a port mapping for our host expressk8s.com in your hosts file.

You will find this file located under /etc/hosts on MacOs, or under C:\Windows\System32\drivers\etc\hosts on Windows.

Just append this line to the end of the file :

127.0.0.1   expressk8s.com

Now you can go to expressk8s.com/health-check and you will see that the application is healthy ๐Ÿ™‚

Suggesting Features

This project is meant to be community driven mainly, so if you have any suggestions for features, fixes or improvements feal free to file an issue explaining the old behavior and the desired behavior.

Contributing

You can first file a feature request in the issues sections to discuss the feature you want to add, and then you can create a pull request for it.

Please make sure you write unit tests for the code you write and make sure all the tests are passing.

express-k8s's People

Contributors

kareemmahlees avatar

Watchers

 avatar

express-k8s's Issues

Use an ingress infront of the service

Describe the solution you'd like
Using a bare service to access the application is not a good practice, instead, it is better to use an ingress.

Describe alternatives you've considered
using an Nginx-ingress controller in minikube.

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.