Skip to main content

Posts

Running same command in multiple terminal windows simultaneously (tmux)

You need to install the tool tmux (Terminal Multiplexer). # sudo apt-get update # sudo apt-get install tmux now u can give the command tmux from the terminal. This will open a tmux session . ######################################### Now inside this session u need to login to your first server. ######################################### Now click on the Ctrl + b + " This will split the screen up and down. You need to login to your second server in the second screen. ######################################### Now Enable synchronize-panes by pressing ctrl+b followed by shift+: Next type: "set synchronize-panes on" at the prompt. ######################################### To disable synchronization: set synchronize-panes off Finally  Ctrl + d ,for exiting from the tmux session. check this   link   for more options

How to Remove and add a Node from a K8S cluster.

First login to the Control-plane node where you can list the nodes. 1) Drain the node (Remove from cluster) # kubectl drain <node name> You might have to ignore daemonsets and local-data in the machine # kubectl drain --ignore-daemonsets --delete-local-data 2) Now delete the node # kubectl delete node <node name> Now if you want to add the node again, you might want to re-generate the token of kubeadm join command for adding the worker. Always use the --v=5 along with the kubeadm join command which will show the error description. # kubeadm token create Now use this token for the kubeadm join command , so that you can join the worker node.

Prometheus Alertmanager integration by routing to slack using helm

Setting up Alertmanager and Rules --------------------------------- Now that you have prometheus set up, you need to specify some instructions. The next step is to create a values.yaml file that specifies 1) what the alert rules are, 2) what the Prometheus targets are (i.e the definition of what to scrape and how) and any jobs for Prometheus, and 3) where alerts should be routed to (in this case, Slack). Alert Rules ------------ vi prometheus.values ## Prometheus server ConfigMap entries ## serverFiles:   ## Alerts configuration   ## Ref: https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/   alerts:     groups:       - name: Instances         rules:           - alert: InstanceDown             expr: up == 0             for: 5m             labels:     ...

Prometheus Monitoring Setup in K8s cluster with Grafana for GUI

Prometheus setup ################ Prerequisites: -------------- > PV & PVC setup with NFS. >> https://jinojoseph.blogspot.com/2019/11/persistent-volume-in-k8s-multinode.html > helm setup with tiller. >> https://jinojoseph.blogspot.com/2019/10/setting-up-helm-chart-for-k8s-cluster.html git clone https://github.com/jinojosep/k8s.git cd k8s/prometheus vi 1.6-deployments.yaml Replace the values of NFS_SERVER & NFS_PATH NFS_SERVER : 10.0.1.9 NFS_PATH : /srv/nfs/k8sdata vi 1.6-class.yaml Add the below line in the metadata:   annotations:     storageclass.kubernetes.io/is-default-class: "true"   # ubuntu@namenode:~/myk8syamls/nfs-provisioner$ kubectl create -f rbac.yaml -f 1.6-class.yaml -f 1.6-deployment.yaml serviceaccount/nfs-client-provisioner created clusterrole.rbac.authorization.k8s.io/nfs-client-provisioner-runner created clusterrolebinding.rbac.authorization.k8s.io/run-nfs-client-provisioner created role....

Dockerfile for Java Openjdk / Node Js / Python and many more.

FROM openjdk:8 # Add Maintainer Info LABEL maintainer="jinojoseph@ndimensions.com" # Add a volume pointing to /tmp VOLUME /tmp # The application's jar file ARG JAR_FILE=/home/ubuntu/YourJarFileNOV7.jar # Add the application's jar to the container COPY ${JAR_FILE} app.jar # Run the jar file ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] COPY --from=python:3.6 / / ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn RUN set -e; \      apt-get update; \      apt-get install -y --no-install-recommends \         software-properties-common \     ; \      apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9; \      apt-add-repository 'deb http://repos.azulsystems.com/debian stable main'; \      apt-get update; \      apt-get install -y --no-install-recommends \       ...

Nagios Monitoring Setup

Nagios Setup ############# Pre-requisites Setup: Apache ------ # sudo yum install httpd # sudo systemctl start httpd.service # sudo systemctl status httpd.service # sudo systemctl enable httpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. Take your servers public ip in the browser, and it will show the apache default page: PHP ---- # sudo yum install php php-mysql # sudo systemctl restart httpd.service Now create a file in /var/www/html/info.php vi info.php phpinfo(); ?> http://ip/info.php This will load the php configuration details Nagios ------ Install Build Dependencies in nagios server # sudo yum install gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel xinetd unzip Create Nagios User and Group in nagios server --------------------------------------------- # sudo useradd nagios # sudo groupadd nagcmd # sudo usermod -a -G nagcmd nagios ...

Horizontal Pod Autoscale & Metrics Server installation in K8S

In K8s inorder to create the HPA we just need to give a below kubectl command like below: # kubectl autoscale deployment myapp  --min=1 --max=4 --cpu-percent=80 But this will give a series of errors like below if metrics API is not registered. ######################################## ubuntu@namenode:~$ kubectl get hpa NAME           REFERENCE                 TARGETS         MINPODS   MAXPODS   REPLICAS   AGE myapp   Deployment/myapp   < unknown> /80%   1         4         2          43h ubuntu@namenode:~$ kubectl describe horizontalpodautoscaler.autoscaling/myapp | grep Warning   Warning  FailedComputeMetricsReplicas  32m (x10333 over 43h)   horizontal-pod-autoscaler  invalid metrics (1 inva...