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"

Creating EKS using aws CLI

 aws eks create-cluster --region us-east-1 --name my-cluster --kubernetes-version 1.22 \

   --role-arn arn:aws:iam::73095:role/AmazonEKSClusterRole \

   --resources-vpc-config subnetIds=subnet-0814938360f2fdf5b,subnet-040ad1e2b5ffe4775



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...