Skip to content

Instantly share code, notes, and snippets.

@LukePammant
Created October 8, 2020 23:04
Show Gist options
  • Save LukePammant/b544b347ef689e5423a25c71bc363096 to your computer and use it in GitHub Desktop.
Save LukePammant/b544b347ef689e5423a25c71bc363096 to your computer and use it in GitHub Desktop.
# Kubectl LOg regeX - quickly get the logs of container in a pod
# Examples - given a pod named `my-super-cool-long-named-pod-668d74bfcc-r46bw`
# - klox r46bw
# - klox r46bw daprd (if the pod has two containers and one named 'daprd'
klox() {
Pod=$(kubectl get pods -o name | grep -i $1)
kubectl logs $Pod $2
}
# Kubectl Describe regeX - quickly describe a pod
# Examples - given a pod named `my-super-cool-long-named-pod-668d74bfcc-r46bw`
# - kdx r46bw
# - kdx r46bw daprd (if the pod has two containers and one named 'daprd'
kdx() {
Pod=$(kubectl get pods -o name | grep -i $1)
kubectl describe $Pod $2
}
# Kubectl EXec regeX - quickly open bash container
# Examples - given a pod named `my-super-cool-long-named-pod-668d74bfcc-r46bw`
# - kexx r46bw
# - kexx r46bw daprd (if the pod has two containers and one named 'daprd'
kexx() {
Pod=$(kubectl get pods -o name | grep -i $1)
kubectl exec -it $Pod $2 -- bash
}
# Creates an image for a failed bulid step and executes a shell prmpt into it. Useful to debug failed build steps when making a Dockerfile.
# Example -
# Step 12/28 : RUN dotnet build "./MySuperCoolProject.Web.sln" -c Debug -o /out
# ---> Running in 790491323a38
# You can run `debugContainer 790491323a38` and see what folders are present, etc. to see why the build is failing
debugContainer() {
docker commit $1 tempdebugimage
docker run -ti --rm tempdebugimage bash
docker image rm tempdebugimage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment