Thursday, 14 August 2025

Learning Kubernetes(k8s)

What is Kubernetes?

Kubernetes (often abbreviated as K8s) is an open-source platform for managing large-scale containerized applications. It automates container deployment, scaling, and operations across clusters of machines. It's written in Go.
It's inspired by the Google project: Boorg.

An instance of Kubernetes is called a Cluster.
Cluster has :
  • Control plane
    • kube-apiserver
      •  The kube-apiserver is a key component of Kubernetes that exposes the Kubernetes API, handles most requests, and manages interactions with the cluster by processing and validating API requests, making it essential for the cluster's operation
    • etcd
      • A key-value store that saves all data about the state of the cluster; only the kube-apiserver can communicate directly with etcd
    • kube-scheduler
      • Identifies a newly created pod that has not been assigned a worker node and assigns it to a specific node
    • kube-controller-manager
      • Monitors the Kubernetes cluster's state, running processes to ensure the current state matches the desired state
    • cloud-controller-manager
      • Connects a Kubernetes cluster to a cloud provider's API, managing cloud-specific resources and ensuring proper integration with the underlying infrastructure
  • Worker Node
    • kubelet
      • An agent that runs on each node in a Kubernetes cluster, ensuring containers in a pod are running and healthy while communicating with the API server in the control plane to maintain the desired state of the node
    • container-runtime
      •  Pulls container images, creates and manages containers, and ensures they run properly and securely as directed by the Kubernetes control plane
    • kube-proxy
      •  A network proxy that runs on each node in a Kubernetes cluster, maintaining network rules and enabling communication between pods and services within the node and the control plane, while also communicating directly with the kube-apiserver


Brief about Containers:

Containers are a lightweight, portable way to package and run applications. They bundle your application along with everything it needs—like libraries, dependencies, and configuration—so it runs reliably in any environment.

Containers terminology:

Image: A container image is a snapshot of everything needed to run a containerized application. It’s like a blueprint or a frozen package that contains:

Container Registry: A container registry is a storage and distribution system for container images.
eg, Docker Hub, quay, Google Container Registry

Advantages of Containers:

  • Portable: Runs on any Linux, Windows or macOS machine
  • Use fewer CPUs and memory, saving money.
  • Self-contained, can be spun up and down in seconds
  • Quick replication and scale up and down.

Cloud-native:

Cloud Native is a modern approach to building and running applications that fully leverages the advantages of the cloud, such as scalability, flexibility, and resilience.


Setting up a K8s cluster

  1. Install Docker (or any container engine): Helps to spin up a Kubernetes cluster.
  2. Install minikube: Software that helps us run a Kubernetes cluster on our computer. it runs locally on the computer.

Spin up a minikube cluster

  • Make sure Docker/Podman is running
  • $ minikube start [create a cluster]

Explore the cluster

  • $ kubectl cluster-info
  • $ kubectl get nodes
  • $ kubectl get namespaces
  • $ kubectl get pods -A
  • $ kubectl get services -A

Application Deployment

Creating namespaces:

Namespaces help in isolating apps.
---
apiVersion: v1
kind: Namespace
metadata:
    name: demo
  • $ kubectl apply -f namespace.yaml
  • $kubectl get namespaces or kubectl get ns
  • $ kubectl delete -f namespace.yaml

Deploying an app

  • $ kubectl apply -f <yaml file>
  • $ kubectl get deployments -n demo
  • $ kubectl get pods -n demo

Check the health of the pod using event logs

  • $ kubectl describe pod <pod name> -n demo

Making sure the app is running fine using BusyBox

  • Create  a Busybox pod
  • $ kubectl apply -f busybox.yaml   #creating a busybox pod in the default namespace
  • $ kubectl get pods   # checking busybox pod is up and running
  • $ kubectl get pods -n demo -o wide  # get the IP address of the pods
  • $ kubectl exec -it <busy box pod name> -- /bin/sh  #we are in busybox command prompt 
  • /# wget <IP address of pod: Port>
  • /#exit     #exit out of busybox

