Skip to content

Instantly share code, notes, and snippets.

@reloni
Last active January 5, 2020 12:30
Show Gist options
  • Save reloni/8367063d523d3b7d555c621752369ab1 to your computer and use it in GitHub Desktop.
Save reloni/8367063d523d3b7d555c621752369ab1 to your computer and use it in GitHub Desktop.
Kubernetes tricks
Get container last termination message:
kubectl get pod gotest-app-morty-5d6f6667c4-8bffb -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"
Get events sorted by date:
kubectl get event --sort-by .lastTimestamp
Get events sorted, filtered by deployment name:
kubectl get event --sort-by .lastTimestamp --field-selector involvedObject.name=go-static-files-rick
Get logs filtered by label (suitable for deployments):
kubectl logs -l app=elasticsearch
kubectl logs deployment/gotest-app-morty --since=10m
Create opaque secret:
kubectl create secret generic backend-user --from-literal=backend-username='backend-admin'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment