Kubectl get contexts6/11/2023 ![]() Kubectl top pod – Display Resource usage (CPU/Memory/Storage) for pods. Kubectl exec -it /bin/sh – Get an interactive shell on a single-container pod. Read more: Using Kubectl Exec: Connect to Your Kubernetes Containers Kubectl exec -c – Execute a command against a container in a pod. Kubectl describe pod – Display the detailed state of a pods. ![]() Kubectl get pods -field-selector=status.phase=Running – Get all running pods in the namespace. Kubectl get pods -sort-by='.' – List pods Sorted by Restart Count. You can also inject ephemeral containers for debugging if your cluster offers this. As well as application containers, a Pod can contain init containers that run during Pod startup. In non-cloud contexts, applications executed on the same physical or virtual machine are analogous to cloud applications executed on the same logical host. A Pod models an application-specific “logical host”: it contains one or more application containers which are relatively tightly coupled. A Pod’s contents are always co-located and co-scheduled, and run in a shared context. A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. Pods – Pods are the smallest deployable units of computing that you can create and manage in Kubernetes. Kubectl label node – Add or update the labels of one or more nodes. Kubectl drain node – Drain a node in preparation for maintenance. Kubectl uncordon node – Mark node as schedulable. Kubectl cordon node – Mark a node as unschedulable. Kubectl get pods -o wide | grep – Pods running on a node. Kubectl top node – Display Resource usage (CPU/Memory/Storage) for nodes. Kubectl delete node – Delete a node or multiple nodes. Kubectl get node – List one or more nodes. Kubectl taint node – Update the taints on one or more nodes. The components on a node include the kubelet, a container runtime, and the kube-proxy. Typically you have several nodes in a cluster in a learning or resource-limited environment, you might have only one node. Each node is managed by the control plane and contains the services necessary to run Pods. A node may be a virtual or physical machine, depending on the cluster. Nodes – Kubernetes runs your workload by placing containers into Pods to run on Nodes. Kubectl logs -previous – View the logs for a previously failed pod. Kubectl logs pod.log – Output the logs for a pod into a file named ‘pod.log’. Kubectl logs -c – Print the logs for a container in a pod. Kubectl logs -f – Print the logs for a pod and follow new logs. Kubectl logs -f – Get logs from a service and optionally select which container. ![]() Kubectl logs -tail=50 – Get the most recent 50 lines of logs. Kubectl logs -since=6h – Print the logs for the last 6 hours for a pod. Logs can be as coarse-grained as showing errors within a component, or as fine-grained as showing step-by-step traces of events (like HTTP access logs, pod state changes, controller actions, or scheduler decisions). You can configure log verbosity to see more or less detail. Logs – System component logs record events happening in cluster, which can be very useful for debugging. Read more about Kubernetes deployment strategies: Different Types of Kubernetes Deployment Strategies (Examples) Kubectl replace -force -f – Perform a replace deployment - Force replace, delete and then re-create the resource. Kubectl rollout undo deployment/ – Rollback a previous deployment. Kubectl set image deployment/ =image: – Perform a rolling update (K8S default), set the image of the container to a new version for a particular deployment. Kubectl rollout status deployment – See the rollout status of a deployment. Kubectl delete deployment – Delete deployments. Kubectl create deployment – Create a new deployment. Kubectl edit deployment – Edit and update the definition of one or more deployments on the server. Kubectl describe deployment – Display the detailed state of one or more deployments. Kubectl get deployment – List one or more deployments. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments. You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. Deployments – A Deployment provides declarative updates for Pods and ReplicaSets. ![]()
0 Comments
Leave a Reply. |