<p>I have a kubernetes cluster.</p>

<p>I can easily connect to a remote container, and run a shell node connecting to live production erlang node:</p>

<pre><code>$ 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&gt;
</code></pre>

<p>What I need though is to be able to <strong>run an <code>:observer</code> against a remote live production erlang node</strong>.</p>

<p>I can do that too:</p>

<ol>
<li><p>kill local <code>epmd</code> process:</p>

<pre><code>killall epmd
</code></pre></li>
<li><p>forward selected remote ports to my local machine:</p>

<pre><code>kubectl port-forward myapp-2431125679-cwqvt 35609 4369
</code></pre>

<p>I know that my app runs on port 35609 on a remote container, and 4369 is the port <code>epmd</code> runs by default, which is the case for my remote container.</p></li>
<li><p>run:</p>

<pre><code>iex --name debugging@127.0.0.1 --cookie marketplace -e ':observer.start()'
</code></pre></li>
<li><p>select the app I'm interested in from the top menu in <code>:observer</code>.</p></li>
</ol>

<p>My questions are:</p>

<ol>
<li><strong>can this be done simpler</strong>?</li>
<li><strong>is there anything I should know about kubernetes</strong>, to make it possible to write a one-liner that'd connect to a remote node and do what I want?</li>
</ol>

<p>Ultimately, can I make this process a one-liner or turn it into a shell script?</p>

<p>Right now killing <code>epmd</code> looks really-really dirty, I'd love to be able avoid that specifically.</p>

<p>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: <a href="https://github.com/dominicletz/remote_observe/" rel="nofollow noreferrer">https://github.com/dominicletz/remote_observe/</a></p>
<p>The script also does auto-discovery of the remote beam port. So you end up with one line:</p>
<p><code>remote_observe -c &lt;cookie&gt; &lt;server-address&gt;</code></p>
<p>I don't have a Kubernetes deployment handy to try but it can probably easily ported to call the <code>kubectl port-forward &lt;server-address&gt; &lt;port&gt;</code> instead of the current ssh forwards.</p>
