GithubHelp home page GithubHelp logo

k8s-for-developers's Introduction

๐Ÿ™ Certified Kubernetes Application Developer ๐Ÿฌ

This repository contains definitions, tips, sources, and many commands for practice and that I am currently using to prepare for my kubernetes certification exam.

REPOSITORY IN PROGRESS ... ๐ŸŽ  ๐Ÿ™‹ ๐Ÿšœ

About the CKAD (Certified Kubernetes Application Developer)

The exam covers the following topics in a certain percentage:

  • ๐Ÿพ Core Concepts (13%)
  • ๐Ÿพ Multi-Container Pods (10%)
  • ๐Ÿพ Pod Design (20%)
  • ๐Ÿพ State Persistence (8%)
  • ๐Ÿพ Configuration (18%)
  • ๐Ÿพ Observability (18%)
  • ๐Ÿพ Services and Networking (13%)

Topics ๐ŸŽฏ

Namespaces Multicontainer
Pods Service Account
Deployment Node Selector and Node Affinity
Replication Controller Readiness and Liveness Probes
Replicaset Labels Selectors Annotations
Resource Quota Jobs
ConfigMaps Rolling Updates Rollbacks in Deployments
Secrets Networking Policy
Kubernetes Security Volumes
Variables Taints and Tolerations
Services KAD hands on

In this repository there are many tips, you may not be able to use all of them, use the ones you feel most comfortable with.

Use the right context always

# Every time before to start the question
kubectl config use-contex <CONTEXTNAME>

Use Alias

# Alias for kubectl
alias k='kubectl'

# This way you can just run k run my-pod --image=nginx $do. 
export do="--dry-run=client -o yaml"

# To apply -f
alias ka='kubectl apply -f'
ka pod1.yaml

# Dry run
alias kdr='kubectl run --dry-run=client -o yaml' # Use it: krd --image=nginx > pod.yaml

# Delete a pod with grace period
alias kdp='kubectl delete pod --force --grace-period=0'

# Kubectl apply with a file
alias kaf='kubectl apply -f'

# Kubectl create with a file
alias kaf='kubectl create -f'

# kubectl set context
alias kns='config set-context --current --namespace'

Use Completions

source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.

alias k=kubectl
complete -F __start_kubectl k

Basic commands

# To get all the resorces in a namespaces
kubectl get all

# Describe a resource
kubectl describe pod yellow

# Generate a preview without a file
kubectl create namespace test-123 --dry-run=client -o yaml

# "edit" to edit existing resources
kubectl edit pod nginx
kubectl edit deployment app

# "set" to update a version in a pod or deployment
kubectl set image pod/nginx nginx=nginx:latest
kubectl set image pod/nginx nginx=nginx:1.9.1
kubectl set image deployment/nginx nginx=nginx:latest
kubectl set image deployment/nginx nginx=nginx:1.9.1

Log and Debugging

k run --image=busybox bbox -- sh -c 'while true; do date; sleep 3; done '

kubectl logs busybox
# Follow the logs
kubectl logs busybox -f
kubectl logs webapp-1 | grep USER5

# to select the containers
kubectl logs webapp-2 -c
kubectl logs webapp-2 -c simple-webapp
kubectl logs alta3pod | sudo tee ~/opt/answers/mypod.log

# See the error of a pod
kubectl get events | grep -i error
kubectl dev-pod -c log-x | grep WARN > /opt/logs.txt

# To keep watching the logs
kubectl  logs bbox --follow

# Use describe
kubectl describe bbox
kubectl describe mydeploy

# See the event for all the resources
kubectl get events

# Using grep
kubectl get events | grep Schedule

# View control exec
kubectl run --image=busybox bbox -- sh -c 'echo here; sleep 3600'

# Access to the shell inside the pod
kubectl exec -it bbox -- sh
ls
exit

# Check all the deployments in all the namespaces
k get get deploy --all-namespaces

# List pods and services in a single namespace
kubectl -n elastic-stack get pod, svc

# To check for more options
kubectl explain pods --recursive | less
/volumeMounts

# Monitorins
kubectl top node
kubectl top pod

Observability

# Collect failed pods by namespace
kubectl -n qa get events | grep -i 'Liveness probe failed'

#  Check pods in all namespaces with READY = 0
k get pod --all-namespaces | grep -i 0

#  Check Liveness and Readiness status
kubectl describe pod nginx | grep -i liveness
kubectl describe pod nginx | grep -i readiness

# You'll see the error here as well
kubectl get events | grep -i error

