Include the most recent 5 minutes of logs kubetail -s 5mĪnother option for modifying objects is through Manifest Files. Get logs for all pods named with pod_prefix kubetail Here are some sample commands using Kubetail. You can learn more about it at its Github repository. This is a bash script that will allow you to get logs from multiple pods simultaneously. View the logs for a previously failed pod kubectl logs -previous įor logs we also recommend using a tool developed by Johan Haleby called Kubetail. Output the logs for a pod into a file named ‘pod.log’ kubectl logs pod.log Print the logs for a container in a pod kubectl logs -c 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 -f Get the most recent 20 lines of logs kubectl logs -tail=20 Print the logs for the last hour for a pod kubectl logs -since=1h Pull events for a single node with a specific name kubectl get events -field-selector involvedObject.kind=Node, involvedObject.name=įilter out normal events from a list of events kubectl get events -field-selector type!=Normal List events but exclude Pod events kubectl get events -field-selector involvedObject.kind!=Pod List Warnings only kubectl get events -field-selector type=Warning List recent events for all resources in the system kubectl get events See the rollout status of a deployment kubectl rollout status deployment List one or more deployments kubectl get deploymentĭisplay the detailed state of one or more deployments kubectl describe deployment Įdit and update the definition of one or more deployment on the server kubectl edit deployment Ĭreate one a new deployment kubectl create deployment ĭelete deployments kubectl delete deployment Manage the rollout of a daemonset kubectl rollout daemonsetĭisplay the detailed state of daemonsets within a namespace kubectl describe ds -n List one or more daemonsets kubectl get daemonsetĮdit and update the definition of one or more daemonset kubectl edit daemonset ĭelete a daemonset kubectl delete daemonset Ĭreate a new daemonset kubectl create daemonset List everything kubectl get all -all-namespaces List the API versions that are available kubectl api-versions List the API resources that are available kubectl api-resources Get the configuration of the cluster kubectl config view IOStreams) *cobra.Display endpoint information about the master and services in the cluster kubectl cluster-infoĭisplay the Kubernetes version running on the client and server kubectl version NewCmdLogs creates a new pod logs commandįunc NewCmdLogs( f cmdutil. IOStreams, allContainers bool) * LogsOptions `), Regexpįunc NewLogsOptions( streams genericiooptions. LogsForObjectFuncĬontainerNameFromRefSpecRegexp *regexp. whether or not a container name was given via -container \nPOD or TYPE/NAME is a required argument for the logs command", logsUsageStr)ĭefaultPodLogsTimeout = 20 * time. Kubectl logs deployment/nginx -c nginx-1`)) # Return snapshot logs from container nginx-1 of a deployment named nginx # Return snapshot logs from first container of a job named hello Kubectl logs -insecure-skip-tls-verify-backend nginx # Show logs from a kubelet with an expired serving certificate # Show all logs from pod nginx written in the last hour # Display only the most recent 20 lines of output in pod nginx Kubectl logs -f -l app=nginx -all-containers=true # Begin streaming the logs from all containers in pods defined by label app=nginx # Begin streaming the logs of the ruby container in pod web-1 # Return snapshot of previous terminated ruby container logs from pod web-1 Kubectl logs -l app=nginx -all-containers=true # Return snapshot logs from all containers in pods defined by label app=nginx # Return snapshot logs from pod nginx with multi containers # Return snapshot logs from pod nginx with only one container If the pod has only one container, the container name is optional.`)) Print the logs for a container in a pod or specified resource. "k8s.io/cli-runtime/pkg/genericiooptions" "k8s.io/cli-runtime/pkg/genericclioptions" Metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Unless required by applicable law or agreed to in writing, softwareĭistributed under the License is distributed on an "AS IS" BASIS, You may not use this file except in compliance with the License. Licensed under the Apache License, Version 2.0 (the "License")
0 Comments
Leave a Reply. |