Posts

Python - Data Science - Mean/Median/Mode

Image
What is a Mean? A mean is the simple mathematical average of a set of two or more numbers. Eg:  The sum of the 57 Boys weight is 231.51 and hence the mean is 231.51/57 = 4.06 What is the Median? The median is the middle number in a sorted, ascending or descending, list of numbers and can be more descriptive of that data set than the average. For example, in a data set of {3, 13, 2, 34, 11, 26, 47}, the sorted order becomes {2, 3, 11, 13, 26, 34, 47}. The median is the number in the middle {2, 3, 11, 13, 26, 34, 47}, which in this instance is 13 since there are three numbers on either side. For example, in a data set of {3, 13, 2, 34, 11, 17, 27, 47}, the sorted order becomes {2, 3, 11, 13, 17, 27, 34, 47}.  The median is the average of the two numbers in the middle which in this case is fifteen {2, 3, 11, 13, 17, 27, 34, 47} -> {(13 + 17) ÷ 2 = 15}. What is a Mode? The is the most frequent observation (or observations) in a sample. We have the sample [4, 1, 2, 2, 3, 5]...

Kubernetes Storage - NFS

Image
  Post shows how to use NFS as Persistent volumes and claim in Kubernetes pod. Setting up NFS Server: Install the NFS package. root@glusterfs:/# apt install -y nfs-server root@glusterfs:/# mkdir /data root@glusterfs:/# cat /etc/exports | grep -v "^#" /data *(rw,no_subtree_check,no_root_squash) root@glusterfs:/# root@glusterfs:/# systemctl status nfs-server root@glusterfs:/# systemctl enable  nfs-server root@glusterfs:/# exportfs -arv exporting *:/data root@glusterfs:/# root@glusterfs:/# chmod -R 777 /data/ We are done with the NFS server and lets mount it on the client. root@master:/# cat /etc/fstab | grep -i data 192.168.163.129:/data /data nfs4 defaults 0 0 root@master:/# You may have to install - nfs-client on the client side. root@master:/# mount -a root@master:/# df -TH /data Filesystem            Type  Size  Used Avail Use% Mounted on 192.168.163.129:/data nfs4   21G  8.5G   11G  44% /data root@ma...

Kubernetes - Volumes

Image
  Persistent volume (PV) is a piece of storage provided by an administrator in a Kubernetes cluster. When a developer needs persistent storage for an application in the cluster, they request that storage by creating a persistent volume claim (PVC) and then mounting the volume to a path in the pod Once that is done, the pod claims any volume that matches its requirements (such as size, access mode, and so on).  An administrator can create multiple PVs with different capacities and configurations.  It is up to the developer to provide a PVC for storage, and then Kubernetes matches a suitable PV with the PVC.  If there is no PV to match the PVC, the StorageClass dynamically creates a PV and binds it to the PVC.  It is important to note that Kubernetes does not restrict PVs to a namespace, which means that a pod in any namespace can claim a PV for storage. I am trying to create a pod with volume. But not creating a volume at first sight.  root@master:/kube# kub...

Kubernetes - Blue/Green Deployment

Image
This deployment is widely used across the companies. Its based on ACTIVE/PASSIVE concept. We are going to create a deployment with the image - rajasekar/node-web-v1 of 3 replicas and bind to a service IP. Next, We are going to create another deployment with the image rajasekar/node-web-v2 and enable this deployment in the service IP - aka IP cutover. Make a note of the labels I am using in the deployment: app: nodejs and version: "1.0" apiVersion: apps/v1 kind: Deployment metadata:   name: node-app-v1   labels:     app: node-app spec:   replicas: 3   selector:     matchLabels:       app: nodejs       version: "1.0"   template:     metadata:       labels:         app: nodejs         version: "1.0"     spec:       containers:       - name: nodejs-v1         image: rajasekar/node-web-v1:latest...

Kubernetes - Building NodeJS Application and deployment - Recreate Strategy

Image
  Now we'll build a simple Node.js web application and package it into a container image.  The application will accept HTTP requests and respond with the hostname of the machine it's running in. root@masterk8s:/kube# mkdir nodejs root@masterk8s:/kube# cd nodejs/ root@masterk8s:/kube/nodejs# vi app.js root@masterk8s:/kube/nodejs# cat app.js const http = require('http'); const os = require('os'); console.log("My server starting and listening on 8080..."); var handler = function(request, response) {   console.log("Received request from " + request.connection.remoteAddress);   response.writeHead(200);   response.end("You've hit " + os.hostname() + "\n"); }; var www = http.createServer(handler); www.listen(8080); root@masterk8s:/kube/nodejs# It starts up an HTTP server on port 8080. The server responds with an HTTP response status code 200 OK and the text "You've hit <hostname>" to every request.  The re...

Kubernetes Pod Priority and Preemption

Image
Pod priority indicates the importance of a pod relative to other pods and queues the pods based on that priority. Pod preemption allows the cluster to evict, or preempt, lower-priority pods so that higher-priority pods can be scheduled if there is no available space on a suitable node Pod priority also affects the scheduling order of pods and out-of-resource eviction ordering on the node. Priority classes can help you control the Kubernetes scheduler decisions to favor higher priority pods over lower priority pods. The Kubernetes scheduler can even preempt (remove) lower priority pods that are running so that pending higher priority pods can be scheduled. By setting pod priority, you can help prevent lower priority workloads from impacting critical workloads in your cluster, especially in cases where the cluster starts to reach its resource capacity. root@masterk8s:~# kubectl describe pod kube-scheduler-masterk8s -n kube-system | grep -i priority Priority:        ...