Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running observer for a remote erlang node: making it simpler

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 [email protected] --remsh [email protected] --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([email protected])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
    
  2. 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.

  3. run:

    iex --name [email protected] --cookie marketplace -e ':observer.start()'
    
  4. select the app I'm interested in from the top menu in :observer.

My questions are:

  1. can this be done simpler?
  2. 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.

like image 914
gmile Avatar asked Feb 02 '17 09:02

gmile


1 Answers

Yes you can turn it into a shell script. I did create a shell script for this use-case but am using SSH. My approach looks the same as yours, also I have to kill epmd locally. But I was able to wrap it into a bash script. You can grab it here: https://github.com/dominicletz/remote_observe/

The script also does auto-discovery of the remote beam port. So you end up with one line:

remote_observe -c <cookie> <server-address>

I don't have a Kubernetes deployment handy to try but it can probably easily ported to call the kubectl port-forward <server-address> <port> instead of the current ssh forwards.

like image 124
Dominic Avatar answered Oct 25 '22 02:10

Dominic