Friday, July 26, 2024

Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117

Friday, July 19, 2024

Minikube Setup on AWS EC2 instance

Create AWS EC2 instance and execute below commands as a root.

Instance Type: t2.medium

     1  yum update -y

    2  yum install docker -y

    3  systemctl enable docker

    4  systemctl start docker

    5  docker ps

    6   curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

    7   chmod +x ./kubectl

    8   sudo mv ./kubectl /usr/local/bin/kubectl

    9  kubectl

    10  curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

    11  sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64

    12  ls -lrt

    13  minikube

    14  minikube start --force --driver=docker

    [root@ip-172-31-29-80 ~]# kubectl run mywebapp --image=nginx

    pod/mywebapp created

Thursday, July 4, 2024

DevOps GitHub Repo gfg

 DevOps Basic:

https://github.com/mathesh-me/gfg-devops/tree/main

Ansible:

https://github.com/mathesh-me/ansible-study-guide

Jenkins:

https://github.com/mathesh-me/jenkins-learning/tree/main

Docker:

https://github.com/mathesh-me/docker-learning

K8s:

https://github.com/mathesh-me/cka-prep-documentation


Best Youtube Course: https://www.youtube.com/@AbhishekVeeramalla

Git Commands

 1. 𝗴𝗶𝘁 𝗶𝗻𝗶𝘁: Initializes a new Git repository in the current directory.

2. 𝗴𝗶𝘁 𝗰𝗹𝗼𝗻𝗲 [𝘂𝗿𝗹]: Clones a repository into a new directory.

3. 𝗴𝗶𝘁 𝗮𝗱𝗱 [𝗳𝗶𝗹𝗲]: Adds a file or changes in a file to the staging area.

4. 𝗴𝗶𝘁 𝗰𝗼𝗺𝗺𝗶𝘁 -𝗺 "[𝗺𝗲𝘀𝘀𝗮𝗴𝗲]": Records changes to the repository with a descriptive message.

5. 𝗴𝗶𝘁 𝗽𝘂𝘀𝗵: Uploads local repository content to a remote repository.

6. 𝗴𝗶𝘁 𝗽𝘂𝗹𝗹: Fetches changes from the remote repository and merges them into the local branch.

7. 𝗴𝗶𝘁 𝘀𝘁𝗮𝘁𝘂𝘀: Displays the status of the working directory and staging area.

8. 𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵: Lists all local branches in the current repository.

9. 𝗴𝗶𝘁 𝗰𝗵𝗲𝗰𝗸𝗼𝘂𝘁 [𝗯𝗿𝗮𝗻𝗰𝗵]: Switches to the specified branch.

10. 𝗴𝗶𝘁 𝗺𝗲𝗿𝗴𝗲 [𝗯𝗿𝗮𝗻𝗰𝗵]: Merges the specified branch's history into the current branch.

11. 𝗴𝗶𝘁 𝗿𝗲𝗺𝗼𝘁𝗲 -𝘃: Lists the remote repositories along with their URLs.

12. 𝗴𝗶𝘁 𝗹𝗼𝗴: Displays commit logs.

13. 𝗴𝗶𝘁 𝗿𝗲𝘀𝗲𝘁 [𝗳𝗶𝗹𝗲]: Unstages the file, but preserves its contents.

14. 𝗴𝗶𝘁 𝗿𝗺 [𝗳𝗶𝗹𝗲]: Deletes the file from the working directory and stages the deletion.

15. 𝗴𝗶𝘁 𝘀𝘁𝗮𝘀𝗵: Temporarily shelves (or stashes) changes that haven't been committed.

16. 𝗴𝗶𝘁 𝘁𝗮𝗴 [𝘁𝗮𝗴𝗻𝗮𝗺𝗲]: Creates a lightweight tag pointing to the current commit.

17. 𝗴𝗶𝘁 𝗳𝗲𝘁𝗰𝗵 [𝗿𝗲𝗺𝗼𝘁𝗲]: Downloads objects and refs from another repository.

18. 𝗴𝗶𝘁 𝗺𝗲𝗿𝗴𝗲 --𝗮𝗯𝗼𝗿𝘁: Aborts the current conflict resolution process, and tries to reconstruct the pre-merge state.