# kubectl cp command
kubectl cp busybox:etc/passwd ./passwd 

Cheat Sheet

Download in PDF -> Made by Edith Puclla

Tips and Tricks ๐ŸŽ

From Udemy course with Mumshad Mannambeth

  • Attempt all questions
  • Don't get stuck on any question
  • Get good with YAML
  • Use shortcuts/aliases
    • po for Pods
    • rs for RepicaSets
    • deploy for Deployments
    • svc for Services
    • ns for Namespaces
    • netpol for Networking polices
    • pv for Persistent Volumes
    • pvc for PersistentVolumeClaims
    • sa for service accounts

From - Muralidaran shanmugham

  • Go through the k8s.io documentation
  • Understand all the concepts outlined in the exam curriculum
  • Register for courses like Kodekloud
  • Time management
    • nano Editor
    • Kubectl alias
    • learn shortcuts
    • alias k='kubectl'
    • k config set-context --namespace=
    • k explain cronjob.spec.jobTemplate --recursive
    • know all the commands => HERE
    • --restart (YAML generator)
    • args: ["-c", "while true; do date >> /var/log/app.txt; sleep 5; done"]
    • args: [/bin/sh, -c, 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done']
    • args: ["-c", "mkdir -p collect; while true; do cat /var/data/*> /collect/data.txt; sleep 10; done"]
    • Use of grep:
      • kubectl describe pods | grep --context=10 annotations:
      • kubectl describe pods | grep --context=10 Events:

Be Fast with VIM

# Move the cursor
- Use:
    h -> move to left
    l -> move to right
    j -> move down
    k -> move  up
- Esc + w           -> move word to word, set cursor at the beginning of the word
- Esc + e           -> move word to word, set cursor at the end of the word
# Edit/view/find words or lines
- Esc + DD          -> delete a line
- Esc + o           -> add a new line
- Esc + :set nu     -> to add line numbers
- Esc + dw          -> Delete a word
- Esc + u           -> revert changes
- Esc + /           -> Find a word
* Esc :num + Enter  -> go a specific number  line in a file, example: Esc :22
# Indent several lines
- Shift + v         -> to visual mode and up and down arrows to move the cursor
- Shift + >         -> indentation to the right
- Shift + <         -> indentation to the left
# Copy and paste single line
- Esc + y           -> copy a line
- Esc + p           -> paste the line
# copy and paste several lines
- Esc + V           -> Mark lines, then arrow keys to select several lines
- Esc + y           -> Copy marked lines
- Esc + d           -> Cut marked lines
- Esc + p           -> Past lines

Bookmarks on Chrome ๐Ÿ”–

  • Go to the documentation: https://kubernetes.io/docs/home/
  • Select a topic
  • Go to specific section of the page
  • Set a bookmark
  • If you need copy the code, use copy application to clipboard

My Setup (Optional)

# Kubectl Autocomplete
# Bash
source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.

alias k=kubectl
complete -F __start_kubectl k

alias kn='kubectl config set-context --current --namespace '
alias kd='kubectl delete pod --grace-period=0 --force'
alias ka='kubectl apply -f'
export do='--dry-run=client -o yaml'

Resources: ๐Ÿ”” ๐Ÿ””

Course ๐Ÿ“ป

Kubernetes Documentation ๐Ÿ“˜

Practice โœ๏ธ

  1. How to Prepare for CKAD and CKA Certification? -> InfraCloud Team
  2. Game of Pods A set of fun challenges to learn and practice your skills on Kubernetes
  3. Kubernetes CKAD Example Exam Questions Practical Challenge Series -> Kim Wuestkamp
  4. Practice Enough With These 150 Questions for the CKAD Exam -> Bhargav Bachina
  5. CKAD Exercises Github -> dgkanatsios
  6. Kubernetes Network Policy Recipes
  7. katacoda - CKAD Practice Challenge
  8. More Practice (Trial) https://www.study4exam.com/
  9. Securing Kubernetes Cluster Networking

Videos ๐ŸŽฅ

  1. How to Pass CKA, CKAD with Flying Colors? -> I AM DINUTH

  2. How to CRUSH the CKAD Exam! -> Alta3 Research, Inc.

  3. Vim Crash Course | How to edit files quickly in CKAD / CKA exam -> The FrontOps Guy

  4. Linux Foundation Kubernetes Certifications Now Include Exam Simulator -> killer.sh CKA, CKAD, or CKS simulator

k8s-for-developers's People

Contributors

edithturn avatar

Watchers

James Cloos avatar

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.