Last active
September 14, 2024 08:47
-
-
Save vfarcic/9d9de2cf93b6514ab8cf8fed56542352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/vfarcic/9d9de2cf93b6514ab8cf8fed56542352 | |
################################################################## | |
# How to Debug Kubernetes Applications With Ephemeral Containers # | |
# https://youtu.be/qKb6loAEPV0 # | |
################################################################## | |
# Additional Info: | |
# - Containers Are Not VMs! Which Base Container (Docker) Images Should We Use?: https://youtu.be/82ZCJw9poxM | |
# - Is Timoni With CUE a Helm Replacement?: https://youtu.be/bbE1BFCs548 | |
######### | |
# Setup # | |
######### | |
# Create a Kubernetes cluster (any should do starting from | |
# v1.25). | |
# Please watch https://youtu.be/bbE1BFCs548 if you are not | |
# familiar with Timoni. | |
timoni --namespace demo apply silly-demo \ | |
oci://c8n.io/vfarcic/silly-demo-package --version 1.4.37 | |
export POD=$(kubectl --namespace demo get pods \ | |
--selector app.kubernetes.io/name=silly-demo \ | |
--output jsonpath='{.items[0].metadata.name}') | |
######## | |
# Demo # | |
######## | |
kubectl --namespace demo exec -it $POD -- sh | |
kubectl --namespace demo debug $POD --image alpine \ | |
--stdin --tty --target silly-demo | |
ps aux | |
exit | |
kubectl --namespace demo get pod $POD --output yaml | |
kubectl --namespace demo debug $POD --image alpine \ | |
--stdin --tty --share-processes --copy-to silly-demo-debug | |
ps aux | |
exit | |
kubectl --namespace demo delete pod silly-demo-debug | |
########### | |
# Destroy # | |
########### | |
# Destroy or reset the cluster. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment