-
Follow the instructions given in https://docs.docker.com/engine/install/ to install docker in your PC/Laptop.
-
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} .
- 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
-
Create Kubernetes cluster in Linode and Digital Ocean
-
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
- 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
- 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
- How to see the current pods in your Kubernetes Cluster
kubectl get pods
- How to see the current services in your Kubernetes Cluster
kubectl get services
- How to details about the nodes in your Kubernetes Cluster
kubectl get nodes -o wide
- If you need to edit the deployment, you can use the following command
kubectl edit deployment web-deploy
- Log into the ubuntu sever
- Update all packages and install NGINX
sudo apt update -y
sudo apt install nginx -y
- Edit the default NGINX file
cd /etc/nginx/sites-available
sudo nano default
- 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;
}
}
- Reload the NGINX server
sudo systemctl reload nginx
nano {service-provider}-kubeconfig.yaml
export KUBECONFIG={service-provider}-kubeconfig.yaml
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
- 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
- Add the prometheus-community Repo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
- Install Prometheus
helm install prometheus prometheus-community/prometheus
- Expose prometheus server as a NodePort to the public
kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-ext
- Install Grafna
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm install grafana grafana/grafana
- To reveal Grafna username password run the following
kubectl get secret --namespace default grafana -o yaml
- 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
- 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
- Install Java
sudo apt install default-jre
- Install Scala with cs setup (recommended)
sudo apt-get install scala
- 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
- 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
- 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
- To see the topic list:
bin/kafka-topics.sh --list --zookeeper localhost:2181
- To write events to the topic:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic openbaypro
- 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.