tmate.io sesions on Cloud Foundry

398 views
Skip to first unread message

Dan Higham

unread,
May 27, 2014, 6:14:12 PM5/27/14
to vcap...@cloudfoundry.org
Hey All,

I built a buildpack to allow tmate (shared tmux) sessions on Cloud
Foundry. It builds libevent, downloads a couple of pre-built binaries
and then starts a tmate session. The connection details for the
session are shown in the app log. Once the session is there, you can
invite other people by giving them the connection string too.

You could use this with another buildpack
(https://github.com/ddollar/heroku-buildpack-multi) to get access to
your Rails console for example or just deploy it on it's own.

I will be adding a few other features soon, like being able to spawn
other processes that can be proxied to the port the app is bound to,
which would allow your app and tmate to run on the same instance.

https://github.com/danhigham/cloudfoundry-tmate-buildpack, tl;dr
example is in the README

--
Kind Regards

Dan Higham
Pivotal Support

Rohit Kelapure

unread,
May 27, 2014, 6:35:38 PM5/27/14
to vcap...@cloudfoundry.org
Dan,

How could we use this buildpack  to debug any issues with the java based build packs (jboss, weblogic,, tomcat etc.,) ?

-cheers,
Rohit



--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/CAMaH4TZ45yekSdLta_JRneBciMMfas4H8izEbsRdz4yK3pVPPw%40mail.gmail.com.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

Dan Higham

unread,
May 27, 2014, 6:46:24 PM5/27/14
to vcap...@cloudfoundry.org
I'm not really a java developer but this buildpack can allow shell
access via tmate/tmux to your application instance running on Cloud
Foundry. So, whatever you can do from bash with your Java app locally
you can do remotely too.
> https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/CAJ%3DGf1UNgR-QmcU8Nze4PUHLSQHViE0me7C4do0A99KKzCmz4g%40mail.gmail.com.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vcap-dev+u...@cloudfoundry.org.



James Bayer

unread,
May 29, 2014, 1:14:32 AM5/29/14
to vcap...@cloudfoundry.org

it looks like it is be possible to use this tmate buildpack in a layered manner with heroku-buildpack-multi [1] and something my gist [2] or forego [3] to start multiple processes in the container and troubleshoot cloud foundry apps over tmux.

see attached where i did a simple proof of concept with ruby. i haven't tried a java app yet with port forwarding for jmx, but that should be straight-forward to try.

using an approach like dan mikusa wrote about in feb [4], you can probably get this down to a simple CLI / manifest command substitution instead of using layered buildpacks.

if you don't trust tmate.io (why would you want a man in the middle that you don't know!) it looks like it's pretty straight forward to run a tmate-slave server [5] 

[5] https://github.com/nviennot/tmate-slave




To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Thank you,

James Bayer

James Bayer

unread,
May 29, 2014, 3:39:50 PM5/29/14
to vcap...@cloudfoundry.org

dan higham has set up an awesome simplification of this process where you only need to change one thing now to get an ssh session to your container, which is the command used to start your app, which pulls down tmate dependencies as your container starts and starts a user-specified process, which could be your actual app or a dummy process which just lets you type commands within your container/droplet.

cf push james-java -c "curl http://tmate-bootstrap.cfapps.io?cmd=ls | sh" --no-route

or using a manifest like

---
applications:
- name: james-java
  memory: 512M
  instances: 1
  path: JavaTinyApp-1.1.war
  command: curl http://tmate-bootstrap.cfapps.io?cmd=ls | sh

if you know the actual command of the app you want to use, then you can supply it as an HTTP encoded value to the cmd param or just use a simple one like "ls". i think there are limits on the length of the command. tmate will reverse proxy to port 8080 in your container, so make sure to use that as your app port instead of $PORT. also, don't map a route or CF will try to make sure that the $PORT that is assigned is listening. check the output of the app using 'cf logs APPNAME --recent' and then ssh to that identifier in the logs as shown here [1]. really cool dan!

[1] https://gist.github.com/jbayer/efbd5232e5c911ddfc36


Dan Higham

unread,
May 29, 2014, 5:16:44 PM5/29/14
to vcap...@cloudfoundry.org
Just made changes so you don't have to specify a command at all if don't want to!



To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

Dr Nic Williams

unread,
Jul 13, 2014, 9:51:58 PM7/13/14
to vcap...@cloudfoundry.org
This is awesome Dan!

And thanks JamesB for pointing to me to this thread which I missed.

Warning: do not run the "cf push" command and use the same app name as your running production app name :) Perhaps suffix -ssh or -tmate to your app name so its guaranteed to be a fresh app and container; and not replace your running production app with routeless, web app-less containers like I did to the https://blog.starkandwayne.com company blog for 5 minutes. Yeah, I'm a pro.

Filip Hanik