19. 𝗴𝗶𝘁 𝗿𝗲𝗯𝗮𝘀𝗲 [𝗯𝗿𝗮𝗻𝗰𝗵]: Reapplies commits on top of another base tip, often used to integrate changes from one branch onto another cleanly.

20. 𝗴𝗶𝘁 𝗰𝗼𝗻𝗳𝗶𝗴 --𝗴𝗹𝗼𝗯𝗮𝗹 𝘂𝘀𝗲𝗿.𝗻𝗮𝗺𝗲 "[𝗻𝗮𝗺𝗲]" 𝗮𝗻𝗱 𝗴𝗶𝘁 𝗰𝗼𝗻𝗳𝗶𝗴 --𝗴𝗹𝗼𝗯𝗮𝗹 𝘂𝘀𝗲𝗿.𝗲𝗺𝗮𝗶𝗹 "[𝗲𝗺𝗮𝗶𝗹]": Sets the name and email to be used with your commits.

21. 𝗴𝗶𝘁 𝗱𝗶𝗳𝗳: Shows changes between commits, commit and working tree, etc.

22. 𝗴𝗶𝘁 𝗿𝗲𝗺𝗼𝘁𝗲 𝗮𝗱𝗱 [𝗻𝗮𝗺𝗲] [𝘂𝗿𝗹]: Adds a new remote repository.

23. 𝗴𝗶𝘁 𝗿𝗲𝗺𝗼𝘁𝗲 𝗿𝗲𝗺𝗼𝘃𝗲 [𝗻𝗮𝗺𝗲]: Removes a remote repository.

24. 𝗴𝗶𝘁 𝗰𝗵𝗲𝗰𝗸𝗼𝘂𝘁 -𝗯 [𝗯𝗿𝗮𝗻𝗰𝗵]: Creates a new branch and switches to it.

25. 𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵 -𝗱 [𝗯𝗿𝗮𝗻𝗰𝗵]: Deletes the specified branch.

26. 𝗴𝗶𝘁 𝗽𝘂𝘀𝗵 --𝘁𝗮𝗴𝘀: Pushes all tags to the remote repository.

27. 𝗴𝗶𝘁 𝗰𝗵𝗲𝗿𝗿𝘆-𝗽𝗶𝗰𝗸 [𝗰𝗼𝗺𝗺𝗶𝘁]: Picks a commit from another branch and applies it to the current branch.

28. 𝗴𝗶𝘁 𝗳𝗲𝘁𝗰𝗵 --𝗽𝗿𝘂𝗻𝗲: Prunes remote tracking branches no longer on the remote.

29. 𝗴𝗶𝘁 𝗰𝗹𝗲𝗮𝗻 -𝗱𝗳: Removes untracked files and directories from the working directory.

Monday, June 17, 2024

Linux Troubleshooting

 

 https://github.com/mismailzz/Linux-Troubleshooting-Scenarios-with-solutions

 

Section 1 - System Access Troubleshooting

•        Server is Not Reachable

•        Cannot Connect to a Website or an Application

•        Cannot SSH as root or a Specific User

•        Firewall Issue

•        Terminal Client is not working

•        Cannot Connect using Putty to a VirutalBox VM

 

Section 2 - FileSystem Troubleshooting

•        Cannot cd into a Directory

•        Cannot Open a File or Run a Script

•        Having Trouble Finding Files and Directories

•        Cannot Create Links

•        Cannot Write to a File

•        Cannot Delete, Copy, Move or Rename a File

•        Cannot Change File Permissions or View Other Users Files

•        Disk Space Full or Add More Disk Space

•        Add Disk and Create Standard Partition

•        Add Disk and Create Standard Partition

•        Add Disk and Create LVM Partition

•        Extend Disk with LVM

•        How to Delete Old Files

•        FileSystem is Corruption

•        Corruption in /etc/fstab

•        Script to Delete Old Files

•        Handouts

 

Section 3- System Administration Troubleshooting

•        Running Out of Memory

•        Add Swap Space

•        System Rebooted or Process Restarted

•        Unable to get IP Address

•        IP Assigned but not Reachable

•        Having Trouble using vi Editor

•        Cannot Run Certain Commands

•        Cannot Change Password

•        User Account has no Home Directory

•        How to Change Every Instance of a Word in a File

•        How to Use sed Command

