Coder Social home page Coder Social logo

cka-training-lab's Introduction

CKA-TrainingLab

Exam Information

This Document was created at 03/2023

  • Kubernetes version: 1.26
  • 2 hours
  • 15-20 questions
  • Pass mark of 66%
  • Webcam and microphone
  • Remotely proctored
  • Chrome browser plus an extension
  • Steady internet, preferably 5MB up/down


Curriculum

Please check more details at CNCF Repo

Storage (10%)



Set Up

For convenience, abbreviate kubectl to k After this section,

Auto Completion Setting

vi ~/.bashrc 

# write down at end of bashrc

# Auto Completion
kubectl completion bash
kubeadm completion bash

# Alias Setting
alias kc="kubectl create" 
export do="--dry-run=client -o yaml" # Create the YAML tamplate (usage: $do)

# Save and Quit

exec $SHELL # Reload shell(Must CAPITAL)
# usage example 
kc deploymentmy my-dep --image=nginx --replicas=3
kc deployment --image=nginx nginx $do
k run --image=busybox $do -- "/bin/sh" "-c" "sleep 36000"


CheatSheet

Short Words

  • pods : po
  • deployments : deploy
  • services : svc
  • replicasets : rs
  • replicationcontollers : rc
  • configmaps : cm
  • namespaces : ns
  • nodes : no
  • persistentvolumeclaims : pvc
  • persistentvolumes : pv
  • resourcequotas : quota
  • serviceaccounts : sa
  • daemonsets : ds
  • cronjobs : cj
  • ingresses : ing
  • storageclasses : sc

Status Diagnosis

# Check the status of kubelet
sudo systemctl status kubelet

# Check correct context
k config get-contexts
k config set-context ${Context_Name} # if you want to change context

# Check the status of System Pod
k logs -n kube-system ${System_Pod_Name}

# Display addresses of the master and services
k cluster-info [dump] # dump option is for more detail

# List all resources in all namespaces, with more details
k get all -A -o wide

# Show related events,  metrics for troubleshooting
k describe pods ${Pod_Id}
k top node my-node
k explain deployment --recursive

Create

# create a deployment
k create deploy nginx --image=nginx

# create a service & ingress
k create svc clusterip my-service --tcp=80:80
k create ingress ${Name} --tcp=80:80

# create a secret & configmap
k create secret generic my-secret --from-file ${File_Name}
k create configmap my-config --from-literal=special.how=very

Read

if you want to create a resource from the yaml file,

you can use the following command (Don't memorize yaml file)

# from existing resource
k get pod ${Pod_Id} -o yaml > pod.yaml

# from scratch
k create deploy nginx --image=nginx  > deploy.yaml
# if you have set alias, you can use $do
k create deploy nginx --image=nginx $do > deploy.yaml 

Update

# apply changes to resource (partial change)
k apply -f ${File_Name}

# replaces a resource with a new configuration file.
# old resource will be removed and new one created.
k replace -f ${File_Name}

# edit in user’s shell.
k edit ${Resource_Type} ${Resource_Name}

# patch a resource with new property values.
k patch ${Resource_Type} ${Resource_Name} -p '{"property_name":"new_value"}'

# updates the container image in a deployment.
k set image deployment ${Deployment_Name} ${New_Image}=${Image_Url}

# restarts a rollout of a Kubernetes resource
k rollout restart deployment ${Deployment_Name}

# Scale a deployment
k scale deploy my-deployment --replicas=5

Delete

# Delete a pod
k delete pod ${podId}

# Force delete a pod
k delete pod ${podId} --force --grace-period=0

# Delete all specified resources in current namespace
k delete pod -n test --all 

RBAC ( Role Based Access Control )

Only one thing to remember is that the Role and ClusterRole are the same,

but the Role is in the namespace, and the ClusterRole is not in the namespace.

k create [role, clusterrole] dev-role \ 
-n default \ # ClusterRole has no namespace
--verb=get,list,watch,update \
--resource=pods \ 
--resource-name=test-pod

k create rolebinding dev-binding \
-n default \ # ClusterRoleBinding has no namespace
--role=dev-role \
--clusterrole=dev-clusterrole \
--serviceaccount=default:test-sa

Specific Situation Command

# Count the number of pods in a namespace
k get pod -n my-namespace | wc -l

# Check authentication
k auth can-i create deployments -n default --as guest

Reference

https://github.com/leandrocostam/cka-preparation-guide

https://github.com/ismet55555/Certified-Kubernetes-Administrator-Notes

https://github.com/arush-sal/cka-practice-environment

https://github.com/kodekloudhub/certified-kubernetes-administrator-course

cka-training-lab's People

Contributors

junwork123 avatar

Watchers

 avatar  avatar

Forkers

arunms003

cka-training-lab's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.