GithubHelp home page GithubHelp logo

isabella232 / copilot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudfoundry-attic/copilot

0.0 0.0 0.0 82.49 MB

Supplies data from Cloud Controller and Diego for consumption by Istio Pilot

License: Apache License 2.0

Go 92.00% Ruby 6.67% Shell 0.96% Dockerfile 0.37%

copilot's Introduction

Copilot

To help Istio Pilot work with Cloud Foundry

You probably want to deploy this using Istio Release.

Development

To get started:

git clone https://github.com/cloudfoundry/copilot.git
cd copilot
go get github.com/onsi/ginkgo/ginkgo
go get github.com/golang/dep/cmd/dep
dep ensure

To run the tests:

ginkgo -r -p -race

To compile the server:

go build code.cloudfoundry.org/copilot/cmd/copilot-server

Using the Server

We are using a generic grpc client to interact with cloud controller grpc service (installation instructions below)

Setup GRPC Client

If you are developing locally, you can install grpcurl

go get -u github.com/fullstorydev/grpcurl

If you are using a cloudfoundry

  • bosh ssh to the istio-control vm and sudo su
  • grpcurl is at /var/vcap/packages/grpcurl/bin/grpcurl
  • the certs you need are in /var/vcap/jobs/pilot-discovery/config/certs/

Push an App

cf push ...

Find Diego Process GUID

Get the CAPI Process GUID:

The following example assumes the "web" process type, but you can replace that with another type if you know what you're doing.

export CAPI_PROCESS_GUID=$(cf curl "/v3/apps/$(cf curl "/v3/apps" | jq -r '.resources[] | select(.name == "<app-name>") | .guid')/processes" | jq -r '.resources[] | select(.type == "web") | .guid')
Get the CAPI Process Version:

The CAPI Process GUID is not sufficient for routing. If you want to map/delete a route, you'll need the entire <capi-process-guid>-<version> concatenation (the "Diego Process GUID"):

export APP_GUID=$(cf app <my-app> --guid) # to obtain the application guid
export CAPI_PROCESS_VERSION=$(cf curl /v2/apps/$APP_GUID | jq -r .entity.version) # to obtain the version
Construct the Diego Process GUID
export DIEGO_PROCESS_GUID="$CAPI_PROCESS_GUID-$CAPI_PROCESS_VERSION"
Get the Route Guid used by Cloud Controller

Given an existing route in cloud controller...

export CAPI_ROUTE_GUID=$(cf curl /v2/routes | jq -r '.resources[] | select(.entity.host == "<hostname-of-existing-route>").metadata.guid')

As Cloud Controller, Add a Route

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  -d '{"route": {"host": "example.com", "guid": "route-guid-a"}}' \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/UpsertRoute

As Cloud Controller, Map a Route

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  -d '{"route_mapping": {"route_guid": "route-guid-a", "capi_process_guid": "capi_guid_1"}}' \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/MapRoute

As Cloud Controller, Associate a CAPI Process with a Diego Process

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  -d '{"capi_diego_process_association": {"capi_process_guid": "capi_guid_1", "diego_process_guids": ["diego_guid_1"]}}' \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/UpsertCapiDiegoProcessAssociation

As Cloud Controller, Delete an Association between a CAPI Process and a Diego Process

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  -d '{"capi_process_guid": "capi_guid_1"}' \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/DeleteCapiDiegoProcessAssociation

As Cloud Controller, Unmap a Route

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  -d '{"route_mapping": {"capi_process_guid": "capi_guid_1", "route_guid": "route-guid-a"}}' \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/UnmapRoute

As Cloud Controller, Delete a Route

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  -d '{"guid": "route-guid-a"}' \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/DeleteRoute

As Cloud Controller, Bulk Sync Routes Between Cloud Controller and Istio

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  -d '{"route_mappings": [{"route_guid": "route-guid-1", "capi_process_guid": "capi-guid-1"}, \
  "routes": [{"host": "example.org", "guid": "route-guid-1"}], \
  "capi_diego_process_associations": [{"capi_process_guid": "capi-guid-1", "diego_process_guids": ["diego-guid-1", "diego-guid-2"]}]}' \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/BulkSync

The following endpoints are only used for debugging. They expose Copilot's internal state

List the CF Routes that Copilot knows about

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/ListCfRoutes

List the CF Route Mappings that Copilot knows about

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/ListCfRouteMappings

List the associations between CAPI Process GUIDs and Diego Process GUIDs that Copilot knows about

(running from /var/vcap/jobs/pilot-discovery/config/certs)

/var/vcap/packages/grpcurl/bin/grpcurl -cacert ./ca.crt \
  -key ./client.key \
  -cert ./client.crt \
  copilot.service.cf.internal:9001 \
  api.CloudControllerCopilot/ListCapiDiegoProcessAssociations

copilot's People

Contributors

aaronshurley avatar ameowlia avatar angelachin avatar charleshansen avatar christianang avatar christopherclark avatar flawedmatrix avatar jpalermo avatar kauzclay avatar mariash avatar moleske avatar ndhanushkodi avatar nhsieh avatar nino-k avatar rosenhouse avatar routing-ci avatar selzoc avatar shubhaat avatar tcdowney avatar tylerschultz avatar utako avatar zachgersh 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.