unread,
Apr 24, 2015, 12:16:12 PM4/24/15
to vcap...@cloudfoundry.org, dhi...@gopivotal.com
2015-04-24T10:12:56.68-0600 [App/0]      OUT include
2015-04-24T10:12:56.68-0600 [App/0]      OUT lib
2015-04-24T10:12:56.68-0600 [App/0]      OUT LICENSE
2015-04-24T10:12:56.68-0600 [App/0]      OUT mail
2015-04-24T10:12:56.68-0600 [App/0]      OUT main.go
2015-04-24T10:12:56.68-0600 [App/0]      OUT metrics
2015-04-24T10:12:56.68-0600 [App/0]      OUT models
2015-04-24T10:12:56.68-0600 [App/0]      OUT payload.tgz
2015-04-24T10:12:56.68-0600 [App/0]      OUT postal
2015-04-24T10:12:56.68-0600 [App/0]      OUT README.md
2015-04-24T10:12:56.68-0600 [App/0]      OUT templates
2015-04-24T10:12:56.68-0600 [App/0]      OUT valiant
2015-04-24T10:12:56.68-0600 [App/0]      OUT walkthrough.md
2015-04-24T10:12:56.68-0600 [App/0]      OUT web
2015-04-24T10:12:56.78-0600 [App/0]      OUT -----> Starting tmate...

doesn't get any further than that. Shouldn't it be printing out SSH login info?

Filip

Dan Higham

unread,
Apr 24, 2015, 2:12:18 PM4/24/15
to Filip Hanik, vcap...@cloudfoundry.org, Dan Higham
Hey Filip,

The recent switch to cflinuxfs2 broke the plugin. I will be working on a fix, it basically requires adding in a bunch of libraries that are missing (libssl etc)

James Bayer

unread,
Apr 25, 2015, 6:47:36 AM4/25/15
to vcap...@cloudfoundry.org, Filip Hanik, Dan Higham
i believe dan said he fixed this now, but i haven't verified it yet.


To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

Filip Hanik

unread,
Apr 27, 2015, 4:36:39 PM4/27/15
to vcap...@cloudfoundry.org, fha...@pivotal.io, dhi...@gopivotal.com
I've verified that it isn't working

Dan Higham

unread,
Apr 27, 2015, 4:51:14 PM4/27/15
to Filip Hanik, vcap...@cloudfoundry.org, Dan Higham
Spoke to Filip, he was using it with a diego cell, which I have confirmed doesn't work.

Filip Hanik

unread,
Apr 27, 2015, 8:10:10 PM4/27/15
to vcap...@cloudfoundry.org, dhi...@pivotal.io, dhi...@gopivotal.com, fha...@pivotal.io
Ok, everything previously said in this thread seems obsolete, I was informed of the new way

1. Update to latest cf
2. cf add-plugin-repo main-repo http://plugins.cfapps.io
3. cf install-plugin Console -r main-repo
4. cf push <app-name> --no-route (or any other preferred flags)
5. cf console <app-name> 

command 5 doesn't work on my ubuntu, but does on mac. 

Rohit Kelapure

unread,
Apr 28, 2015, 3:41:24 PM4/28/15
to vcap...@cloudfoundry.org, dhi...@pivotal.io, dhi...@gopivotal.com, fha...@pivotal.io
I did upgrade cf-cli to to 6.11.2-2a26d55-2015-04-27T21:11:49+00:00 ; however the console plugin does not work on my mac following the instructions above.

Rohits-MacBook-Pro:FizzBuzz rkelapure$ cf console fizzbuzz

> Finding app guid for fizzbuzz ... e201337d-58d1-4d96-afbf-bb8a6570c6e1 

> Updating app to connect to tmate.

> Updating app start command to 'curl -s https://raw.githubusercontent.com/danhigham/cf-console/master/install.sh > /tmp/install.sh && bash /tmp/install.sh && sleep 3600'.

> Changing instance count to 2.

> Checking app log datestamps.

> Waiting for SSH endpoint.

> SSHing to SAtogb7WI65y...@ny.tmate.io

> Changing instance count to 1.

> Updating app start command to ''.

Rohits-MacBook-Pro:FizzBuzz rkelapure$ 


When I run the same command with sudo I see

accept tcp 127.0.0.1:55463: too many open files

after > Waiting for SSH endpoint.

-Thanks,

Rohit


Dan Higham

unread,
Apr 28, 2015, 4:28:46 PM4/28/15
to Rohit Kelapure, vcap...@cloudfoundry.org, Dan Higham, Filip Hanik
Hey Rohit, do you have an ssh identity? Try running ssh-keygen and the trying again.

Rohit Kelapure

unread,
Apr 28, 2015, 5:49:42 PM4/28/15
to vcap...@cloudfoundry.org, fha...@pivotal.io, dhi...@gopivotal.com, kela...@gmail.com, dhi...@pivotal.io
Dan,

Tried that as well. Is there a way to sanity check the ssh configuration ?

-Thanks,
Rohit

Dan Higham

unread,
Apr 28, 2015, 5:53:00 PM4/28/15
to Rohit Kelapure, vcap...@cloudfoundry.org, Filip Hanik, Dan Higham, Rohit Kelapure
What happens if you try and ssh to the address manually? Are you behind any sort of firewall or proxy that's not allowing outbound SSH?

Rohit Kelapure

unread,
Apr 28, 2015, 6:11:36 PM4/28/15
to Dan Higham, Rohit Kelapure, vcap...@cloudfoundry.org, Filip Hanik, Dan Higham
Dan,

You are right, generating ssh-keygen fixed the issue. When running ssh-keygen 
I was not choosing the defaults and hence the ssh keys was not named id_rsa and id_rsa.pub.

-Thanks,
Rohit

Reply all
Reply to author
Forward
0 new messages