Kubernetes Commands: Containerizing Your Workflow

2025-02-12

Pods: Building Blocks of Applications

  • View all running pods: `kubectl get pods`
  • Dive into pod details: `kubectl describe pod `
  • Deploy a pod: `kubectl create pod –image=`
  • Remove a pod: `kubectl delete pod `
  • Check pod logs: `kubectl logs `
  • Access pod’s container: `kubectl exec -it /bin/bash`

Deployments: Managing Application Lifecycle

  • List deployments: `kubectl get deployments`
  • Understand deployment details: `kubectl describe deployment `
  • Create a deployment: `kubectl create deployment –image=`
  • Scale a deployment: `kubectl scale deployment –replicas=`
  • Roll out changes: `kubectl rollout restart deployment `

Services: Exposing and Connecting Applications

  • See available services: `kubectl get services`
  • Explore service configuration: `kubectl describe service `
  • Expose an application: `kubectl expose deployment –type=`
  • Delete a service: `kubectl delete service `

Namespaces: Organizing Workloads

  • List namespaces: `kubectl get namespaces`
  • Create a namespace: `kubectl create namespace `
  • Switch to a namespace: `kubectl config set-context –current –namespace=`
  • Remove a namespace: `kubectl delete namespace `

Other Resources: Additional Tools

  • View cluster nodes: `kubectl get nodes`
  • Check cluster events: `kubectl get events`
  • Monitor cluster health: `kubectl cluster-info`

Useful Flags: Handy Options

  • -o wide: Display more details in a wider format
  • -f: Specify a YAML file for resource definitions
  • -n: Define a namespace
  • --dry-run: Preview changes before executing
  • Filter pods by namespace: `kubectl get pods [namespace]`

What Undercode Say

Kubernetes is a powerful tool for managing containerized applications, and mastering its commands is essential for DevOps professionals. The commands listed above provide a solid foundation for managing pods, deployments, services, and namespaces. For instance, `kubectl get pods` is indispensable for monitoring running pods, while `kubectl describe pod ` offers detailed insights into pod configurations.

To further enhance your Kubernetes skills, consider exploring advanced commands like `kubectl apply -f ` for declarative resource management and `kubectl port-forward :` for accessing pods directly from your local machine. Additionally, leveraging `kubectl get events` can help you troubleshoot cluster issues by providing a chronological log of cluster activities.

For those looking to automate tasks, integrating Kubernetes with CI/CD pipelines using tools like Jenkins or GitLab CI can streamline deployments. Commands like `kubectl rollout status deployment/` ensure that updates are applied smoothly, while `kubectl autoscale deployment –min= –max= –cpu-percent=` enables dynamic scaling based on resource usage.

To deepen your understanding, refer to the official Kubernetes documentation (https://kubernetes.io/docs) and explore community-driven resources like Kubernetes Slack channels and GitHub repositories. By combining these commands with best practices, you can optimize your workflow, enhance cluster performance, and ensure seamless application deployments.

Remember, Kubernetes is not just about running commands; it’s about understanding the underlying architecture and leveraging its capabilities to build scalable, resilient systems. Whether you’re managing a small cluster or a large-scale deployment, these commands will empower you to take control of your containerized environment and drive efficiency in your DevOps workflows.

References:

Hackers Feeds, Undercode AIFeatured Image

Scroll to Top