📦

Beginner's Guide to kubectl Commands

Apr 13, 2025

Lecture Notes: Basic kubectl Commands and Managing Pods in Minikube

Introduction

  • Objective: Learn basic kubectl commands for creating and debugging pods in Minikube.
  • Tools: Minikube cluster, kubectl for managing Kubernetes clusters.

Initial Setup

  • Cluster Status: kubectl get
    • Check node status: one master node in Minikube.
    • Check pods and services: initially no resources or default service.

Creating and Managing Deployments

  • Pods in Kubernetes
    • Pod is the smallest unit but usually managed via deployments.
  • Creating Deployments
    • Use kubectl create deployment with options for name and image.
    • Example: kubectl create deployment nginx-deployment --image=nginx
    • Deployment creates pods with specified container images.

Understanding Kubernetes Layers

  • Deployment
    • Manages the blueprint for pods.
    • Configurations include name and container image.
  • ReplicaSet
    • Automatically managed, controls pod replicas.
    • No direct management needed; handle via deployments.

Editing Deployments

  • Editing with kubectl edit deployment
    • Modify deployment configurations like image version.
    • Changes automatically update pods and replicaset.

Debugging and Logs

  • Checking Logs with kubectl logs
    • View application logs inside pods.
    • Useful for debugging.
  • Exec into Pod with kubectl exec -it
    • Access terminal of a running container for debugging.

Deleting Resources

  • Deleting Deployments
    • kubectl delete deployment <name> removes deployment and associated pods and replicaset.

Using Configuration Files

  • Why Use Config Files?
    • Practicality: Easier than long command lines.
    • Centralizes configurations for deployments and other resources.
  • Applying Config Files with kubectl apply -f <file>
    • Create or update resources from a YAML configuration file.
    • Example YAML includes deployment name, replicas, and pod template.

Summary

  • Key kubectl commands: create, edit, delete, get status, logs, exec.
  • Use configuration files for managing extensive setup and configuration.
  • Upcoming content: Detailed breakdown of configuration file syntax.

Conclusion

  • Stay tuned for more videos on Kubernetes configurations.
  • Engage with any questions or feedback in comments section.

Note

  • Subscribe for notifications on new videos and topics.