Kubernetes cheat sheet

Kubernetes cheat sheet

Managing Resources:

  1. Create Resource: kubectl create -f <filename> - Create a resource from a YAML file.
  2. Apply Configuration: kubectl apply -f <filename> - Apply a configuration to a resource from a YAML file.
  3. Get Resources: kubectl get <resource> - Retrieve resources (pods, deployments, services, etc.).
  4. Describe Resource: kubectl describe <resource> <resource_name> - Show details of a specific resource.
  5. Delete Resource: kubectl delete -f <filename> - Delete resources defined in a YAML file.

Pods Management:

  1. List Pods: kubectl get pods - List all pods in the current namespace.
  2. Pod Logs: kubectl logs <pod_name> - Print logs for a specific pod.
  3. Execute Command in Pod: kubectl exec -it <pod_name> -- <command> - Execute a command in a running pod.
  4. Port Forwarding: kubectl port-forward <pod_name> <local_port>:<pod_port> - Forward a local port to a pod.
  5. Create Pod: kubectl run <pod_name> --image=<image_name> - Create a pod imperatively.

Deployments Management:

  1. List Deployments: kubectl get deployments - List all deployments in the current namespace.
  2. Scale Deployment: kubectl scale --replicas=<replica_count> deployment/<deployment_name> - Scale a deployment to a specific number of replicas.
  3. Rollout Status: kubectl rollout status deployment/<deployment_name> - Check the status of a deployment rollout.
  4. Rollout History: kubectl rollout history deployment/<deployment_name> - View the history of a deployment rollout.
  5. Rollback Deployment: kubectl rollout undo deployment/<deployment_name> - Rollback a deployment to the previous version.

Services Management:

  1. List Services: kubectl get services - List all services in the current namespace.
  2. Expose Service: kubectl expose deployment/<deployment_name> --port=<port> - Expose a deployment as a service.

Namespaces Management:

  1. List Namespaces: kubectl get namespaces - List all namespaces in the cluster.
  2. Switch Namespace: kubectl config set-context --current --namespace=<namespace> - Switch to a different namespace.

Configuration & Troubleshooting:

  1. Edit Resource: kubectl edit <resource> <resource_name> - Edit a resource in real-time using the default editor.
  2. Describe Node: kubectl describe node <node_name> - Show details of a specific node.
  3. Describe Pod: kubectl describe pod <pod_name> - Show details of a specific pod.
  4. Top Resources: kubectl top <resource> - Display resource usage statistics (CPU, memory) for pods or nodes.
  5. Get Events: kubectl get events - Display events from the cluster.
  6. Cluster Info: kubectl cluster-info - Display cluster information.

These commands cover a wide range of Kubernetes operations for managing resources, pods, deployments, services, namespaces, configuration, and troubleshooting. They form the foundation for interacting with Kubernetes clusters efficiently.

Ankit B

Data-Driven B2B Marketer | Driving Business Success

1 年

Multi-Cloud Kubernetes with Rancher Download Now: https://tinyurl.com/4u3ytxxc, #Kubernetes #cloud #cloudtechnology #cloudtech #multicloud #cloudengineering #cloudtechnology #cloudinfrastructure #cloudmanagement?

Excited to see the Kubernetes cheat sheet for DevOps, Priyanka kumari! Would love to know what your top tip is for beginners diving into Kubernetes.

要查看或添加评论,请登录

Priyanka kumari yadav的更多文章

  • Jenkins Interview Question

    Jenkins Interview Question

    jenkins Overview and Architecture: What is Jenkins? Jenkins is an open-source automation server used to automate…

    4 条评论
  • Docker cheat sheet

    Docker cheat sheet

    Docker cheat sheet with the top 50 commands: Managing Images and Containers: docker pull [image_name]: Pull an image…

    1 条评论
  • GIT CHEET SHEET-BASIC TO ADVANCED

    GIT CHEET SHEET-BASIC TO ADVANCED

    git init: Initialize a new Git repository. git clone [url]: Clone a repository into a new directory.

    2 条评论
  • CheatSheet: Linux Commands for DevOps

    CheatSheet: Linux Commands for DevOps

    id - This is used to find out user and group names and numeric ID’s (UID or group ID) of the current user or any other…

    3 条评论

社区洞察

其他会员也浏览了