Viewing application logs

  • $ kubectl logs <pod_name> -n demo

Types of service

  • ClusterIP
  • NodePort
  • LoadBalancer

Exposing the application to the internet 

A Kubernetes Service is an abstraction that exposes a set of Pods as a network service. It allows other Pods or external clients to communicate with them, even as Pods are created or destroyed.
A load balancer directs traffic from the internet to k8s pods. 

Running a stateful application
  • Using a database outside your cluster
  • Using a Kubernetes Persistent Volume

Deleting k8s resources

  • $ kubectl delete -f <yaml file>
  • $ minikube delete

Kubernetes Security

  • Adding some security context
    • Containers are running as non-root
    • The container's filesystem is read-only
  • Scan your file using Snyk
    • snyck iac test <yaml file>
    • Regularly update your k8s version







Friday, 27 June 2025

Teach Your AI New Tricks with InstructLab


 InstructLab is an open-source toolkit and workflow designed to fine-tune foundation models using a community-driven, taxonomy-based process.

 It enables experts—even those unfamiliar with ML—to contribute small “skill recipes” that enhance a model’s knowledge base.


How does it work?

  1. Install the CLI tool(ilab)
    1. pip install instructlab
  2. Initialize a project
    1. ilab config init  > It sets up a taxonomy repo and configuration.
  3. Download a base model
    1. ilab model download > such as IBM granite or Merlinite
    2. It downloads pre-trained models from HuggingFace
  4. List the downloaded model
    1. ilab model list
  5. Serve the model
    1. ilab model serve
  6. Chat with the model
    1. ilab model chat

Contribute knowledge

  1. Create skills via recipes 
    1. Add examples(question and answer: YAML format), 
  2. Add and validate your new data.
    1. ilab taxonomy diff
  3. Run synthetic data generation.
    1. ilab data generate
  4. Train or fine tune the model 
    1. ilab model train --pipeline=simple
  5. Serve the trained model
    1. ilab lodel serve --model-path <path>
  6. Chat with the model
    1. ilab model chat --model <model>
  7. Submit recipes as pull requests.


Understanding the Basics of Artificial Intelligence

 What exactly AI is and why everyone is talking about it.

Artificial intelligence, or AI, has now become a part of our daily lives, and many of us are not aware of that. It's working behind the scenes, quietly and efficiently. Few examples are: phone unlocking with facial recognition, a chatbot helping you book a flight, or Netflix suggesting your next favorite show.

What is Artificial Intelligence?

In simple terms, Artificial Intelligence refers to machines or software that mimic human intelligence. A machine can learn patterns and make predictions. AI does not replace human decision-making; instead, it adds value to human judgment.


Types of AI:

  • Narrow AI(Weak AI)
    •  AI is designed for a specific task.  eg, Siri, Google Maps, facial recognition
  • General AI (Strong AI)
    • AI that can understand, learn, and apply knowledge across a wide range of tasks, like humans. eg, Meta AI, GPT4
  • Super AI(AGI and ASI)
    • Hypothetical AI that surpasses human intelligence in all aspects. A future concept, not yet developed.

How does AI work?

AI systems are built using techniques like:
  • Machine Learning:
    • ML is a subset of AI that provides machines the ability to automatically learn and improve from experience without being explicitly programmed. Types of ML:
      • Supervised Learning
      • Unsupervised Learning
      • Reinforcement Learning
  • Deep Learning
    • A type of ML that mimics the human brain's network(neural network)
  • Natural Language Processing
    • Helps the computer understand human language.

Why AI Matters?

AI has the power to transform industries, improve efficiency, and solve global problems- from climate modeling to personalized education.

As AI continues to evolve, it will become even more integrated into our lives. The key is to use it responsibly. ensuring that it benefits society as a whole.



Monday, 27 May 2024

