Saturday, 24 May 2025

Git

1 git add

↳ It lets you add changes from the working directory into the staging area

2 git commit

↳ It lets you save a snapshot of currently staged changes in the local repository, with a message

3 git push

↳ It lets you upload commited changes from the local repository to a remote repository

4 git fetch

↳ It lets you download changes from a remote repository, without applying them locally

5 git merge

↳ It lets you combine changes from one branch into another

6 git pull

↳ It lets you fetch and then merge changes from a remote repository into the local branch

7 git diff

↳ It lets you see the changes not staged or commited yet

8 git diff HEAD

↳ It lets you see changes between the current working directory and the latest commit

9 git status

↳ It shows you the current state of the working directory and staging area

10 git branch

↳ It lets you see all local branches

11 git checkout

↳ It lets you create a branch or switch between branches

12 git log

↳ It shows you commits in the current branch with extra details

13 git stash

↳ It lets you temporarily save uncommited changes and apply them later

14 git rebase

↳ It lets you apply commits from one branch to another

15 git reset

↳ It lets you undo changes in the working directory and move back to a specific commit

16 git revert

↳ It lets you undo changes by creating a new commit

17 git cherry pick

↳ It lets you apply commits from one branch to another

———

- Working directory

↳ It's the directory where you make changes to the files

- Staging area

↳ It lets you control which changes go into a commit

- Local repository

↳ It's the version of a project stored on the local machine of a user

- Remote repository

↳ It's the version of a project stored on a server, such as GitHub

Wednesday, 20 December 2023

Linux command to check CPU Utilization

 awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \

<(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat)

Wednesday, 25 January 2023

Useful notes for CKA exam

 

## Shortcuts to save time 

export do="--dry-run=client -o yaml"

export now="--force --grace-period 0"

k delete pod x $now

alias kn='kubectl config set-context --current --namespace '

kn my-namespace 


## JOIN KUBE CLUSTER ##

kubeadm token create --print-join-command


## Check Service CIDR ##

ssh cluster1-controlplane1

cat etc/kubernetes/manifests/kube-apiserver.yaml | grep range


## CNI Plugin is configured and where is its config file ##

find /etc/cni/net.d/

cat /etc/cni/net.d/10-weave.conflist


## Show Latest events ##

kubectl get events -A --sort-by=.metadata.creationTimestamp


### find pod running on cluster2-node1

k -n kube-system get pod -o wide | grep proxy 


## killing pod on a node 

  crictl ps | grep kube-proxy

        crictl stop e6fe93fbaec50

        crictl rm e6fe93fbaec50

        crictl ps | grep kube-proxy


## Write the names of all namespaced resources into file 

 k api-resources --namespaced -o name > /opt/course/16/resources.txt


## Check which namspace has more role (count )

  k -n <namespacename> get role --no-headers | wc -l


cat <<EOF | kubectl apply -f -

---

apiVersion: rbac.authorization.k8s.io/v1

kind: Role

metadata:

  name: app-role

  namespace: project-hamster

rules:

  - apiGroups:

        - ""

        - apps

        - autoscaling

        - batch

        - extensions

        - policy

        - rbac.authorization.k8s.io

    resources:

      - configmaps

      - secrets


    verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]

EOF



cat <<EOF | kubectl apply -f -

---

apiVersion: rbac.authorization.k8s.io/v1

kind: RoleBinding

metadata:

  name: app-rolebinding

  namespace: project-hamster 

roleRef:

  apiGroup: rbac.authorization.k8s.io

  kind: Role

  name: app-role 

subjects:

- namespace: webapps 

  kind: ServiceAccount

  name: processor

EOF

Tuesday, 26 July 2022

Creating EKS cluster

 https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html

Checking EKS status using aws cli

 


aws eks describe-cluster \

    --region us-east-1 \

    --name my-cluster \

    --query "cluster.status"

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...