正在为远程Erlang节点运行观察程序:使其更简单

f4t66c6m  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(138)

I have a kubernetes cluster.
I can easily connect to a remote container, and run a shell node connecting to live production erlang node:

$ kubectl exec myapp-2431125679-cwqvt -i -t -- iex --name debugging@127.0.0.1 --remsh myliveapp@127.0.0.1 --cookie my_secret_cookie

Erlang/OTP 18 [erts-7.3.1] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]

Interactive Elixir (1.3.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(myliveapp@127.0.0.1)1>

What I need though is to be able to run an :observer against a remote live production erlang node.
I can do that too:

  1. kill local epmd process:
killall epmd
  1. forward selected remote ports to my local machine:
kubectl port-forward myapp-2431125679-cwqvt 35609 4369

I know that my app runs on port 35609 on a remote container, and 4369 is the port epmd runs by default, which is the case for my remote container.

  1. run:
iex --name debugging@127.0.0.1 --cookie marketplace -e ':observer.start()'
  1. select the app I'm interested in from the top menu in :observer .
    My questions are:
  2. can this be done simpler?
  3. is there anything I should know about kubernetes, to make it possible to write a one-liner that'd connect to a remote node and do what I want?
    Ultimately, can I make this process a one-liner or turn it into a shell script?
    Right now killing epmd looks really-really dirty, I'd love to be able avoid that specifically.
s4n0splo

s4n0splo1#

是的,你可以把它变成一个shell脚本。我确实为这个用例创建了一个shell脚本,但是我使用的是SSH。我的方法看起来和你的一样,而且我必须在本地杀死epmd。但是我能够把它 Package 成一个bash脚本。你可以在这里获得它:https://github.com/dominicletz/remote_observe/
该脚本还自动发现远程波束端口。
remote_observe -c <cookie> <server-address>
我手边没有Kubernetes部署可以尝试,但它可能很容易移植到调用kubectl port-forward <server-address> <port>,而不是当前的ssh转发。

相关问题