Giter Club home page Giter Club logo

alphagov.paas-cf-conduit's Introduction

conduit

alt text

The Cloud Foundry cli plugin that makes it easy to directly connect to your remote service instances.

Overview

  • Create tunnels to remote service instances running on Cloud Foundry to allow direct access.
  • Provides a way to invoke cli tools such as psql or mysqldump for supported service types.
  • [experimental] Enables running local Cloud Foundry application processes against live service instances by setting up a tunneled VCAP_SERVICES environment.

Installation

cf-conduit is a Cloud Foundry CLI Plugin. Cloud Foundry plugins are binaries that you download and install using the cf install-plugin command. For more general information on installing and using Cloud Foundry CLI Plugins please see Using CF CLI Plugins

To install cf-conduit:

  1. Run the following code from the command line:

    cf install-plugin conduit
    
  2. Your plugin should now be installed and you can use via:

    cf conduit --help
    

See the usage and running database tools section for examples.

Building from source

Alternatively, you can build from source. You'll need Go 1.13 or higher.

go get -u -d github.com/alphagov/paas-cf-conduit
cd $GOPATH/src/github.com/alphagov/paas-cf-conduit
make install

Usage

General help

For help from command line:

cf conduit --help

Creating tunnels

To tunnel a connection from your Cloud Foundry hosted service instance to your local machine:

cf conduit my-service-instance

You can configure multiple tunnels at the same time:

cf conduit service-1 service-2

Output from the command will report connection details for the tunnel(s) in the foreground, hit Ctrl+C to terminate the connections.

Running database tools

There is limited support for some common database service tools. It works by detecting certain service types and setting up the environment so that the tools pickup the service binding details by default.

Currently only GOV.UK PaaS RDS broker provided postgres and mysql service types are supported.

Note: You should only specify a single service-instance when using this method and you must install any required tools on your machine for this to work.

Postgres

Launch a psql shell:

cf conduit pg-instance -- psql

Export a postgres database:

cf conduit pg-instance -- pg_dump -f backup.sql

Import a postgres dump

cf conduit pg-instance -- psql < backup.sql

Copy data from one instance to another

cf conduit --local-port 7001 pg-1 -- psql -c "COPY things TO STDOUT WITH CSV HEADER DELIMITER ','" | cf conduit --local-port 8001 pg-2 -- psql -c "COPY things FROM STDIN WITH CSV HEADER DELIMITER ','"

Launch a psql shell from Docker for Mac:

cf conduit pg-instance -- docker run --rm -ti -e PGUSER -e PGPASSWORD -e PGDATABASE -e PGPORT -e PGHOST=docker.for.mac.localhost postgres:9.5-alpine psql

MySQL

Launch a mysql shell:

cf conduit mysql-instance -- mysql

Export a mysql database:

cf conduit mysql-instance -- mysqldump --result-file backup.sql some_database_name

Import a mysql dump

cf conduit mysql-instance -- mysql < backup.sql

Redis

Launch a Redis shell:

cf conduit redis-instance -- redis-cli

Run a Redis command:

cf conduit redis-instance -- redis-cli get mykey

Running local processes

A VCAP_SERVICES environment variable containing binding details for each service conduit is made available to any application given after the -- on the command line.

For example, if your Ruby based application is located at /home/myapp/app.rb and requires access to your app-db service instance you could execute it via:

cf conduit app-db -- ruby /home/myapp/app.rb

Alternatively you could drop yourself into a bash shell and work from there:

cf conduit app-db -- bash
...
bash$

Development

To run the tests, run make test

To release a new version:

  1. Checkout latest main
  2. Generate artefacts: make dist
  3. Create a new tag: git tag v0.0.xyz
  4. Push the new tag: git push --tag
  5. Create a new release via the GitHub UI with release artefacts from bin
  6. Raise a pull request via the release repo using make generate-release-yaml

alphagov.paas-cf-conduit's People

Contributors

46bit avatar alext avatar ap-hunt avatar bandesz avatar camelpunch avatar chrisfarms avatar dcarley avatar gidsg avatar henrytk avatar leeporte avatar mogds avatar paroxp avatar quis avatar richardtowers avatar rusllonrails avatar samcrang avatar surminus avatar whi-tw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.