Kubernetes
Commands

🌟 Introduction to Kubernetes

Kubernetes, often abbreviated as K8s, is an open-source platform designed to automate the deployment, scaling, and operation of application containers. It provides a framework to run distributed systems resiliently. This documentation provides a basic introduction and commands to get started with Kubernetes for beginners.


📚 Basic Concepts

1. Pod

  • The smallest and simplest Kubernetes object. A pod represents a single instance of a running process in your cluster.

2. Service

  • A way to expose an application running on a set of Pods as a network service.

3. Deployment

  • Manages a set of identical pods. Used to scale up or down and update pods systematically.

4. Namespace

  • A way to divide cluster resources between multiple users.

🛠️ Kubernetes Commands

Cluster Setup

  1. Check Cluster Information

    kubectl cluster-info
  2. Get Nodes in the Cluster

    kubectl get nodes

Working with Namespaces

  1. List All Namespaces

    kubectl get namespaces
  2. Create a New Namespace

    kubectl create namespace <namespace-name>
  3. Delete a Namespace

    kubectl delete namespace <namespace-name>

Pods

  1. List All Pods

    kubectl get pods
  2. Get Pod Details

    kubectl describe pod <pod-name>
  3. Delete a Pod

    kubectl delete pod <pod-name>

Deployments

  1. List All Deployments

    kubectl get deployments
  2. Create a Deployment

    kubectl create deployment <deployment-name> --image=<image-name>
  3. Scale a Deployment

    kubectl scale deployment <deployment-name> --replicas=<number-of-replicas>
  4. Update a Deployment

    kubectl set image deployment/<deployment-name> <container-name>=<new-image>
  5. Delete a Deployment

    kubectl delete deployment <deployment-name>

Services

  1. List All Services

    kubectl get services
  2. Expose a Deployment as a Service

    kubectl expose deployment <deployment-name> --type=<service-type> --port=<port>
  3. Delete a Service

    kubectl delete service <service-name>

ConfigMaps and Secrets

  1. Create a ConfigMap

    kubectl create configmap <configmap-name> --from-literal=<key>=<value>
  2. List ConfigMaps

    kubectl get configmaps
  3. Create a Secret

    kubectl create secret generic <secret-name> --from-literal=<key>=<value>
  4. List Secrets

    kubectl get secrets

Logs and Debugging

  1. View Pod Logs

    kubectl logs <pod-name>
  2. Execute Command in Pod

    kubectl exec -it <pod-name> -- <command>
  3. Get Events in the Cluster

    kubectl get events


🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!