Kubernetes Commands

Kubernetes is a powerful container orchestration tool that helps manage and deploy containerized applications. Here are some essential Kubernetes commands with examples for your blog:

1. Basic Commands:

Create and manage resources:

  1. Create a Deployment:
   kubectl create deployment nginx --image=nginx
  1. Scale Deployments:
   kubectl scale deployment nginx --replicas=3
  1. Create a Service:
   kubectl expose deployment nginx --port=80 --type=NodePort
  1. List Pods:
   kubectl get pods

2. Pod Management:

Interacting with Pods:

  1. View Logs from a Pod:
   kubectl logs <pod-name>
  1. Execute Commands in a Pod:
   kubectl exec -it <pod-name> -- /bin/bash
  1. Copy Files to/from Pod:
   kubectl cp /local/path <pod-name>:/pod/path
   kubectl cp <pod-name>:/pod/path /local/path

3. Cluster Management:

Checking Cluster Status and Info:

  1. View Cluster Information:
   kubectl cluster-info
  1. Show Nodes in the Cluster:
   kubectl get nodes
  1. Describe a Resource:
   kubectl describe pod <pod-name>

4. Resource Cleanup:

Deleting Resources:

  1. Delete a Deployment:
   kubectl delete deployment nginx
  1. Delete a Service:
   kubectl delete service nginx
  1. Delete a Pod:
   kubectl delete pod <pod-name>

5. Resource Inspection:

Get and Filter Information:

  1. Get Detailed Resource Information:
   kubectl get pods -o wide
  1. Filter Resources by Labels:
   kubectl get pods -l key=value
  1. Show Resource YAML Configuration:
   kubectl get deployment nginx -o yaml

6. Advanced Operations:

Advanced Kubernetes Operations:

  1. Apply Configuration from a YAML File:
   kubectl apply -f filename.yaml
  1. Create a Namespace:
   kubectl create namespace my-namespace
  1. Run a CronJob:
   kubectl create -f cronjob.yaml

Include explanations, use cases, and scenarios where these commands are utilized. Highlight the importance of these commands for managing, monitoring, and scaling containerized applications within a Kubernetes cluster. Emphasize the significance of learning and understanding these commands for efficient Kubernetes management and application deployment.