Troubleshooting
Debugging a Kubernetes Application
-
Check Pod Logs:
-
Use
kubectl logs <pod-name>to view the logs of a specific pod. -
Example:
kubectl logs my-app-pod
-
-
Describe the Pod:
-
Use
kubectl describe pod <pod-name>to get detailed information about the pod. -
Example:
kubectl describe pod my-app-pod
-
-
Check Pod Events:
-
Events can provide insights into issues like scheduling problems or container crashes.
-
Example:
kubectl get events --sort-by='.metadata.creationTimestamp'
-
-
Exec into the Pod:
-
Use
kubectl exec -it <pod-name> -- /bin/shto get a shell inside the pod for further investigation. -
Example:
kubectl exec -it my-app-pod -- /bin/sh
-
Debugging a GitLab CI Script
-
Validate
.gitlab-ci.yml:-
Use the CI Lint tool in GitLab to validate your
.gitlab-ci.ymlfile. -
Example:
# In GitLab UI, go to CI/CD > Pipelines > CI Lint
-
-
Check Pipeline Logs:
-
Review the logs of each job in the pipeline to identify errors.
-
Example:
# In GitLab UI, go to CI/CD > Pipelines > Jobs > [Job Name]
-
-
Use Debug Tracing:
-
Enable debug tracing by setting the
CI_DEBUG_TRACEvariable totrue. -
Example:
variables:
CI_DEBUG_TRACE: "true"
-
-
Run Jobs Locally:
-
Use the GitLab Runner to run jobs locally for debugging.
-
Example:
gitlab-runner exec docker <job-name>
Debugging an ArgoCD Application
To debug an ArgoCD application using the UI, follow these steps:
-
Select the Application:
- Once logged in, you will see a list of applications. Click on the application you want to debug.
-
Check Application Status:
- The application details page will show the current status of the application, including whether it is
SyncedorOutOfSync, and any health status likeHealthyorDegraded.
- The application details page will show the current status of the application, including whether it is
-
Sync the Application:
- If the application is out of sync, you can manually sync it by clicking the
Syncbutton. This will synchronize the application's state with the desired state defined in the Git repository.
TipSometimes, giving the Application an
Hard Refreshmight be useful. The button can be found by clicking the little arrow pointing downwards next to theRefreshbutton. - If the application is out of sync, you can manually sync it by clicking the
-
View Application Logs:
- To view logs, navigate to the
Podssection under theResourcestab. Click on the specific pod you are interested in, and then click on theLogstab to see the logs for that pod.
- To view logs, navigate to the
-
Check Events and Conditions:
- Under the
Eventstab, you can see events related to the application. This can help identify issues such as failed deployments or resource constraints.
- Under the
-
Check Events and Conditions in the cluster:
-
Use
kubectl get eventsandkubectl describe <resource>to check for events and conditions affecting the application. -
Example:
kubectl get events
kubectl describe application my-app-deployment
-