•        How to Kill a User Terminal or Process

•        Recover Root Password

•        SOS Report

•        List of Users Logged in by Date

•        System is Running Slow

 

 

 

Thursday, June 13, 2024

Ansible Playbooks Practise

 https://github.com/do-community/ansible-practice/blob/main/playbook-01.yml

Sunday, June 9, 2024

Important Link for Terraform Project

 https://www.linkedin.com/pulse/create-vpcsubnetsec2-instance-using-terraform-srini-b-dcjuc/


https://www.linkedin.com/pulse/day-66-terraform-hands-on-project-build-your-own-aws-sayali-shewale/


https://medium.com/@saurabhdahibhate50/terraform-hands-on-project-d2105bbc0c62


https://helenchukwukelu.hashnode.dev/terraform-project-for-bbeginners



https://blog.softup.co/how-we-structure-our-terraform-code/


https://blog.devops.dev/devops-project-12-infrastructure-as-code-with-terraform-in-aws-407165d3d801



=========

Important Project:

https://medium.com/@e-miguel/project-1-host-a-dynamic-ecommerce-website-on-aws-with-terraform-ea93ef2ba15f


https://medium.com/@faisalkuzhan/day-55-90-terraform-interview-questions-e8ff859220d5



==========

Manual AWS PRoject:

https://medium.com/@e-miguel/host-a-dynamic-car-rental-web-application-on-aws-f4f5ed700feb


Wednesday, June 5, 2024

Terraform S3 Backend Configuration

#provider.tf

provider "aws" {
  region = "us-east-1"
  access_key = "my-access-key"
  secret_key = "my-secret-key"

}

main.tf:


resource "aws_instance" "ec2web3" {
  ami           = "ami-0d191299f2822b1fa"
  instance_type = "t2.micro"
}

terraform {

  backend "s3" {

    access_key = "xxxxxxxxxxxxxxx"
    secret_key = "xxxxxxxxxxxxxxxxxxxxxxx"
    region     = "us-east-1"
    bucket     = "kishor-tf-state"
    key        = "terraform.tfstate"
  }
}

#command
terraform init -backend-config="access_key=xxxxxxxxxxxxxxxx"
-backend-config="secret_key=xxxxxxxxxxxxxxxxxx"




Saturday, June 1, 2024

Create S3 Bucket Using Terraform

 resource "aws_s3_bucket" "my-bucket1" {

  bucket = "my-tf-test-bucket-kaa"

  tags = {
    Name        = "My bucket"
    Environment = "Dev"
  }
}



============

provider "aws" {

  region     = "ap-south-1"
  access_key = "XXXXXXXXXXXX"
  secret_key = "XXXXXXXX+yLQRZk01cw1EXNKqNXLKeNTiT"

}

Create EC2 Instance , SG, KEY Using Terraform

 resource "aws_key_pair" "key-tf" {

  key_name   = "tf-key"
  public_key = file("${path.module}/id_rsa.pub")

}

output "keyname" {
  value = aws_key_pair.key-tf.key_name

}


resource "aws_instance" "web" {
  ami                         = "ami-067aaeea6813afbde"
  instance_type               = "t3.micro"
  vpc_security_group_ids      = [aws_security_group.instance.id]
  associate_public_ip_address = true


  key_name = aws_key_pair.key-tf.key_name

  tags = {
    Name = "tf-instance"
  }
}

resource "aws_security_group" "instance" {

  name = "terraform-SG"
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]

  }
}

provider "aws" {
  region     = "ap-south-1"
  access_key = "XXXXXXXXXXXXXXXXXXXX"
  secret_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

}


Tuesday, May 21, 2024

K8 All Topics Details

 https://github.com/devopsproin/certified-kubernetes-administrator/tree/main

Sunday, May 19, 2024

PV Demo Using HostPath and EBS

Follow Below Link For HosPath Demo:

https://srdev.hashnode.dev/managing-persistent-volumes-in-your-deployment

Follow Below Link For EBS PV and PVC Demo:

Installing and Configuring AWS EBS CSI Driver for Kubernetes Cluster with Dynamic Provisioning of EBS Volumes


This guide provides the steps to install and configure the AWS EBS CSI Driver on a Kubernetes cluster to enable the use of Amazon Elastic Block Store (EBS) volumes as persistent volumes.

