- Create Resource: kubectl create -f <filename> - Create a resource from a YAML file.
- Apply Configuration: kubectl apply -f <filename> - Apply a configuration to a resource from a YAML file.
- Get Resources: kubectl get <resource> - Retrieve resources (pods, deployments, services, etc.).
- Describe Resource: kubectl describe <resource> <resource_name> - Show details of a specific resource.
- Delete Resource: kubectl delete -f <filename> - Delete resources defined in a YAML file.
- List Pods: kubectl get pods - List all pods in the current namespace.
- Pod Logs: kubectl logs <pod_name> - Print logs for a specific pod.
- Execute Command in Pod: kubectl exec -it <pod_name> -- <command> - Execute a command in a running pod.
- Port Forwarding: kubectl port-forward <pod_name> <local_port>:<pod_port> - Forward a local port to a pod.
- Create Pod: kubectl run <pod_name> --image=<image_name> - Create a pod imperatively.
- List Deployments: kubectl get deployments - List all deployments in the current namespace.
- Scale Deployment: kubectl scale --replicas=<replica_count> deployment/<deployment_name> - Scale a deployment to a specific number of replicas.
- Rollout Status: kubectl rollout status deployment/<deployment_name> - Check the status of a deployment rollout.
- Rollout History: kubectl rollout history deployment/<deployment_name> - View the history of a deployment rollout.
- Rollback Deployment: kubectl rollout undo deployment/<deployment_name> - Rollback a deployment to the previous version.
- List Services: kubectl get services - List all services in the current namespace.
- Expose Service: kubectl expose deployment/<deployment_name> --port=<port> - Expose a deployment as a service.
- List Namespaces: kubectl get namespaces - List all namespaces in the cluster.
- Switch Namespace: kubectl config set-context --current --namespace=<namespace> - Switch to a different namespace.
- Edit Resource: kubectl edit <resource> <resource_name> - Edit a resource in real-time using the default editor.
- Describe Node: kubectl describe node <node_name> - Show details of a specific node.
- Describe Pod: kubectl describe pod <pod_name> - Show details of a specific pod.
- Top Resources: kubectl top <resource> - Display resource usage statistics (CPU, memory) for pods or nodes.
- Get Events: kubectl get events - Display events from the cluster.
- 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.
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.