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

No comments:

Post a Comment

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