Prerequisites

  • A running Kubernetes cluster.
  • A Kubernetes version of 1.20 or greater.
  • An AWS account with access to create an IAM user and obtain an access key and secret key.

Installing Helm

Helm is a package manager for Kubernetes that simplifies the deployment and management of applications.

  • Run the following commands to install Helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

Installing AWS EBS CSI Driver

  • Create a secret to store your AWS access key and secret key using the following command:
kubectl create secret generic aws-secret \
    --namespace kube-system \
    --from-literal "key_id=${AWS_ACCESS_KEY_ID}" \
    --from-literal "access_key=${AWS_SECRET_ACCESS_KEY}"
  • Add the AWS EBS CSI Driver Helm chart repository:
helm repo add aws-ebs-csi-driver https://kubernetes-sigs.github.io/aws-ebs-csi-driver
helm repo update
  • Deploy the AWS EBS CSI Driver using the following command:
helm upgrade --install aws-ebs-csi-driver \
    --namespace kube-system \
    aws-ebs-csi-driver/aws-ebs-csi-driver
  • Verify that the driver has been deployed and the pods are running:
kubectl get pods -n kube-system -l app.kubernetes.io/name=aws-ebs-csi-driver

Provisioning EBS Volumes


https://docs.aws.amazon.com/eks/latest/userguide/ebs-sample-app.html

  • Create a storageclass.yaml file and apply the storageclass.yaml file using the following command:
kubectl apply -f storageclass.yaml
  • Create a pvc.yaml file and apply the pvc.yaml file using the following command:
kubectl apply -f pvc.yaml
  • Create a pod.yaml file and apply the pod.yaml file using the following command:
kubectl apply -f pod.yaml
  • Verify that the EBS volume has been provisioned and attached to the pod:
kubectl exec -it app -- df -h /data

The output of the above command should show the mounted EBS volume and its available disk space.





Wednesday, May 15, 2024

Ingress Demo Using Minikube

 https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/

Sunday, May 12, 2024

EKS Cluster Setup

 https://medium.com/@mudasirhaji/setup-kubernetes-cluster-on-amazon-eks-56cbbadace04

Wednesday, May 8, 2024

K8S Cluster Setup Steps (AWS Amazon Linux)

  yum install docker -y

 

 systemctl enable docker

 

 systemctl start docker

 

 curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

 

 sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64

 

 minikube version

 

 minikube start --driver=docker --force

 

  minikube status

  

 curl -LO https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl

  

 sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

 

 kubectl version

 

 Deploy Sample POd:

 https://kubernetes.io/docs/concepts/workloads/pods/

 

 

=======================================================================

Master 


1  hostnamectl set-hostname k8master

    

2  yum install docker -y

    

3  systemctl start docker;systemctl enable docker

    

4  sudo setenforce 0

 


5 Add K8S Repo:


cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo

[kubernetes]

name=Kubernetes

baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/

enabled=1

gpgcheck=1

gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key

exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni

EOF


6.yum repolist

    

7  sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes --disableplugin=priorities

    

8  kubeadm init

  --> Note down kubeadm join commands:

  

9  kubectl get nodes


10  mkdir -p $HOME/.kube

   

11  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

   

12  sudo chown $(id -u):$(id -g) $HOME/.kube/config


13  export KUBECONFIG=/etc/kubernetes/admin.conf


14. kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml


15 kubectl get nodes


17 kubectl get pods -n kube-system


18  kubectl get nodes



Worker:



1  hostnamectl set-hostname k8worker1

    

2  yum install docker -y

    

3  systemctl start docker;systemctl enable docker

    

4  sudo setenforce 0

 


5 Add K8S Repo:


cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo

[kubernetes]

name=Kubernetes

baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/

enabled=1

gpgcheck=1

gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key

exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni

EOF


6.yum repolist

    

7  sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes --disableplugin=priorities


8. Use join comamnd to connect control plain:  join command and token you can take from master 



 kubeadm join 172.31.63.238:6443 --token 15zdfy.iogdr2v5ngur6cwo \

>         --discovery-token-ca-cert-hash sha256:6fbc63b2d51467ec36482022d207af7672e1330168ceee673eb4182538f324fb



Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117