Posts

Showing posts from July, 2022

Kubernetes Multi Master Cluster

Image
  Post shows how to setup multi master cluster. I setup this using 4 VM's on Ubuntu 20.04. etcd — A highly available key-value store for shared configuration and service discovery. kube-apiserver — Provides the API for Kubernetes orchestration. kube-controller-manager — Enforces Kubernetes services. kube-scheduler — Schedules containers on hosts. kubelet — Processes a container manifest so the containers are launched according to how they are described. kube-proxy — Provides network proxy services. 2 X Master nodes [192.168.163.128, 192.168.163.129] 1 X HAProxy node [192.168.163.130] 1 X Worker node [192.168.163.131] Update /etc/hosts as below across all the nodes. 192.168.163.128 master1 192.168.163.129 master2 192.168.163.130 haproxy 192.168.163.131 worker1 Lets start with HAProxy setup:  We need to deploy an HAPRoxy load balancer in front of them to distribute the traffic. 1) Update and Upgrade. # apt-get update and # apt-get upgrade across all the nodes. 2) Install HAP...

Python Basic Programs

Image
# Total number of odd numbers in list numbers=[ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10 , 11 , 12 , 13 , 14 , 15 , 16 ]; count= 0 ; for i in numbers: if i== 1 : count=count+ 1 ; else : if (i% 2 != 0 ): count=count+ 1 ; print ( "Total odd numbers: " ,count); # Using comprehension odd = [num for num in numbers if num % 2 != 0 ]; print ( "Odd Numbers: " ,odd); # Using lambda odd = list ( filter ( lambda x:x% 2 != 0 , numbers)); print ( "Odd Numbers: " ,odd); --------------------------------------------------------------------- # Remove items from a list while iterating # You need to remove items from a list while iterating but without creating a different copy of a list. # Remove numbers greater than 50 number_list = [ 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 ]; for i in range ( len (number_list)- 1 ,- 1 ,- 1 ): print (i); --------------------------------------------------------------------- # Print the following num...

Kubernetes - Ingress Policy

Image
  Kubernetes provides a resource called NetworkPolicy that allows rules to allow/deny network traffic, which works like a network firewall. By default using this resource doesn't do anything. To make it work, you need first to add a Kubernetes Networking plugin that implements it. Some Kubernetes cluster providers propose their implementation, like GKS and AKS. On the other side, you can use Calico, like recommended by AWS with EKS. I have installed calico network policy agent for the network policy to work. curl https://projectcalico.docs.tigera.io/v3.23/manifests/calico-policy-only.yaml -o calico.yaml kubectl apply -f calico.yaml Lets create a namespace "production". root@master:~# kubectl create ns production namespace/production created root@master:~# Creating a nginx pod under "production" namespace. root@master:~# kubectl run nginx -n production --image nginx --labels app=nginx --expose --port 80 service/nginx created pod/nginx created root@master:~# root@...

Test your skills on Kubernetes

Image
Test your skills on Kubernetes Create a pod name "nginx" with image "nginx" under namespace "website-frontend" Launch 7 replicas of redis image with label app_runtime_stage=test and deployment name "kual00201" and copy the json file to location. Finally cleanup. Create pod as below: - Name: non-persistent-redis - Image: Redis - PV name: app-cache - MountPath: /data/redis - Namespace: staging Volume must not be persistent Create a deployment: name: nginx-test service: nginx-test Ensure the service and pod accessible via respective DNS records. Image: nginx Use "nslookup" to lookup the DNS records of the service and pod and save to a file. Set the node named ek8s-node-0 as unavailable and reschedule all the pods running on it. Investigate the node which is not is in NOT READY state. Configure static pods. Create a PV with name app-data of capacity 2Gi and access mode ReadWriteOnce with hostpath as /srv/app-data. Labe...