Shell Scripting

 What is Shell?

Shell allows a user to interact with kernel and provide an environment to execute commands.

Types of Shell

  • bash
  • sh
  • ksh
  • tsh
  • fish
  • zsh
How to check your default shell?

poyadav@fedora:~$ echo $0
bash

What is shell scripting?
We can use shell scripting to automate tasks, it contains a set of commands to perform a task which are executed sequencially.

What is shebang?
#!/bin/bash 
It tell our system to use bash for executing the script.

How to execute as bash script?
  • ./file.sh    #Make sure file has execute command (chmod +x file.sh)
  • /path/file.sh  #Make sure file has execute command
  • bash file.sh
Variables
var=hello
var=$(command)
readonly var=value

Arrays
myarray=(1 2 3 "hello" "hii")   #contains space seperated values
echo "${myarray[2]}   #getting 3rd value
echo "${myarray[*]}   #gatiing all values
echo "${myarray[*]:2} #getting specific values

array+=(bye tata)  #adding new values

Key-Value arrays
declare -A myarray
myarray=( [name]=Henry [age]=23 ) 
echo "${myarray[name]}"

Strings Operations
myvar="Hello, how are you?"
length=${#myvar}
upper=${myvar^^}
lower=${myvar,,}
replace=${myvar/Hello/Hey}
slice=${myvar:2:5}

Getting input from user
echo -n "What is your name? "
read name
echo "Your name is $name"

read -p "What is your age? " age
echo "Your age is $age"

Arithmetic Operations
let a++
let a=6*10

((a++))
((a=6*10))


if-else 
if [ condition ];then
echo "PASS"
else
echo "FAIL"
fi

case
echo "where you want to go"
echo "a=Paris"
echo "b=London"
echo "c=USA"

read choice

case $choice in
a) echo "Going to Paris";;
b) echo "Going to London";;
c) echo "Going to USA";;
*) echo "Not going anywhere"
esac

Logical Operators
#Both conditions need to be true/met
if [[ condition1 ]] && [[ condition2 ]];then
echo "PASS"
else
echo "FAIL"
fi

#only one condition need to be true
if [[ condition1 ]] || [[ condition2 ]];then
echo "PASS"
else
echo "FAIL"

for Loop
for i in 1 2 3 4 5
do
echo i
done
#or we can also use
for i in Apple banana grapes
for i in {1..10}

#for loop with file
file=array.sh
for i in $(cat $file);do
echo $i
done

#or we can also use
for ((i=0;i<10;i++))
do
echo "Hello $i"
done

while Loop

#syntaX
count=0
num=10

while [ $count -lt $num ];do
echo "value is $count"
(( count++ ))
done

#reading from file
while read myvar;do
echo $myvar
done < myfile

#while with csv file
while IFS="," read id name age
do
echo "id is $id"
echo "name i $name"
echo "age is $age"
done < file.csv

Infinite Loop

while true;do
echo "Hey"
done
#for infinite loop
for (( ;; ));do
echo "Hey'
done

Functions

fun() {
echo "hello"
}
#another way
function myfun {
echo "Hey"
}

#function with args
myarg() {
echo "Hello $1"
echo "Welcome to $2"
}

fun
myfun
myarg raju manali
























Wednesday, 9 August 2023

SSH (Secure Shell)

 What is ssh?

SSH is a network protocol by which two machines can communicate with each other, we can transfer information or data from client and server in a secure way.

It uses encryption to secure the data that travel over the network to secure it.


Use of ssh:

We can access a remote machine using ssh over the same network.

Command: ssh <user>@<ip>  eg: ssh root@10.65.34.20

Now there are two types of authentication methods that we can use :

  1. Password-based authentication
  2. Key-based authentication
  • In Password-based authentication, we need the password of the host to access it.
  • In key-based authentication, we need keys on the machines ie private and public keys.

How to generate keys.

Command: ssh-keygen 

