My_cheatSheets

Kubernetes Cheat Sheet

Cluster Management

  • Get cluster information

    kubectl cluster-info
  • View nodes

    kubectl get nodes
    

Workloads

  • List all pods in all namespaces

  • kubectl get pods --all-namespaces
    • Create a pod using an image

    • kubectl run <pod-name> --image=<image-name>
      • Describe a pod

      • kubectl describe pod <pod-name>

        Services & Networking

        • Create a new service

        • kubectl expose deployment <deployment-name> --type=<service-type> --port=<port>
          • Get all services in the namespace

          • kubectl get svc

            Configuration

            • Set a context’s user and cluster

            • kubectl config set-context --current --user=<user-name> --cluster=<cluster-name>
              • View kubeconfig settings

              • kubectl config view

                Monitoring & Logging

                • Print the logs for a container in a pod

                • kubectl logs <pod-name>
                  • Stream pod logs in real-time

                  • kubectl logs -f <pod-name>

                    Resource Management

                    • List resource quotas

                    • kubectl get quota
                      • Describe resource usage on nodes

                      • kubectl top nodes

Last updated

Was this helpful?