How to implement troubleshooting in Service by kubernetes
This article mainly shows you "kubernetes how to achieve troubleshooting in Service", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "kubernetes how to achieve troubleshooting in Service" this article.
1. View the definition and usage of a resource
Kubectl explain
Kubectl explain pod
DESCRIPTION:
Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.
FIELDS:
ApiVersion
APIVersion defines the versioned schema of this representation of an
Object. Servers should convert recognized schemas to the latest internal
Value, and may reject unrecognized values. More info:
Https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
Kind
Kind is a string value representing the REST resource this object
Represents. Servers may infer this from the endpoint the client submits
Requests to. Cannot be updated. In CamelCase. More info:
Https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
Metadata
Standard object
two。 View the status of Pod
Kubectl get pods
Kubectl describe pods my-pod
3. Monitor changes in Pod statu
Kubectl get pod-w
You can see the phase changes for all the pod in a namespace.
4. View Pod's log
Kubectl logs my-pod
Kubectl logs my-pod-c my-container
Kubectl logs-f my-pod
Kubectl logs-f my-pod-c my-container
5. Interactive Debug
Kubectl exec my-pod-it / bin/bash
Kubectl top pod POD_NAME-containers
6.Pod 's last words
The definition of Pod specifies the path to the last words log file in the container through .spec.containers [] .terminationMessagePath. The default value is / dev/termination-log. This file will be saved throughout the life cycle of Pod. Each time a new Pod is created, a file will be created on the host and then mounted to the Pod container. These files will not be lost due to the destruction of the container, so the container can write the last words to this file to facilitate troubleshooting.
These are all the contents of the article "how to troubleshoot kubernetes in Service". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!