It generates two keys private key(id_rsa) and public key(id_rsa.pub) at ~/.ssh/

  • Private is private to our local machine, this should never be shared with others.
  • Public key can be shared with other servers/machines. We can copy our public key to a host/server using ssh-copy-id <user>@<ip> or if we can access the UI of the server, we can even upload it there as in GitLab, GitHub. 
The public keys are copied at  ~/.ssh/authorized_host on the server side. When we have our public key shared with the server, we don't need the password to access it, it will be passwordless login from the client. Authentication will be done on the key pair which we added earlier. 

 




Tuesday, 27 August 2019

Flock-2019


Flock is the Fedora Project's annual contributor-focused conference. I attended Flock-2019 which was in Budapest this time. I feel great to be a part of this conference and community. It was four day conference with lots of interesting sessions.


Day 1
First day started with "The State of Fedora" session by Matthew Miller where he discussed about Fedora current and future state. Then Cate Huston presented a very interesting talk on how we can make a great and successful team. She shared interesting facts to make failing team functional. It was good to see "Facebook Loves Fedora" and Facebook employees are using it. In this they shared their experience and challenges faced. After lunch I attended "The future of langpacks in Fedora", it was a great discussion on langpacks. In evening I attended Fedora CI by David and  Tim Flink and Getting started with Fedora QA by Suprith Gangawar and Geoffrey Marr. Day 1 ended with Slideshow Karaoke organised by Amita and Adam Samalik.

                                 

Day 2
On second day, I attended the talk by Denise Dumas on "Fedora, Red Hat and IBM. Then I mostly attended the talks around Fedora CI and gating. Also attended session on "Use cases for Transtats in the Fedora Community". It was a day well spent with so much information on Continuous Integration. Then in the evening we enjoyed the River Cruise with Dinner.


Day 3
Third day started with the showcasing of Fedora Summer Coding 2019 projects where Summer Coding interns talked about their  projects, learning and experiences. Same day we have our Fedora internationalization hack fest where we discussed about how we can increase CI for Fedora i18n packages and did some brainstorming for future release. It was very helpful for me as I got ideas about the high priority packages and how we can contribute more to CI.


Also, I was a part of Fedora Diversity and Inclusion Hack fest which was just after i18n hack fest, so after that I quickly moved to D&I hack fest room where we worked and discussed on some pending tickets and took the action items from those. Also planned for the future elections for next Diversity Advisor. Then in the end there was a walking tour planned around Budapest where we visited some tourist attraction points and learnt some facts about the history of Budapest.


Day 4
On Day 4, I attended the Wrap-Up session and collaborated with people and had some good discussions. This was the last day, most of us were already leaving so there were good byes, future planning etc.

Overall, it was a great experience, as being a part of community it felt good to be meet people and talk to them. It was good to see so many talks about CI and gating and I attended most of them, as I myself is starting to contribute to CI and gating, so these sessions were very helpful and informative.

Below are few pics clicked while different activities in Flock :)


                                 



Friday, 21 June 2019

Fedora Pune Meetup


Last Saturday(June,15) , we had Fedora Pune Meetup with Fedora-30 release celebration. When I reached the venue, people were already present there and were ready to start the event. We started according to the agenda with our first talk from Pravin Satpute on Fedora-30 features which was great, as people were really interested in knowing the new features added.



After that Parag delivered a talk on Modularity. He covered the basics and also covered some examples to make the concept more clear. We had had good discussions around this topic as question were coming in between from the audience. After such a technical discussion a break was really needed. So we went for a short break to grab some snacks.




Then, there was a talk on Fedora CoreOS by Praveen Kumar after the break with a disclaimer that he is only the presenter, slides are prepared by Sinny Kumari. It was a great session with demo and a lot of interactions among attendees. After his session Kushal quickly discussed about QubeOS which was new to me and also interesting. Then we ended the event with Cake cutting to celebrate the release of Fedora-30.