diff --git a/Makefile b/Makefile index 7699e343..bb0d8e90 100644 --- a/Makefile +++ b/Makefile @@ -41,11 +41,11 @@ 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) @@ -53,7 +53,7 @@ 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) @@ -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 diff --git a/README.md b/README.md index 75f77a5e..246a32cf 100644 --- a/README.md +++ b/README.md @@ -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/) @@ -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. @@ -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 diff --git a/kube-router.go b/cmd/kube-router/kube-router.go similarity index 84% rename from kube-router.go rename to cmd/kube-router/kube-router.go index 5c25501f..59ee313a 100644 --- a/kube-router.go +++ b/cmd/kube-router/kube-router.go @@ -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" ) @@ -39,7 +39,7 @@ func Main() error { } if config.Version { - app.PrintVersion(false) + cmd.PrintVersion(false) return nil } @@ -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) } diff --git a/kube-router_test.go b/cmd/kube-router/kube-router_test.go similarity index 77% rename from kube-router_test.go rename to cmd/kube-router/kube-router_test.go index 6693b47f..a40bbfa8 100644 --- a/kube-router_test.go +++ b/cmd/kube-router/kube-router_test.go @@ -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) @@ -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) } } diff --git a/Documentation/README.md b/docs/README.md similarity index 97% rename from Documentation/README.md rename to docs/README.md index e187edf5..4701db83 100644 --- a/Documentation/README.md +++ b/docs/README.md @@ -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 diff --git a/Documentation/bgp.md b/docs/bgp.md similarity index 100% rename from Documentation/bgp.md rename to docs/bgp.md diff --git a/Documentation/bootkube.md b/docs/bootkube.md similarity index 100% rename from Documentation/bootkube.md rename to docs/bootkube.md diff --git a/Documentation/developing.md b/docs/developing.md similarity index 100% rename from Documentation/developing.md rename to docs/developing.md diff --git a/Documentation/generic.md b/docs/generic.md similarity index 100% rename from Documentation/generic.md rename to docs/generic.md diff --git a/Documentation/health.md b/docs/health.md similarity index 100% rename from Documentation/health.md rename to docs/health.md diff --git a/Documentation/how-it-works.md b/docs/how-it-works.md similarity index 100% rename from Documentation/how-it-works.md rename to docs/how-it-works.md diff --git a/Documentation/img/ep.jpg b/docs/img/ep.jpg similarity index 100% rename from Documentation/img/ep.jpg rename to docs/img/ep.jpg diff --git a/Documentation/img/forward.png b/docs/img/forward.png similarity index 100% rename from Documentation/img/forward.png rename to docs/img/forward.png diff --git a/Documentation/img/ipset.jpg b/docs/img/ipset.jpg similarity index 100% rename from Documentation/img/ipset.jpg rename to docs/img/ipset.jpg diff --git a/Documentation/img/ipvs1.jpg b/docs/img/ipvs1.jpg similarity index 100% rename from Documentation/img/ipvs1.jpg rename to docs/img/ipvs1.jpg diff --git a/Documentation/img/kube-router-arch.png b/docs/img/kube-router-arch.png similarity index 100% rename from Documentation/img/kube-router-arch.png rename to docs/img/kube-router-arch.png diff --git a/Documentation/img/logo-full.png b/docs/img/logo-full.png similarity index 100% rename from Documentation/img/logo-full.png rename to docs/img/logo-full.png diff --git a/Documentation/img/logo-full.svg b/docs/img/logo-full.svg similarity index 100% rename from Documentation/img/logo-full.svg rename to docs/img/logo-full.svg diff --git a/Documentation/img/logo-icon-only.png b/docs/img/logo-icon-only.png similarity index 100% rename from Documentation/img/logo-icon-only.png rename to docs/img/logo-icon-only.png diff --git a/Documentation/img/logo-icon-only.svg b/docs/img/logo-icon-only.svg similarity index 100% rename from Documentation/img/logo-icon-only.svg rename to docs/img/logo-icon-only.svg diff --git a/Documentation/img/podfw.png b/docs/img/podfw.png similarity index 100% rename from Documentation/img/podfw.png rename to docs/img/podfw.png diff --git a/Documentation/img/policyfw.png b/docs/img/policyfw.png similarity index 100% rename from Documentation/img/policyfw.png rename to docs/img/policyfw.png diff --git a/Documentation/img/svc.jpg b/docs/img/svc.jpg similarity index 100% rename from Documentation/img/svc.jpg rename to docs/img/svc.jpg diff --git a/Documentation/kops.md b/docs/kops.md similarity index 100% rename from Documentation/kops.md rename to docs/kops.md diff --git a/Documentation/kubeadm.md b/docs/kubeadm.md similarity index 100% rename from Documentation/kubeadm.md rename to docs/kubeadm.md diff --git a/Documentation/metrics.md b/docs/metrics.md similarity index 100% rename from Documentation/metrics.md rename to docs/metrics.md diff --git a/Documentation/pod-toolbox.md b/docs/pod-toolbox.md similarity index 100% rename from Documentation/pod-toolbox.md rename to docs/pod-toolbox.md diff --git a/Documentation/see-it-in-action.md b/docs/see-it-in-action.md similarity index 100% rename from Documentation/see-it-in-action.md rename to docs/see-it-in-action.md diff --git a/Documentation/testing.md b/docs/testing.md similarity index 100% rename from Documentation/testing.md rename to docs/testing.md diff --git a/Documentation/upgrading.md b/docs/upgrading.md similarity index 100% rename from Documentation/upgrading.md rename to docs/upgrading.md diff --git a/app/server.go b/pkg/cmd/kube-router.go similarity index 97% rename from app/server.go rename to pkg/cmd/kube-router.go index f9af5bce..5e8d3344 100644 --- a/app/server.go +++ b/pkg/cmd/kube-router.go @@ -1,4 +1,4 @@ -package app +package cmd import ( "errors" @@ -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" diff --git a/app/controllers/controllers_suite_test.go b/pkg/controllers/controllers_suite_test.go similarity index 100% rename from app/controllers/controllers_suite_test.go rename to pkg/controllers/controllers_suite_test.go diff --git a/app/controllers/health_controller.go b/pkg/controllers/health_controller.go similarity index 98% rename from app/controllers/health_controller.go rename to pkg/controllers/health_controller.go index 27fa0a73..4f96247a 100644 --- a/app/controllers/health_controller.go +++ b/pkg/controllers/health_controller.go @@ -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" ) diff --git a/app/controllers/metrics_controller.go b/pkg/controllers/metrics_controller.go similarity index 99% rename from app/controllers/metrics_controller.go rename to pkg/controllers/metrics_controller.go index 1435c179..897680c8 100644 --- a/app/controllers/metrics_controller.go +++ b/pkg/controllers/metrics_controller.go @@ -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" diff --git a/app/controllers/network_policy_controller.go b/pkg/controllers/network_policy_controller.go similarity index 99% rename from app/controllers/network_policy_controller.go rename to pkg/controllers/network_policy_controller.go index a1a4e579..17887bd3 100644 --- a/app/controllers/network_policy_controller.go +++ b/pkg/controllers/network_policy_controller.go @@ -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" diff --git a/app/controllers/network_routes_controller.go b/pkg/controllers/network_routes_controller.go similarity index 99% rename from app/controllers/network_routes_controller.go rename to pkg/controllers/network_routes_controller.go index 24d1362c..4fed5010 100644 --- a/app/controllers/network_routes_controller.go +++ b/pkg/controllers/network_routes_controller.go @@ -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" diff --git a/app/controllers/network_routes_controller_test.go b/pkg/controllers/network_routes_controller_test.go similarity index 100% rename from app/controllers/network_routes_controller_test.go rename to pkg/controllers/network_routes_controller_test.go diff --git a/app/controllers/network_services_controller.go b/pkg/controllers/network_services_controller.go similarity index 99% rename from app/controllers/network_services_controller.go rename to pkg/controllers/network_services_controller.go index d1aa00f4..ef09770f 100644 --- a/app/controllers/network_services_controller.go +++ b/pkg/controllers/network_services_controller.go @@ -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" diff --git a/app/controllers/network_services_controller_moq.go b/pkg/controllers/network_services_controller_moq.go similarity index 100% rename from app/controllers/network_services_controller_moq.go rename to pkg/controllers/network_services_controller_moq.go diff --git a/app/controllers/network_services_controller_test.go b/pkg/controllers/network_services_controller_test.go similarity index 100% rename from app/controllers/network_services_controller_test.go rename to pkg/controllers/network_services_controller_test.go diff --git a/app/options/options.go b/pkg/options/options.go similarity index 100% rename from app/options/options.go rename to pkg/options/options.go diff --git a/utils/ipset.go b/pkg/utils/ipset.go similarity index 100% rename from utils/ipset.go rename to pkg/utils/ipset.go diff --git a/utils/node.go b/pkg/utils/node.go similarity index 100% rename from utils/node.go rename to pkg/utils/node.go diff --git a/utils/node_test.go b/pkg/utils/node_test.go similarity index 100% rename from utils/node_test.go rename to pkg/utils/node_test.go diff --git a/utils/pod_cidr.go b/pkg/utils/pod_cidr.go similarity index 100% rename from utils/pod_cidr.go rename to pkg/utils/pod_cidr.go diff --git a/utils/pod_cidr_test.go b/pkg/utils/pod_cidr_test.go similarity index 100% rename from utils/pod_cidr_test.go rename to pkg/utils/pod_cidr_test.go diff --git a/utils/utils.go b/pkg/utils/utils.go similarity index 100% rename from utils/utils.go rename to pkg/utils/utils.go