Get information about your app
You can get information about your app, your app deployment, and the pods and containers in your app.
Most of the following examples use the Kubernetes command-line tool, kubectl
.
Choose and set a namespace
All the GOV.UK applications are in the apps
namespace. You can avoid having to specify this (-n apps
) in every kubectl
command by setting apps
as your default namespace:
kubectl config set-context --current --namespace=apps
Get a list of all deployed apps in a namespace
To get a list of all deployed apps, run:
kubectl -n apps get deployments
Describe an app deployment
To describe an app deployment, run:
kubectl -n <namespace> describe deployment <deployment>
The output includes information like the pod template, the containers, and the environment variables.
List all pods in an app
To list all pods running in an app, run:
kubectl -n <namespace> get pods
Describe a pod
To describe a pod in an app, run:
kubectl -n <namespace> describe pod <pod>
The output includes information on everything that Kubernetes uses to run the pod, for example:
- pod image
- pod host
- resource limits
- readiness checks
- environment variables
View app logs
To view the logs of all running containers in a specific pod, run:
kubectl -n <namespace> logs <pod>
To view the logs of a specific container for a pod, run:
kubectl -n <namespace> logs <pod> -c <container>
To view the logs for all containers in a given app deployment, run:
kubectl logs -n apps deploy/<deployment> <container>
You can also view logs in Logit.
- Access Logit by following the Reliability Engineering documentation on getting started with Logit.
- In the Logit dashboard, find the EKS stack you want to view the logs for. For example GOV.UK INTEGRATION EKS.
- Select LAUNCH KIBANA in the appropriate EKS stack.
You can filter the logs in Logit by app, pod, container and other parameters.
View Kubernetes events
An event is any action that Kubernetes takes. For example, starting a pod, pulling an image, a pod crashing.
Viewing Kubernetes events is helpful for debugging an app.
Via logit
Events are stored in Logit for 14 days in production, and 7 days in other environments. They are stored in an ElasticSearch index with the name prefix of kubernetes-events-
.
In logit, when viewing Kibana, on the left side of the interface there is a dropdown box which defaults to filebeat-*
, you should change this to kubernetes-events-*
, alternatively you can use the links below:
- Kubernetes Events in Logit for Production
- Kubernetes Events in Logit for Staging
- Kubernetes Events in Logit for Integration
Logit supports querying via either the Lucene syntax, or the DQL syntax, to the right of the search box it will show you which you are set to, all the following queries use DQL, to do them in lucene the syntax is field = value
instead of field: value
.
To see Kubernetes events for a namespace, search for:
involvedObject.namespace: "<namespace>"
To get events for a specific Kubernetes resource, search for:
involvedObject.name: "<resource>"
For example, to get events for the pod publisher-7795bd698-v6bfc
, search for:
involvedObject.name: "publisher-7795bd698-v6bfc"
Via kubectl (only the last 1 hour)
Logs are available via the cli for only 1 hour, if you wish to see logs older than this you should view them using Logit
To see Kubernetes events for a namespace, run:
kubectl -n <namespace> get events
To get events for a specific Kubernetes resource, run:
kubectl -n apps get events --field-selector=involvedObject.name=<resource>
For example, to get events for the pod publisher-7795bd698-v6bfc
, run:
kubectl -n apps get events --field-selector=involvedObject.name=publisher-7795bd698-v6bfc
Further information
For more information on kubectl
, see the Kubernetes kubectl documentation.
For more information on Logit, see the Reliability Engineering documentation on logging.