Skip to content

Commit

Permalink
feat: use bgp to announce pod ip
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Apr 27, 2020
1 parent 909b5a0 commit da14eae
Show file tree
Hide file tree
Showing 496 changed files with 130,948 additions and 1,357 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist/images/kube-ovn-daemon
dist/images/kube-ovn-gateway
dist/images/kube-ovn-webhook
dist/images/kube-ovn-pinger
dist/images/kube-ovn-speaker
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ build-go:
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $(PWD)/dist/images/kube-ovn-daemon -ldflags "-w -s" -v ./cmd/daemon
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $(PWD)/dist/images/kube-ovn-pinger -ldflags "-w -s" -v ./cmd/pinger
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $(PWD)/dist/images/kube-ovn-webhook -ldflags "-w -s" -v ./cmd/webhook
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $(PWD)/dist/images/kube-ovn-speaker -ldflags "-w -s" -v ./cmd/speaker

release: lint build-go
docker buildx build --platform linux/${ARCH} --build-arg ARCH=${ARCH} --build-arg RPM_ARCH=${RPM_ARCH} -t ${REGISTRY}/kube-ovn:${RELEASE_TAG} -o type=docker -f dist/images/Dockerfile dist/images/
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The Kube-OVN community is waiting for you participation!
- **Distributed Gateways**: Every Node can act as a Gateway to provide external network connectivity.
- **Namespaced Gateways**: Every Namespace can have a dedicated Gateway for Egress traffic.
- **Direct External Connectivity**:Pod IP can be exposed to external network directly.
- **BGP Support**: Pod IP can be exposed to external by BGP router protocol.
- **Traffic Mirror**: Duplicated container network traffic for monitoring, diagnosing and replay.
- **Vlan Support**: Kube-OVN also support underlay Vlan mode network for better performance and throughput.
- **IPv6 Support**: Kube-OVN supports ipv6-only mode pod network.
Expand Down Expand Up @@ -64,6 +65,7 @@ If you want to install Kubernetes from scratch, you can try [kubespray](https://
- [Static IP](docs/static-ip.md)
- [Dynamic QoS](docs/qos.md)
- [Gateway and Direct connect](docs/subnet.md#gateway)
- [BGP support](docs/bgp.md)
- [Multi NIC Support](docs/multi-nic.md)
- [Vlan Support](docs/vlan.md)
- [Traffic Mirror](docs/mirror.md)
Expand Down
28 changes: 28 additions & 0 deletions cmd/speaker/speaker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"github.com/alauda/kube-ovn/pkg/speaker"
"github.com/prometheus/client_golang/prometheus/promhttp"
"k8s.io/klog"
"k8s.io/sample-controller/pkg/signals"
"net/http"
)

func main() {
defer klog.Flush()
config, err := speaker.ParseFlags()
if err != nil {
klog.Fatalf("failed to parse config %v", err)
}

stopCh := signals.SetupSignalHandler()
ctl := speaker.NewController(config)

go func() {
http.Handle("/metrics", promhttp.Handler())
klog.Fatal(http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", config.PprofPort), nil))
}()

ctl.Run(stopCh)
}
1 change: 1 addition & 0 deletions dist/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ COPY kube-ovn /kube-ovn/kube-ovn
COPY kube-ovn-daemon /kube-ovn/kube-ovn-daemon
COPY kube-ovn-pinger /kube-ovn/kube-ovn-pinger
COPY kube-ovn-controller /kube-ovn/kube-ovn-controller
COPY kube-ovn-speaker /kube-ovn/kube-ovn-speaker
36 changes: 36 additions & 0 deletions docs/bgp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# BGP support

Kube-OVN supports broadcast pod ips to external networks by BGP protocol.
To enable BGP announce function, you need to install kube-ovn-speaker and annotate pods that need to be exposed.

## Install kube-ovn-speaker

1. Download `kube-ovn-speaker` yaml

```bash
wget https://github.com/alauda/kube-ovn/blob/master/yamls/speaker.yaml
```

2. Modify the args in yaml

```bash
--neighbor-address=10.32.32.1 # The router address that need to establish bgp peers
--neighbor-as=65030 # The AS of router
--cluster-as=65000 # The AS of container network
```

3. Apply the yaml

```bash
kubectl apply -f speaker.yaml
```

## Annotate pods that need to be exposed

```bash
# Enable BGP
kubectl annotate pod sample ovn.kubernetes.io/bgp=true

# Disable BGP
kubectl annotate pod perf-ovn-xzvd4 ovn.kubernetes.io/bgp-
```
19 changes: 8 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,44 @@ require (
github.com/containernetworking/cni v0.7.1
github.com/containernetworking/plugins v0.8.2
github.com/coreos/go-iptables v0.4.2
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/elazarl/goproxy v0.0.0-20190630181448-f1e96bc0f4c5 // indirect
github.com/elazarl/goproxy/ext v0.0.0-20190630181448-f1e96bc0f4c5 // indirect
github.com/emicklei/go-restful v2.11.1+incompatible
github.com/go-ini/ini v1.42.0 // indirect
github.com/go-logr/zapr v0.1.1 // indirect
github.com/golang/protobuf v1.3.2
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/intel/multus-cni v0.0.0-20200313031649-eaf6ff6e20bb
github.com/juju/errors v0.0.0-20190207033735-e65537c515d7
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kubesphere/porter v0.1.1
github.com/moul/http2curl v1.0.0 // indirect
github.com/oilbeater/go-ping v0.0.0-20200413021620-332b7197c5b5
github.com/onsi/ginkgo v1.12.0
github.com/onsi/gomega v1.9.0
github.com/osrg/gobgp v0.0.0-20190401195721-805d02fdfbc5
github.com/parnurzeal/gorequest v0.2.15
github.com/projectcalico/felix v3.6.1+incompatible
github.com/projectcalico/go-json v0.0.0-20161128004156-6219dc7339ba // indirect
github.com/projectcalico/go-yaml v0.0.0-20161201183616-955bc3e451ef // indirect
github.com/projectcalico/go-yaml-wrapper v0.0.0-20161127220527-598e54215bee // indirect
github.com/projectcalico/libcalico-go v0.0.0-20190305235709-3d935c3b8b86 // indirect
github.com/prometheus/client_golang v0.9.2
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect
github.com/prometheus/common v0.2.0 // indirect
github.com/prometheus/procfs v0.0.0-20190328153300-af7bedc223fb // indirect
github.com/prometheus/client_golang v1.1.0
github.com/sirupsen/logrus v1.4.2
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.6.3 // indirect
github.com/vishvananda/netlink v1.0.0
go.uber.org/zap v1.10.0 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
gopkg.in/ini.v1 v1.42.0 // indirect
google.golang.org/grpc v1.23.0
k8s.io/api v0.0.0-20190703205437-39734b2a72fe
k8s.io/apimachinery v0.0.0-20190703205208-4cfb76a8bf76
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/klog v1.0.0
k8s.io/sample-controller v0.0.0-20190326030654-b8f621986e45
k8s.io/utils v0.0.0-20190607212802-c55fbcfc754a // indirect
sigs.k8s.io/controller-runtime v0.2.0-alpha.0
sigs.k8s.io/controller-runtime v0.2.0-beta.5
)

replace (
Expand Down

0 comments on commit da14eae

Please sign in to comment.