Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code restructuring as per typical golang projects #397

Merged
merged 2 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ ifeq "$(BUILD_IN_DOCKER)" "true"
$(DOCKER) run -v $(PWD):/go/src/github.com/cloudnativelabs/kube-router -w /go/src/github.com/cloudnativelabs/kube-router $(DOCKER_BUILD_IMAGE) \
sh -c ' \
GOARCH=$(GOARCH) CGO_ENABLED=0 go build \
-ldflags "-X github.com/cloudnativelabs/kube-router/app.version=$(GIT_COMMIT) -X github.com/cloudnativelabs/kube-router/app.buildDate=$(BUILD_DATE)" \
-o kube-router kube-router.go'
-ldflags "-X github.com/cloudnativelabs/kube-router/pkg/cmd.version=$(GIT_COMMIT) -X github.com/cloudnativelabs/kube-router/pkg/cmd.buildDate=$(BUILD_DATE)" \
-o kube-router cmd/kube-router/kube-router.go'
@echo Finished kube-router binary build.
else
GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags '-X github.com/cloudnativelabs/kube-router/app.version=$(GIT_COMMIT) -X github.com/cloudnativelabs/kube-router/app.buildDate=$(BUILD_DATE)' -o kube-router kube-router.go
GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags '-X github.com/cloudnativelabs/kube-router/pkg/cmd.version=$(GIT_COMMIT) -X github.com/cloudnativelabs/kube-router/pkg/cmd.buildDate=$(BUILD_DATE)' -o kube-router cmd/kube-router/kube-router.go
endif

test: gofmt gomoqs ## Runs code quality pipelines (gofmt, tests, coverage, lint, etc)
ifeq "$(BUILD_IN_DOCKER)" "true"
$(DOCKER) run -v $(PWD):/go/src/github.com/cloudnativelabs/kube-router -w /go/src/github.com/cloudnativelabs/kube-router $(DOCKER_BUILD_IMAGE) \
sh -c 'go test github.com/cloudnativelabs/kube-router github.com/cloudnativelabs/kube-router/app/... github.com/cloudnativelabs/kube-router/utils/'
else
go test github.com/cloudnativelabs/kube-router github.com/cloudnativelabs/kube-router/app/... github.com/cloudnativelabs/kube-router/utils/
go test github.com/cloudnativelabs/kube-router/cmd/kube-router/ github.com/cloudnativelabs/kube-router/pkg/...
endif

vagrant-up: export docker=$(DOCKER)
Expand Down Expand Up @@ -144,7 +144,7 @@ gofmt-fix: ## Fixes files that need to be gofmt'd.

# List of all file_moq.go files which would need to be regenerated
# from file.go if changed
gomoqs: ./app/controllers/network_services_controller_moq.go
gomoqs: ./pkg/controllers/network_services_controller_moq.go

# file_moq.go file is generated from file.go "//go:generate moq ..." in-file
# annotation, as it needs to know which interfaces to create mock stubs for
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ single DaemonSet/Binary. It doesn't get any easier.
### IPVS/LVS based service proxy | `--run-service-proxy`

