Skip to content

Commit

Permalink
Microbox names and namespaces
Browse files Browse the repository at this point in the history
Also switch from govendor to go modules
  • Loading branch information
danhunsaker committed Jun 18, 2023
1 parent d165bff commit 23e132c
Show file tree
Hide file tree
Showing 50 changed files with 444 additions and 576 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Nanopack
Copyright (c) 2015-2019 Nanobox, 2019-present The Microbox Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Portal
[![Build Status](https://travis-ci.org/nanopack/portal.svg)](https://travis-ci.org/nanopack/portal)
[![GoDoc](https://godoc.org/github.com/nanopack/portal?status.svg)](https://godoc.org/github.com/nanopack/portal)
# Portal
[![Build Status](https://github.com/mu-box/portal/actions/workflows/ci.yaml/badge.svg)](https://github.com/mu-box/portal/actions)
[![GoDoc](https://godoc.org/github.com/mu-box/portal?status.svg)](https://godoc.org/github.com/mu-box/portal)

Portal is an api-driven, in-kernel layer 2/3 load balancer.

## Status
Complete/Experimental
Complete

## Usage:

Expand Down Expand Up @@ -71,7 +71,7 @@ Flags:
Use "portal [command] --help" for more information about a command.
```

For usage examples, see [Api](api/README.md) and/or [Cli](commands/README.md) readme
For usage examples, see [API](api/README.md) and/or [CLI](commands/README.md) readme

### As a Server
To start portal as a server run:
Expand Down Expand Up @@ -134,10 +134,10 @@ An optional config file can also be passed on startup:
| **Post** /vips | Add new vip | json vip object | json vip object |
| **Put** /vips | Reset the list of vips | json array of vip objects | json array of vip objects |

- **service_id** is a formatted combination of service info: type-host-port. (tcp-127_0_0_3-80)
- **server_id** is a formatted combination of server info: host-port. (192_0_0_3-8080)
- **service_id** is a formatted combination of service info: type-host-port. (tcp-127_0_0_3-80)
- **server_id** is a formatted combination of server info: host-port. (192_0_0_3-8080)

For examples, see [the api's readme](api/README.md)
For examples, see [the api's readme](api/README.md)

## Data types:
### Service:
Expand Down Expand Up @@ -295,9 +295,6 @@ json:
Fields:
- **msg**: Success message

### Contributing
Portal uses [`govendor`](https://github.com/kardianos/govendor) to manage dependencies. After clone, run `govendor sync` to ensure you have the proper dependencies prior to building.

## Todo
- vip testing
- balance vips across cluster
Expand All @@ -317,4 +314,4 @@ Portal uses [`govendor`](https://github.com/kardianos/govendor) to manage depend
- Users can now add vips to portal
- Portal now uses the service host for server's hosts that are "127.0.0.1"

[![portal logo](http://nano-assets.gopagoda.io/open-src/nanobox-open-src.png)](http://nanobox.io/open-source)
[![portal logo](http://microbox.rocks/assets/open-src/microbox-open-src.png)](http://microbox.cloud/open-source)
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vi: set ft=ruby :

# determine vagrant provider
ENV['VAGRANT_DEFAULT_PROVIDER'] = ENV['NANOBOX_BUILD_VAGRANT_PROVIDER'] || 'virtualbox'
ENV['VAGRANT_DEFAULT_PROVIDER'] = ENV['MICROBOX_BUILD_VAGRANT_PROVIDER'] || 'virtualbox'

Vagrant.configure('2') do |config|

Expand All @@ -18,7 +18,7 @@ Vagrant.configure('2') do |config|
v.vmx["numvcpus"] = "1"
v.gui = false
override.vm.box = "trusty64_vmware"
override.vm.box_url = 'https://github.com/pagodabox/vagrant-packer-templates/releases/download/v0.2.0/trusty64_vmware.box'
override.vm.box_url = 'https://github.com/mu-box/vagrant-packer-templates/releases/download/v0.2.0/trusty64_vmware.box'
end

config.vm.network "private_network", type: "dhcp"
Expand Down
6 changes: 3 additions & 3 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![portal logo](http://nano-assets.gopagoda.io/readme-headers/portal.png)](http://nanobox.io/open-source#portal)
[![Build Status](https://travis-ci.org/nanopack/portal.svg)](https://travis-ci.org/nanopack/portal)
[![portal logo](http://microbox.rocks/assets/readme-headers/portal.png)](http://microbox.cloud/open-source#portal)
[![Build Status](https://github.com/mu-box/portal/actions/workflows/ci.yaml/badge.svg)](https://github.com/mu-box/portal/actions)

# Portal

Expand Down Expand Up @@ -216,4 +216,4 @@ $ curl -k -H "X-AUTH-TOKEN:" https://127.0.0.1:8443/vips \
[{"ip":"192.168.0.100","interface":"eth0","alias":"eth0:1"}]
```

[![portal logo](http://nano-assets.gopagoda.io/open-src/nanobox-open-src.png)](http://nanobox.io/open-source)
[![portal logo](http://microbox.rocks/assets/open-src/microbox-open-src.png)](http://microbox.cloud/open-source)
60 changes: 30 additions & 30 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// api handles the api routes and pertaining funtionality.
//
// | Action | Route | Description | Payload | Output |
// |--------|-----------------------------------|---------------------------------------------|---------------------------------------------|-------------------------------|
// | GET | /services | List all services | nil | json array of service objects |
// | POST | /services | Add a service | json service object | json service object |
// | PUT | /services | Reset the list of services | json array of service objects | json array of service objects |
// | PUT | /services/:svc_id | Reset the specified service | nil | json service object |
// | GET | /services/:svc_id | Get information about a service | nil | json service object |
// | DELETE | /services/:svc_id | Delete a service | nil | success message or an error |
// | GET | /services/:svc_id/servers | List all servers on a service | nil | json array of server objects |
// | POST | /services/:svc_id/servers | Add new server to a service | json server object | json server object |
// | PUT | /services/:svc_id/servers | Reset the list of servers on a service | json array of server objects | json array of server objects |
// | GET | /services/:svc_id/servers/:srv_id | Get information about a server on a service | nil | json server object |
// | DELETE | /services/:svc_id/servers/:srv_id | Delete a server from a service | nil | success message or an error |
// | DELETE | /routes | Delete a route | subdomain, domain, and path (json or query) | success message or an error |
// | GET | /routes | List all routes | nil | json array of route objects |
// | POST | /routes | Add new route | json route object | json route object |
// | PUT | /routes | Reset the list of routes | json array of route objects | json array of route objects |
// | DELETE | /certs | Delete a cert | json cert object | success message or an error |
// | GET | /certs | List all certs | nil | json array of cert objects |
// | POST | /certs | Add new cert | json cert object | json cert object |
// | PUT | /certs | Reset the list of certs | json array of cert objects | json array of cert objects |
// | DELETE | /vips | Delete a vip | json vip object | success message or an error |
// | GET | /vips | List all vips | nil | json array of vip objects |
// | POST | /vips | Add new vip | json vip object | json vip object |
// | PUT | /vips | Reset the list of vips | json array of vip objects | json array of vip objects |
// | Action | Route | Description | Payload | Output |
// |--------|-----------------------------------|---------------------------------------------|---------------------------------------------|-------------------------------|
// | GET | /services | List all services | nil | json array of service objects |
// | POST | /services | Add a service | json service object | json service object |
// | PUT | /services | Reset the list of services | json array of service objects | json array of service objects |
// | PUT | /services/:svc_id | Reset the specified service | nil | json service object |
// | GET | /services/:svc_id | Get information about a service | nil | json service object |
// | DELETE | /services/:svc_id | Delete a service | nil | success message or an error |
// | GET | /services/:svc_id/servers | List all servers on a service | nil | json array of server objects |
// | POST | /services/:svc_id/servers | Add new server to a service | json server object | json server object |
// | PUT | /services/:svc_id/servers | Reset the list of servers on a service | json array of server objects | json array of server objects |
// | GET | /services/:svc_id/servers/:srv_id | Get information about a server on a service | nil | json server object |
// | DELETE | /services/:svc_id/servers/:srv_id | Delete a server from a service | nil | success message or an error |
// | DELETE | /routes | Delete a route | subdomain, domain, and path (json or query) | success message or an error |
// | GET | /routes | List all routes | nil | json array of route objects |
// | POST | /routes | Add new route | json route object | json route object |
// | PUT | /routes | Reset the list of routes | json array of route objects | json array of route objects |
// | DELETE | /certs | Delete a cert | json cert object | success message or an error |
// | GET | /certs | List all certs | nil | json array of cert objects |
// | POST | /certs | Add new cert | json cert object | json cert object |
// | PUT | /certs | Reset the list of certs | json array of cert objects | json array of cert objects |
// | DELETE | /vips | Delete a vip | json vip object | success message or an error |
// | GET | /vips | List all vips | nil | json array of vip objects |
// | POST | /vips | Add new vip | json vip object | json vip object |
// | PUT | /vips | Reset the list of vips | json array of vip objects | json array of vip objects |
package api

// Things this api needs to support
Expand All @@ -47,13 +47,13 @@ import (
"net/http"

"github.com/gorilla/pat"
"github.com/nanobox-io/golang-nanoauth"
microauth "github.com/mu-box/golang-microauth"

"github.com/nanopack/portal/config"
"github.com/mu-box/portal/config"
)

var (
auth nanoauth.Auth
auth microauth.Auth
BadJson = errors.New("Bad JSON syntax received in body")
BodyReadFail = errors.New("Body Read Failed")
NoServerError = errors.New("No Server Found")
Expand All @@ -80,9 +80,9 @@ func StartApi() error {
var cert *tls.Certificate
var err error
if config.ApiCert == "" {
cert, err = nanoauth.Generate("portal.nanobox.io")
cert, err = microauth.Generate("portal.microbox.cloud")
} else {
cert, err = nanoauth.Load(config.ApiCert, config.ApiKey, config.ApiKeyPassword)
cert, err = microauth.Load(config.ApiCert, config.ApiKey, config.ApiKeyPassword)
}
if err != nil {
return err
Expand Down
36 changes: 18 additions & 18 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (

"github.com/jcelliott/lumber"

"github.com/nanopack/portal/api"
"github.com/nanopack/portal/balance"
"github.com/nanopack/portal/cluster"
"github.com/nanopack/portal/config"
"github.com/nanopack/portal/core"
"github.com/nanopack/portal/database"
"github.com/nanopack/portal/proxymgr"
"github.com/nanopack/portal/vipmgr"
"github.com/mu-box/portal/api"
"github.com/mu-box/portal/balance"
"github.com/mu-box/portal/cluster"
"github.com/mu-box/portal/config"
"github.com/mu-box/portal/core"
"github.com/mu-box/portal/database"
"github.com/mu-box/portal/proxymgr"
"github.com/mu-box/portal/vipmgr"
)

var (
Expand Down Expand Up @@ -73,9 +73,9 @@ func TestMain(m *testing.M) {
// Post - /sync postSync
// Get - /sync getSync

////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// SERVICES
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// test get services
func TestGetServices(t *testing.T) {
body, err := rest("GET", "/services", "")
Expand Down Expand Up @@ -231,9 +231,9 @@ func TestDeleteService(t *testing.T) {
}
}

////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// SERVERS
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// test get servers
func TestGetServers(t *testing.T) {
rest("POST", "/services", testService)
Expand Down Expand Up @@ -349,9 +349,9 @@ func TestDeleteServer(t *testing.T) {
}
}

////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// ROUTES
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// test get routes
func TestGetRoutes(t *testing.T) {
body, err := rest("GET", "/routes", "")
Expand Down Expand Up @@ -445,9 +445,9 @@ func TestDeleteRoute(t *testing.T) {
}
}

////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// CERTS
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// test get certs
func TestGetCerts(t *testing.T) {
body, err := rest("GET", "/certs", "")
Expand Down Expand Up @@ -535,9 +535,9 @@ func TestDeleteCert(t *testing.T) {
}
}

////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// PRIVS
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// hit api and return response body
func rest(method, route, data string) ([]byte, error) {
body := bytes.NewBuffer([]byte(data))
Expand Down
6 changes: 3 additions & 3 deletions api/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"net/http"
"strings"

"github.com/nanopack/portal/cluster"
"github.com/nanopack/portal/core"
"github.com/nanopack/portal/core/common"
"github.com/mu-box/portal/cluster"
"github.com/mu-box/portal/core"
"github.com/mu-box/portal/core/common"
)

func postCert(rw http.ResponseWriter, req *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"net/http"

"github.com/nanobox-io/nanobox-router"
"github.com/mu-box/microbox-router"
)

// todo: update router so it uses map[string]string|byte for errors
Expand Down
6 changes: 3 additions & 3 deletions api/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package api
import (
"net/http"

"github.com/nanopack/portal/cluster"
"github.com/nanopack/portal/core"
"github.com/nanopack/portal/core/common"
"github.com/mu-box/portal/cluster"
"github.com/mu-box/portal/core"
"github.com/mu-box/portal/core/common"
)

func postRoute(rw http.ResponseWriter, req *http.Request) {
Expand Down
8 changes: 4 additions & 4 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"io/ioutil"
"net/http"

"github.com/nanopack/portal/cluster"
"github.com/nanopack/portal/config"
"github.com/nanopack/portal/core"
"github.com/nanopack/portal/core/common"
"github.com/mu-box/portal/cluster"
"github.com/mu-box/portal/config"
"github.com/mu-box/portal/core"
"github.com/mu-box/portal/core/common"
)

func parseReqServer(req *http.Request) (*core.Server, error) {
Expand Down
8 changes: 4 additions & 4 deletions api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"strconv"
"strings"

"github.com/nanopack/portal/cluster"
"github.com/nanopack/portal/config"
"github.com/nanopack/portal/core"
"github.com/nanopack/portal/core/common"
"github.com/mu-box/portal/cluster"
"github.com/mu-box/portal/config"
"github.com/mu-box/portal/core"
"github.com/mu-box/portal/core/common"
)

func parseReqService(req *http.Request) (*core.Service, error) {
Expand Down
6 changes: 3 additions & 3 deletions api/vip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package api
import (
"net/http"

"github.com/nanopack/portal/cluster"
"github.com/nanopack/portal/core"
"github.com/nanopack/portal/core/common"
"github.com/mu-box/portal/cluster"
"github.com/mu-box/portal/core"
"github.com/mu-box/portal/core/common"
)

func postVip(rw http.ResponseWriter, req *http.Request) {
Expand Down
5 changes: 3 additions & 2 deletions balance/balance.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux || darwin
// +build linux darwin

// balance handles the load balancing portion of portal.
Expand All @@ -11,8 +12,8 @@ import (

"github.com/coreos/go-iptables/iptables"

"github.com/nanopack/portal/config"
"github.com/nanopack/portal/core"
"github.com/mu-box/portal/config"
"github.com/mu-box/portal/core"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions balance/balance_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

// balance handles the load balancing portion of portal.
Expand All @@ -8,8 +9,8 @@ import (
"strconv"
"strings"

"github.com/nanopack/portal/config"
"github.com/nanopack/portal/core"
"github.com/mu-box/portal/config"
"github.com/mu-box/portal/core"
)

var (
Expand Down
Loading

0 comments on commit 23e132c

Please sign in to comment.