Giter Club home page Giter Club logo

distributed-systems's Introduction

Overview

Prepare Docker containers and upload it on DockerHub

  1. Follow the instructions given in https://docs.docker.com/engine/install/ to install docker in your PC/Laptop.

  2. Command to build the docker image. Make sure you are in the same folder/directory of the files

docker image build -t rfernandohub/ob:{tag_name} .
  1. Push your docker image. You need to have an account in https://hub.docker.com/
docker image push rfernandohub/ob:{tag_name}

You can use the docker image I have created for your deployments: https://hub.docker.com/repository/docker/rfernandohub/ob/general

Configure Kubernetes Cluster

  1. Create Kubernetes cluster in Linode and Digital Ocean

  2. Install Kubectl

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

chmod +x kubectl

sudo mv ./kubectl /usr/local/bin/kubectl

kubectl version --client
  1. Apply kubeconfig.yaml file provided by the cloud providers on your PC/Laptop to control Kubernetes
nano do-kubeconfig.yaml
nano linode-kubeconfig.yaml

export KUBECONFIG=do-kubeconfig.yaml
export KUBECONFIG=linode-kubeconfig.yaml
  1. To create a service in your Kubernetes cluster, create a YAML file and apply the file using the following command.
kubectl apply -f rfernandogo_service_do.yaml
  1. How to see the current pods in your Kubernetes Cluster
kubectl get pods
  1. How to see the current services in your Kubernetes Cluster
kubectl get services
  1. How to details about the nodes in your Kubernetes Cluster
kubectl get nodes -o wide
  1. If you need to edit the deployment, you can use the following command
kubectl edit deployment web-deploy

Install NGINX Load Balancer

  1. Log into the ubuntu sever
  1. Update all packages and install NGINX
sudo apt update -y
sudo apt install nginx -y
  1. Edit the default NGINX file
cd /etc/nginx/sites-available
sudo nano default
  1. Remove the existing code and add the following.
upstream myproxy {
    ip_hash;
    server aaa.bb.ccc.dd:8080;
    server eee.ff.ggg.hhh:8080;
}

server {
    listen 80;
    server_name localhost;
    root /var/www/html;

    location / {
        proxy_pass http://myproxy;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
}
  1. Reload the NGINX server
sudo systemctl reload nginx

Install Prometheus and Grafana for monitoring the services

nano {service-provider}-kubeconfig.yaml 
export KUBECONFIG={service-provider}-kubeconfig.yaml

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

  1. Follow the instructions to intall HELM in your Kubernetes Cluster https://helm.sh/docs/intro/install/. You need to make sure your device(PC/Laptop) is connected to the cluster via Kubectl
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null

sudo apt-get install apt-transport-https --yes

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list

sudo apt-get update

sudo apt-get install helm
  1. Add the prometheus-community Repo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
  1. Install Prometheus
helm install prometheus prometheus-community/prometheus
  1. Expose prometheus server as a NodePort to the public
kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-ext
  1. Install Grafna
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm install grafana grafana/grafana
  1. To reveal Grafna username password run the following
kubectl get secret --namespace default grafana -o yaml
  1. To decode the username password you can run the following
echo "{username_string}" | openssl base64 -d ; echo
# Here for example username_string is "YWRtaW4=" and its equals to "admin"
echo "YWRtaW4=" | openssl base64 -d ; echo

# Do the same for password 
echo "{password_string}" | openssl base64 -d ; echo
  1. Expose Grafana server as a NodePort to the public
kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-ext

Normal Prometheus Dashboard: http://172.104.128.242:31161/graph?g0.expr=node_memory_Active_bytes&g0.tab=0&g0.stacked=0&g0.show_exemplars=0&g0.range_input=1h

Grafna Dashboard: http://172.104.128.242:30276/d/k8s_views_ns/kubernetes-views-namespaces?orgId=1&refresh=30s

How to configure APache Kafka

  1. Install Java
sudo apt install default-jre
  1. Install Scala with cs setup (recommended)
sudo apt-get install scala
  1. Install Kafka Make sure it will be same as scala version 2.11.x in your previous step
wget https://archive.apache.org/dist/kafka/2.4.1/kafka_2.11-2.4.1.tgz
  1. Run the following commands in order to start all services in the correct order:
# Start the ZooKeeper service
bin/zookeeper-server-start.sh config/zookeeper.properties

# Start the Kafka broker service
bin/kafka-server-start.sh config/server.properties
  1. To create a topic, Open another terminal session and run:
bin/kafka-topics.sh --create --topic openbaypro --zookeeper localhost:2181 --partitions 1 --replication-factor 1
  1. To see the topic list:
bin/kafka-topics.sh --list --zookeeper localhost:2181
  1. To write events to the topic:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic openbaypro
  1. To read the events published through producer:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic openbaypro --from-beginning

To read and produce events, we can use the Golang sripts in the Kafka folder mentioned in this repo.

distributed-systems's People

Contributors

rfernando-oulu 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.