kube-router uses the Linux kernel's LVS/IPVS features to implement its K8s Services
Proxy. Kube-router fully leverages power off LVS/IPVS to provide rich set of [scheduling options](/Documentation#load-balancing-scheduling-algorithms) and unique features like DSR (Direct Server Return), L3 load balancing with ECMP for deployments where high throughput, minimal latency and high-availability are crucial.
Proxy. Kube-router fully leverages power off LVS/IPVS to provide rich set of [scheduling options](/docs#load-balancing-scheduling-algorithms) and unique features like DSR (Direct Server Return), L3 load balancing with ECMP for deployments where high throughput, minimal latency and high-availability are crucial.

Read more about the advantages of IPVS for container load balancing:
- [Kubernetes network services proxy with IPVS/LVS](https://cloudnativelabs.github.io/post/2017-05-10-kube-network-service-proxy/)
Expand Down Expand Up @@ -68,18 +68,18 @@ configured BGP peers. Kube-routes also support MD5 password based authentication
uses strict export policies so you can be assured routes are advertised to underlay
only as you intended.

For more details please refer to the [BGP documentation](Documentation/bgp.md).
For more details please refer to the [BGP documentation](docs/bgp.md).

### Standard Linux Networking

A key design tenet of Kube-router is to use standard Linux networking stack and toolset. There is no overlays or
SDN pixie dust, but just plain good old networking. You can use standard Linux networking tools like iptables, ipvsadm, ipset,
iproute, traceroute, tcpdump etc. to troubleshoot or observe data path. When kube-router is ran as a daemonset, image also ships with these [tools](./Documentation/pod-toolbox.md#pod-toolbox) automatically configured for your cluster.
iproute, traceroute, tcpdump etc. to troubleshoot or observe data path. When kube-router is ran as a daemonset, image also ships with these [tools](./docs/pod-toolbox.md#pod-toolbox) automatically configured for your cluster.

### Small Footprint

Although it does the work of several of its peers in one binary, kube-router
does it all with a relatively [tiny codebase](https://github.com/cloudnativelabs/kube-router/tree/master/app/controllers), partly because IPVS is already
does it all with a relatively [tiny codebase](https://github.com/cloudnativelabs/kube-router/tree/master/pkg/controllers), partly because IPVS is already
there on your Kuberneres nodes waiting to help you do amazing things.
kube-router brings that and GoBGP's modern BGP interface to you in an elegant
package designed from the ground up for Kubernetes.
Expand All @@ -94,11 +94,11 @@ that has been thouroughly tested and optimized.

## Getting Started

- [How it Works](./Documentation/how-it-works.md)
- [Architecture](./Documentation/README.md#architecture)
- [See Kube-router in action](./Documentation#see-kube-router-in-action)
- [User Guide](./Documentation/README.md#user-guide)
- [Developer Guide](./Documentation/developing.md)
- [How it Works](./docs/how-it-works.md)
- [Architecture](./docs/README.md#architecture)
- [See Kube-router in action](./docs/README.md#see-kube-router-in-action)
- [User Guide](./docs/README.md#user-guide)
- [Developer Guide](./docs/developing.md)

## Project status

Expand Down
10 changes: 5 additions & 5 deletions kube-router.go → cmd/kube-router/kube-router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

_ "net/http/pprof"

"github.com/cloudnativelabs/kube-router/app"
"github.com/cloudnativelabs/kube-router/app/options"
"github.com/cloudnativelabs/kube-router/pkg/cmd"
"github.com/cloudnativelabs/kube-router/pkg/options"
"github.com/spf13/pflag"
)

Expand Down Expand Up @@ -39,7 +39,7 @@ func Main() error {
}

if config.Version {
app.PrintVersion(false)
cmd.PrintVersion(false)
return nil
}

Expand All @@ -48,11 +48,11 @@ func Main() error {
}

if config.CleanupConfig {
app.CleanupConfigAndExit()
cmd.CleanupConfigAndExit()
return nil
}

kubeRouter, err := app.NewKubeRouterDefault(config)
kubeRouter, err := cmd.NewKubeRouterDefault(config)
if err != nil {
return fmt.Errorf("Failed to parse kube-router config: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions kube-router_test.go → cmd/kube-router/kube-router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func TestMainHelp(t *testing.T) {
stderrW.Close()
wg.Wait()

docF, err := os.Open("Documentation/README.md")
docF, err := os.Open("../../docs/README.md")
if err != nil {
t.Fatalf("could not open Documentation/README.md: %s\n", err)
t.Fatalf("could not open docs/README.md: %s\n", err)
}
docBuf := bytes.NewBuffer(nil)
docBuf.ReadFrom(docF)
Expand All @@ -44,6 +44,6 @@ func TestMainHelp(t *testing.T) {
exp = append(exp, []byte("```\n")...)

if !bytes.Contains(docBuf.Bytes(), exp) {
t.Errorf("Documentation/README.md 'command line options' section does not match `kube-router --help`.\nExpected:\n%s", exp)
t.Errorf("docs/README.md 'command line options' section does not match `kube-router --help`.\nExpected:\n%s", exp)
}
}
6 changes: 3 additions & 3 deletions Documentation/README.md → docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ However BGP can be leveraged to other use cases like advertising the cluster ip,
The best way to get started is to deploy Kubernetes with Kube-router is with a cluster installer.

#### kops
Please see the [steps](https://github.com/cloudnativelabs/kube-router/blob/master/Documentation/kops.md) to deploy Kubernetes cluster with Kube-router using [Kops](https://github.com/kubernetes/kops)
Please see the [steps](https://github.com/cloudnativelabs/kube-router/blob/master/docs/kops.md) to deploy Kubernetes cluster with Kube-router using [Kops](https://github.com/kubernetes/kops)

#### bootkube
Please see the [steps](https://github.com/cloudnativelabs/kube-router/tree/master/contrib/bootkube) to deploy Kubernetes cluster with Kube-router using [bootkube](https://github.com/kubernetes-incubator/bootkube)

#### kubeadm
Please see the [steps](https://github.com/cloudnativelabs/kube-router/blob/master/Documentation/kubeadm.md) to deploy Kubernetes cluster with Kube-router using [Kubeadm](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/)
Please see the [steps](https://github.com/cloudnativelabs/kube-router/blob/master/docs/kubeadm.md) to deploy Kubernetes cluster with Kube-router using [Kubeadm](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/)

#### generic
Please see the [steps](https://github.com/cloudnativelabs/kube-router/blob/master/Documentation/generic.md) to deploy kube-router on manually installed clusters
Please see the [steps](https://github.com/cloudnativelabs/kube-router/blob/master/docs/generic.md) to deploy kube-router on manually installed clusters

### deployment

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions app/server.go → pkg/cmd/kube-router.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app
package cmd

import (
"errors"
Expand All @@ -9,8 +9,8 @@ import (
"sync"
"syscall"

"github.com/cloudnativelabs/kube-router/app/controllers"
"github.com/cloudnativelabs/kube-router/app/options"
"github.com/cloudnativelabs/kube-router/pkg/controllers"
"github.com/cloudnativelabs/kube-router/pkg/options"
"github.com/golang/glog"

"k8s.io/client-go/informers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/cloudnativelabs/kube-router/app/options"
"github.com/cloudnativelabs/kube-router/pkg/options"
"github.com/golang/glog"
"golang.org/x/net/context"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/cloudnativelabs/kube-router/app/options"
"github.com/cloudnativelabs/kube-router/pkg/options"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"sync"
"time"

"github.com/cloudnativelabs/kube-router/app/options"
"github.com/cloudnativelabs/kube-router/utils"
"github.com/cloudnativelabs/kube-router/pkg/options"
"github.com/cloudnativelabs/kube-router/pkg/utils"
"github.com/coreos/go-iptables/iptables"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/cloudnativelabs/kube-router/app/options"
"github.com/cloudnativelabs/kube-router/utils"
"github.com/cloudnativelabs/kube-router/pkg/options"
"github.com/cloudnativelabs/kube-router/pkg/utils"
"github.com/coreos/go-iptables/iptables"
"github.com/golang/glog"
bgpapi "github.com/osrg/gobgp/api"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"syscall"
"time"

"github.com/cloudnativelabs/kube-router/app/options"
"github.com/cloudnativelabs/kube-router/utils"
"github.com/cloudnativelabs/kube-router/pkg/options"
"github.com/cloudnativelabs/kube-router/pkg/utils"
"github.com/coreos/go-iptables/iptables"
"github.com/docker/docker/client"
"github.com/docker/libnetwork/ipvs"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.