Git Product home page Git Product logo

kotlin-full-stack-example's Introduction

Sample full stack ToDo application in Kotlin

Can be easily packaged into Helm chart and ready to be deployed into Kubernetes cluster.

Backend: ktor, exposed

Frontend: kotlin-react, kotlin-js-wrappers

Deployment: docker, helm, kubernetes

Build and deploy using minikube

All the commands below use FISH shell syntax on macOS

Build project and docker image

$ ./gradlew build

$ docker build -t todoapp:v0.0.3 .

(Optionally) Run inside minikube's VM

$ eval (minikube docker-env)

$ docker run -m512M --cpus 2 -it -p 9090:9090 --rm todoapp:v0.0.1

$ open http://(minikube ip):9090/

Install helm

$ brew install helm

$ helm init

Deploy application into Kubernetes cluster (minikube)

Use helm to install.

  • Update dependencies (copy PostgreSQL chart into charts)

$ helm update dependencies helm-chart/todoapp

  • Package chart into archive

$ helm package helm-chart/todoapp

  • Install package into Kubernetes

$ helm install todoapp-0.0.3.tgz

  • Setup port forwarding using command provided in helm install output. Something similar to:
  export SERVICE_NAME=(kubectl get service --namespace default -l "app=todoapp,release=geared-marmot" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward svc/$SERVICE_NAME 8080:9090

Check if replication is working as expected

  • Kill one or both pods

$ kubectl delete pod <app-pod-id>

  • Check if new instance is automatically deployed

$ kubectl get pods

  • Check if DB and data is still there from UI

Useful debugging commands

Get status of helm installation

$ helm status <installation-name>

List helm installations

$ helm list

Delete helm installation

$ helm delete <installation-name>

List kubernetes pods

$ kubectl get pods

Get logs from the pod

$ kubectl logs <pod>

TODOs

  • Tests
  • LoadBalancer in front of app pods
  • Improve styling of Web UI
  • Check if kotlin multiplatform project will allow for better code reuse between backend and frontend
  • Minify JS in production build
  • Do not used development server in production build
  • Gradle build scripts to build docker image and helm package

kotlin-full-stack-example's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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