Skip to content

aa-tt/weather-prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weather-prediction

Execution

Open in Gitpod

or,

  1. Git Clone this repo.
  2. Execute below docker-compose command wait for images to be pulled, build and started.
  3. Open http://localhost for app.
  4. Open http://localhost:8080/swagger-ui/index.html for swagger.
docker-compose -f docker-compose-dev.yml up

OR

Setup (to run locally in say IntelliJ)

  • The project in directory ./weather-prediction-api is the gradle project and implements API in springboot and Kotlin
  • While importing the project in Intellij, select build.gradle and open as project
  • Set Project JDK to Java 17 by opening Module Settings for the project
  • Use clean, build and then bootRun options build and application tasks in the Gradle tool window
  • Alternatively ./gradlew clean build bootRun can be used

Docker

The images build in the project are build and published at https://hub.docker.com/repositories/ianunay. For example, api published with tag v0 and image name ianunay/weather-app-api

> docker build -t ianunay/weather-app-api:v0 -f Dockerfile-api .
> docker push ianunay/weather-app-api:v0

Kubernetes

eksctl - for AWS EKS cluster

eksctl create cluster --name eks-weather-cluster-0 --region us-west-2 --nodegroup-name standard-workers --node-type t3.small --nodes 1 --nodes-min 0 --nodes-max 1 --managed
kubectl apply -f eks-weather-app.yaml
kubectl get service nginx -n eks-weather-app -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'

http://a96a52c8094de46d78688c6d5008e893-149566309.us-west-2.elb.amazonaws.com

Route 53

To access the service using a domain name, create a hosted zone in Route 53 and create an A record with the load balancer DNS name. http://myday.outorin.com or http://44.228.245.169

aws route53 change-resource-record-sets --hosted-zone-id <hosted-zone-id> --change-batch '{
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "myday.outorin.io",
        "Type": "A",
        "AliasTarget": {
          "HostedZoneId": "Z35SXDOTRQ7X7K",  // Hosted zone ID for ELB in us-west-2
          "DNSName": "dualstack.a96a52c8094de46d78688c6d5008e893-149566309.us-west-2.elb.amazonaws.com.",
          "EvaluateTargetHealth": false
        }
      }
    }
  ]
}'

Scale down EKS cluster to 0 node for cost saving and scale up later for bringing up the service

eksctl scale nodegroup --cluster=eks-weather-cluster-0 --name=standard-workers --nodes=0
kubectl get nodes
eksctl scale nodegroup --cluster=eks-weather-cluster-0 --name=standard-workers --nodes=1
kubectl get nodes

Kind - Kubernetes in Docker for single node K8S cluster and local development

kind create cluster --name weather-cluster
kubectl cluster-info --context kind-weather-cluster
kubectl apply -f kubernetes-dashboard.yaml
kubectl port-forward service/nginx 30080:80 -n kind-weather-app

http://localhost:30080

Kompose - deploy a sample docker-compose yaml file to a Kubernetes cluster.

brew install kompose

# Convert your Docker Compose file to Kubernetes:
kompose convert -f docker-compose-k8s.yml

Microk8s - for kubernetes cluster

brew install ubuntu/microk8s/microk8s
microk8s install
microk8s status --wait-ready
microk8s enable dashboard dns istio storage
microk8s kubectl
alias k='microk8s.kubectl'
microk8s dashboard-proxy
microk8s kubectl apply -f .

microk8s kubectl delete -n default deployment ui consul redis-cache-weather-prediction nginx api
microk8s kubectl delete -n default persistentvolumeclaim consul-claim0 redis-cache-weather-prediction-claim0
microk8s kubectl delete -n default service api consul nginx redis-cache-weather-prediction ui kubernetes

Minikube - for kubernetes cluster

minikube start
minikube kubectl -- get po -A
minikube dashboard

minikube kubectl -- delete -n default service api consul nginx ui redis-cache-weather-prediction

kubectl

kubectl create deployment wapp-ui --image=ianunay/weather-app-ui:v0
kubectl expose deployment wapp-ui --type=LoadBalancer --port=5001
kubectl port-forward service/wapp-ui 5001:5001

kubectl create deployment wapp-redis --image=redis
kubectl expose deployment wapp-redis --type=LoadBalancer --port=6379
kubectl port-forward service/wapp-redis 6379:6379

kubectl create deployment wapp-ssm --image=ianunay/weather-app-ssm:v0
kubectl expose deployment wapp-ssm --type=LoadBalancer --port=8500
kubectl port-forward service/wapp-ssm 8500:8500

kubectl create deployment wapp-api --image=ianunay/weather-app-api:v0
kubectl expose deployment wapp-api --type=LoadBalancer --port=8080
kubectl port-forward service/wapp-api 8080:8080

API (microservice in springboot and kotlin-jvm)

  • The api runs at port 8080
  • The api doc can be seen at http://localhost:8080/swagger-ui/index.html

UI (microfrontend in react 16 (functional components and react hooks) )

  • The UI that consumes this API is located in directory ./weather-prediction-ui
  • The UI can be started following the commands
    > cd ./weather-prediction-ui
    > npm install
    > npm start
  • The UI in react runs at port 5001

Caching

Caching is done using redis server running in docker The cached keys can be checked by login to redis-cli

    > redis-cli
    127.0.0.1:6379> keys *

todos

  • security
  • logging
  • controller advice for error responses
  • caching Done
  • unit test for tdd Done
  • integratuon test for bdd Done
  • docker-compose and jenkins script Done

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published