chore(kb/k8s): add best practice to save logs somewhere else

This commit is contained in:
Michele Cereda
2024-11-05 08:52:00 +01:00
parent 6fd6bce31e
commit 2d8d29087d
2 changed files with 3 additions and 1 deletions

View File

@@ -243,6 +243,7 @@ Also see [configuration best practices] and the [production best practices check
Leverage [Namespaces]. Leverage [Namespaces].
- Consider **organizing** cluster and workload resources.<br/> - Consider **organizing** cluster and workload resources.<br/>
Leverage [Labels][labels and selectors]; see [recommended Labels]. Leverage [Labels][labels and selectors]; see [recommended Labels].
- Consider forwarding logs to a central log management system for better storage and easier access.
- Avoid sending traffic to pods which are not ready to manage it.<br/> - Avoid sending traffic to pods which are not ready to manage it.<br/>
[Readiness probes][Configure Liveness, Readiness and Startup Probes] signal services to not forward requests until the [Readiness probes][Configure Liveness, Readiness and Startup Probes] signal services to not forward requests until the
probe verifies its own pod is up.<br/> probe verifies its own pod is up.<br/>
@@ -254,7 +255,7 @@ Also see [configuration best practices] and the [production best practices check
- Prefer smaller container images. - Prefer smaller container images.
- Prioritize critical workloads.<br/> - Prioritize critical workloads.<br/>
Leverage [quality of service](#quality-of-service). Leverage [quality of service](#quality-of-service).
- Instrument applications to detect and respond to the SIGTERM signal. - Instrument workloads to detect and respond to the `SIGTERM` signal to allow them to safely and cleanly shutdown.
- Avoid using bare pods.<br/> - Avoid using bare pods.<br/>
Prefer defining them as part of a replica-based resource, like Deployments, StatefulSets, ReplicaSets or DaemonSets. Prefer defining them as part of a replica-based resource, like Deployments, StatefulSets, ReplicaSets or DaemonSets.
- Leverage [autoscalers](#autoscaling). - Leverage [autoscalers](#autoscaling).

View File

@@ -363,6 +363,7 @@ kubectl logs -f -l 'name=myLabel' --all-containers
# Get Logs for a previous instantiation of a Container. # Get Logs for a previous instantiation of a Container.
kubectl logs 'nginx' --previous kubectl logs 'nginx' --previous
kubectl logs 'nginx' -p -c 'init'
# Get the Logs of the first Pod matching 'ID'. # Get the Logs of the first Pod matching 'ID'.
kubectl logs $(kubectl get pods --no-headers | grep $ID | awk '{print $2}') kubectl logs $(kubectl get pods --no-headers | grep $ID | awk '{print $2}')