GithubHelp home page GithubHelp logo

negotiator's Introduction

Not currently under active development

Negotiator

Negotiates between an RHMAP core and a OpenShift master. It understands both. It uses the OpenShift client and Kubernetes client to directly interact with the Kubernetes API and OpenShift API. For example when a new cloud app from RHMAP needs to be deployed or a new environment needs to be created, a request will be sent to negotiator with the details required such as a giturl, an auth token, env vars etc. Negotiator will take care of turning this into the required OpenShift Objects and sending them on to OpenShift / Kubernetes directly.

Try it out locally.

  • ensure go 1.7 or greater installed
  • clone this repo into $GOPATH/src/github.com/feedhenry/negotiator
  • cd $GOPATH/src/github.com/feedhenry/negotiator/cmd/negotiator
  • go build (will be slow the first time but faster afterwards as we have to vendor kubernetes and oscp)
  • ./negotiator

In a separate terminal run the following

oc new-project se
curl http://localhost:3000/deploy/se/cloudapp -H Content-type:application/json -d '{"repo": {"loc": "https://github.com/feedhenry/testing-cloud-app.git","ref": "master"}, "target":{"host":"AN OPENSHIFT MASTER","token":"AN OPENSHIFT TOKEN"}, "serviceName": "cloudapp4","replicas": 1,  "projectGuid":"test","envVars":[{"name":"test","value":"test"}]}'

curl http://localhost:3000/deploy/se/cache -H Content-type:application/json -d '{"serviceName": "cache","replicas": 1,  "projectGuid":"test", "target":{"host":"AN OPENSHIFT MASTER","token":"AN OPENSHIFT TOKEN"}}'

Using the cli


cd $GOPATH/src/github.com/feedhenry/negotiator/cmd/services 
go install . 
services deploy -h 

Developing

  • install glide package manager curl https://glide.sh/get | sh

All dependencies are vendored so you shouldn't need to update or install.

Layout:

.
├── config
│
├── cmd # where the main.go for the server and cli are located
│
├── deploy #domain specfic logic for deployment
│   ├── template.go # deploys templates to OpenShift
│   
└── pkg
│    └── openshift # pkg for making the openshift and kubernetes client more simple to work with. Our domain logic does not go here##handlers go in the root dir and deal with http specific logic 
│  
└── web 
     └── deploy.go 
     └── sys.go      

Test

make test-unit 

build and publish

env GOOS=linux go build .

docker build -t rhmap/negotiator:0.0.1 . ##change build number

docker tag rhmap/negotiator:0.0.1 rhmap/negotiator:latest

docker push rhmap/negotiator:0.0.1

Run in OpenShift

oc new-app -f os_template.json

negotiator's People

Contributors

maleck13 avatar philbrookes avatar philipgough avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

negotiator's Issues

Should it work?

Hey @maleck13 and @philbrookes,

this looks awesome!

I'm not sure about the current functionality of this guy - readme says "currently it just sets up a service, a route and an imagestream", but I see some commits about adding BuildConfig and DeploymentConfig, so I'm not sure if it should currently work...?

By following the instructions, the tool created imagestream, services, route, secrets and dc for redis.
However it failed on creating BuildConfig for cloud-testguid:

failed to create BuildConfig: BuildConfig "cloud-testguid" is invalid: spec.source.git.uri: Required value

When I run unit tests, I get the following:

> $ make test-unit                                                                               ⬡ 0.10.42 [±master ✓]
go test -v -cpu=2 `go list ./... | grep -v /vendor/`
?   	github.com/feedhenry/negotiator	[no test files]
?   	github.com/feedhenry/negotiator/config	[no test files]
?   	github.com/feedhenry/negotiator/controller	[no test files]
# github.com/feedhenry/negotiator/domain/openshift_test
domain/openshift/service_test.go:135: cannot use mockClient (type MockPassClient) as type openshift.PaaSClient in argument to openshift.NewService:
	MockPassClient does not implement openshift.PaaSClient (missing CreateBuildConfigInNamespace method)
domain/openshift/service_test.go:136: too many arguments in call to underTest.CreateService
domain/openshift/service_test.go:136: assignment count mismatch: 2 = 1
FAIL	github.com/feedhenry/negotiator/domain/openshift [build failed]
testing: warning: no tests to run
PASS
ok  	github.com/feedhenry/negotiator/domain/rhmap	0.009s
?   	github.com/feedhenry/negotiator/endpoint	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/feedhenry/negotiator/pkg/openshift	0.026s
make: *** [test-unit] Error 2

Thanks!

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.