I'm running a rails service inside a minikube cluster on my local machine. I like to throw breakpoints into my code in order to interact with the process. This doesn't work while inside Minikube. I can attach to the pod running my rails container and hit the binding.pr
statement in my code, and instead of getting an interactive breakpoint, I simply see the pry attempt to create a breakpoint, but ultimately move right past it. Anyone figure out how to get this working? I'm guessing the deployed pod itself isn't interactive.
You are trying to get interactive access to your application.
Your problem is caused by the fact that the k8s does not allocate a TTY and stdin buffer for the container by default.
I have replicated your issue and found a solution.
To get an interactive breakpoint you have to add 2 flags to your Deployment yaml to indicate that you need interactive session:
stdin: true
tty: true
Here is an example of a deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: test
name: test
spec:
selector:
matchLabels:
run: test
template:
metadata:
labels:
run: test
spec:
containers:
- image: test
name: test
stdin: true
tty: true
You can find more info about it here.
Remember to use -it option when attaching to pod, like shown below:
kubectl attach -it <pod_name>
Let me know if that helped.