Skip to content

Commit 72fd0d2

Browse files
committed
re-organize documentation
1 parent 547b17d commit 72fd0d2

File tree

4 files changed

+125
-128
lines changed

4 files changed

+125
-128
lines changed

Documentation/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Kube-router consists of 3 core controllers and multiple watchers as depicted in
88

99
![Arch](./img/kube-router-arch.png)
1010

11+
## See Kube-router in action
12+
1113
#### Network Services Controller
1214

1315
Network services controller is responsible for reading the services and endpoints information from Kubernetes API server and configure IPVS on each cluster node accordingly.
@@ -45,7 +47,7 @@ Network routes controller is responsible for reading pod CIDR allocated by contr
4547

4648
[![asciicast](https://asciinema.org/a/120885.png)](https://asciinema.org/a/120885)
4749

48-
However BGP can be leveraged to other use cases like advertising the cluster ip, routable pod ip etc. Only in such use-cases understanding of BGP and configuration is required. Please see below demo how kube-router advertises cluster IP and pod codes to external BGP router
50+
However BGP can be leveraged to other use cases like advertising the cluster ip, routable pod ip etc. Only in such use-cases understanding of BGP and configuration is required. Please see below demo how kube-router advertises cluster IP and pod cidrs to external BGP router
4951
[![asciicast](https://asciinema.org/a/121635.png)](https://asciinema.org/a/121635)
5052

5153
## User Guide
@@ -88,7 +90,7 @@ Usage of ./kube-router:
8890
--master string The address of the Kubernetes API server (overrides any value in kubeconfig).
8991
--nodes-full-mesh Each node in the cluster will setup BGP peering with rest of the nodes. (default true)
9092
--peer-asn string ASN number of the BGP peer to which cluster nodes will advertise cluster ip and node's pod cidr.
91-
--peer-router string The ip address of the external router to which all nodes will peer and advertise the cluster ip and pod cidr's.
93+
--peer-router string Comma sepereated list of ip address of the external routers to which all nodes will peer and advertise the cluster ip and pod cidr's.
9294
--routes-sync-period duration The delay between route updates and advertisements (e.g. '5s', '1m', '2h22m'). Must be greater than 0. (default 1m0s)
9395
--run-firewall Enables Network Policy -- sets up iptables to provide ingress firewall for pods. (default true)
9496
--run-router Enables Pod Networking -- Advertises and learns the routes to Pods via iBGP. (default true)
@@ -97,7 +99,7 @@ Usage of ./kube-router:
9799

98100
### requirements
99101

100-
- Kube-router need to access kubernetes API server to get information on pods, services, endpoints, network policies etc. The very minimum information it requires is the details on where to access the kubernetes API server. This information can be passed as `kube-router --master=http://192.168.1.99:8080/` or `kube-router --kubeconfig=<path to kubeconfig file>`. If neither `--master` nor `--kubeconfig` option is specified then kube-router will look for kubeconfig at `/var/lib/kube-router/kubeconfig` location.
102+
- Kube-router need to access kubernetes API server to get information on pods, services, endpoints, network policies etc. The very minimum information it requires is the details on where to access the kubernetes API server. This information can be passed as `kube-router --master=http://192.168.1.99:8080/` or `kube-router --kubeconfig=<path to kubeconfig file>`.
101103

102104
- If you run kube-router as agent on the node, ipset package must be installed on each of the nodes (when run as daemonset, container image is prepackaged with ipset)
103105

Documentation/how-it-works.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
## Theory of Operation
3+
4+
Kube-router can be run as an agent or a Pod (via DaemonSet) on each node and
5+
leverages standard Linux technologies **iptables, ipvs/lvs, ipset, iproute2**
6+
7+
### Service Proxy And Load Balancing
8+
9+
Blog: [Kubernetes network services proxy with IPVS/LVS](https://cloudnativelabs.github.io/post/2017-05-10-kube-network-service-proxy/)
10+
11+
Kube-router uses IPVS/LVS technology built in Linux to provide L4 load
12+
balancing. Each **ClusterIP**, **NodePort**, and **LoadBalancer** Kubernetes
13+
Service type is configured as an IPVS virtual service. Each Service Endpoint is
14+
configured as real server to the virtual service. The standard **ipvsadm** tool
15+
can be used to verify the configuration and monitor the active connections.
16+
17+
Below is example set of Services on Kubernetes:
18+
19+
![Kube services](./img/svc.jpg)
20+
21+
and the Endpoints for the Services:
22+
23+
![Kube services](./img/ep.jpg)
24+
25+
and how they got mapped to the IPVS by kube-router:
26+
27+
![IPVS configuration](./img/ipvs1.jpg)
28+
29+
Kube-router watches the Kubernetes API server to get updates on the
30+
Services/Endpoints and automatically syncs the IPVS configuration to reflect the
31+
desired state of Services. Kube-router uses IPVS masquerading mode and uses
32+
round robin scheduling currently. Source pod IP is preserved so that appropriate
33+
network policies can be applied.
34+
35+
### Pod Ingress Firewall
36+
37+
Blog: [Enforcing Kubernetes network policies with iptables](https://cloudnativelabs.github.io/post/2017-05-1-kube-network-policies/)
38+
39+
Kube-router provides an implementation of Kubernetes Network Policies through
40+
the use of iptables, ipset and conntrack. All the Pods in a Namespace with
41+
'DefaultDeny' ingress isolation policy has ingress blocked. Only traffic that
42+
matches whitelist rules specified in the network policies are permitted to reach
43+
those Pods. The following set of iptables rules and chains in the 'filter' table
44+
are used to achieve the Network Policies semantics.
45+
46+
Each Pod running on the Node which needs ingress blocked by default is matched
47+
in FORWARD and OUTPUT chains of the fliter table and are sent to a pod specific
48+
firewall chain. Below rules are added to match various cases
49+
50+
- Traffic getting switched between the Pods on the same Node through the local
51+
bridge
52+
- Traffic getting routed between the Pods on different Nodes
53+
- Traffic originating from a Pod and going through the Service proxy and getting
54+
routed to a Pod on the same Node
55+
56+
![FORWARD/OUTPUT chain](./img/forward.png)
57+
58+
Each Pod specific firewall chain has default rule to block the traffic. Rules
59+
are added to jump traffic to the Network Policy specific policy chains. Rules
60+
cover only policies that apply to the destination pod ip. A rule is added to
61+
accept the the established traffic to permit the return traffic.
62+
63+
![Pod firewall chain](./img/podfw.png)
64+
65+
Each policy chain has rules expressed through source and destination ipsets. Set
66+
of pods matching ingress rule in network policy spec forms a source Pod ip
67+
ipset. set of Pods matching pod selector (for destination Pods) in the Network
68+
Policy forms destination Pod ip ipset.
69+
70+
![Policy chain](./img/policyfw.png)
71+
72+
Finally ipsets are created that are used in forming the rules in the Network
73+
Policy specific chain
74+
75+
![ipset](./img/ipset.jpg)
76+
77+
Kube-router at runtime watches Kubernetes API server for changes in the
78+
namespace, network policy and pods and dynamically updates iptables and ipset
79+
configuration to reflect desired state of ingress firewall for the the pods.
80+
81+
### Pod Networking
82+
83+
Blog: [Kubernetes pod networking and beyond with BGP](https://cloudnativelabs.github.io/post/2017-05-22-kube-pod-networking)
84+
85+
Kube-router is expected to run on each Node. The subnet of the Node is obtained
86+
from the CNI configuration file on the Node or through the Node.PodCidr. Each
87+
kube-router instance on the Node acts as a BGP router and advertises the Pod
88+
CIDR assigned to the Node. Each Node peers with rest of the Nodes in the cluster
89+
forming full mesh. Learned routes about the Pod CIDR from the other Nodes (BGP
90+
peers) are injected into local Node routing table. On the data path, inter Node
91+
Pod-to-Pod communication is done by the routing stack on the Node.
92+

Documentation/see-it-in-action.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## See it in action
2+
3+
<a href="https://asciinema.org/a/118056" target="_blank"><img src="https://asciinema.org/a/118056.png" /></a>
4+

README.md

Lines changed: 24 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,9 @@
33
[![Build Status](https://travis-ci.org/cloudnativelabs/kube-router.svg?branch=master)](https://travis-ci.org/cloudnativelabs/kube-router)
44
[![Gitter chat](http://badges.gitter.im/kube-router/Lobby.svg)](https://gitter.im/kube-router/Lobby)
55
[![Docker Pulls kube-router](https://img.shields.io/docker/pulls/cloudnativelabs/kube-router.svg?label=docker+pulls)](https://hub.docker.com/r/cloudnativelabs/kube-router/)
6+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
67

7-
Kube-router is a distributed load balancer, firewall and router for Kubernetes. Kube-router can be configured to provide on each cluster node:
8-
9-
- a IPVS/LVS based service proxy on each node for *ClusterIP*, *NodePort* and *LoadBalancer* service types, providing service discovery and load balancing
10-
- an ingress firewall for the pods running on the node as per the defined Kubernetes network policies using iptables and ipset
11-
- a BGP router to advertise and learn the routes to the pod IP's for cross-node pod-to-pod connectivity
12-
13-
## Project status
14-
15-
Project is in alpha stage. We are working towards beta release
16-
[milestone](https://github.com/cloudnativelabs/kube-router/milestone/2) and are
17-
activley incorporating users feedback.
18-
19-
## Getting Started
20-
21-
- [User Guide](./Documentation/README.md#user-guide)
22-
- [Developer Guide](./Documentation/developing.md)
23-
- [Architecture](./Documentation/README.md#architecture)
8+
Kube-router is a distributed load balancer, firewall and router designed for Kubernetes networking with aim to provide operational simplicity and high performance.
249

2510
## Primary Features
2611

@@ -80,10 +65,16 @@ modern BGP API platform as well right out of the box.
8065

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

68+
### Standard Linux Networking
69+
70+
A key design tenet of Kube-router is to use standard Linux networking stack and toolset. There is no overlays or
71+
SDN pixie dust, but just plain good old networking. You can use standard Linux networking tools like iptables, ipvsadm, ipset,
72+
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.
73+
8374
### Small Footprint
8475

8576
Although it does the work of several of its peers in one binary, kube-router
86-
does it all with a relatively tiny codebase, partly because IPVS is already
77+
does it all with a relatively [tiny codebase](https://github.com/cloudnativelabs/kube-router/tree/master/app/controllers), partly because IPVS is already
8778
there on your Kuberneres nodes waiting to help you do amazing things.
8879
kube-router brings that and GoBGP's modern BGP interface to you in an elegant
8980
package designed from the ground up for Kubernetes.
@@ -96,6 +87,20 @@ recipe for high-performance cluster networking at scale. BGP ensures that the
9687
data path is dynamic and efficient, and IPVS provides in-kernel load balancing
9788
that has been thouroughly tested and optimized.
9889

90+
## Getting Started
91+
92+
- [How it Works](./Documentation/how-it-works.md)
93+
- [Architecture](./Documentation/README.md#architecture)
94+
- [See Kube-router in action](./Documentation#see-kube-router-in-action)
95+
- [User Guide](./Documentation/README.md#user-guide)
96+
- [Developer Guide](./Documentation/developing.md)
97+
98+
## Project status
99+
100+
Project is in alpha stage. We are working towards beta release
101+
[milestone](https://github.com/cloudnativelabs/kube-router/milestone/2) and are
102+
activley incorporating users feedback.
103+
99104
## Contributing
100105

101106
We encourage all kinds of contributions, be they documentation, code, fixing
@@ -108,111 +113,6 @@ If you experience any problems please reach us on our gitter
108113
for quick help. Feel free to leave feedback or raise questions at any time by
109114
opening an issue [here](https://github.com/cloudnativelabs/kube-router/issues).
110115

111-
## See it in action
112-
113-
<a href="https://asciinema.org/a/118056" target="_blank"><img src="https://asciinema.org/a/118056.png" /></a>
114-
115-
116-
## Theory of Operation
117-
118-
Kube-router can be run as an agent or a Pod (via DaemonSet) on each node and
119-
leverages standard Linux technologies **iptables, ipvs/lvs, ipset, iproute2**
120-
121-
### Service Proxy And Load Balancing
122-
123-
[Kubernetes network services proxy with IPVS/LVS](https://cloudnativelabs.github.io/post/2017-05-10-kube-network-service-proxy/)
124-
125-
Kube-router uses IPVS/LVS technology built in Linux to provide L4 load
126-
balancing. Each **ClusterIP**, **NodePort**, and **LoadBalancer** Kubernetes
127-
Service type is configured as an IPVS virtual service. Each Service Endpoint is
128-
configured as real server to the virtual service. The standard **ipvsadm** tool
129-
can be used to verify the configuration and monitor the active connections.
130-
131-
Below is example set of Services on Kubernetes:
132-
133-
![Kube services](./Documentation/img/svc.jpg)
134-
135-
and the Endpoints for the Services:
136-
137-
![Kube services](./Documentation/img/ep.jpg)
138-
139-
and how they got mapped to the IPVS by kube-router:
140-
141-
![IPVS configuration](./Documentation/img/ipvs1.jpg)
142-
143-
Kube-router watches the Kubernetes API server to get updates on the
144-
Services/Endpoints and automatically syncs the IPVS configuration to reflect the
145-
desired state of Services. Kube-router uses IPVS masquerading mode and uses
146-
round robin scheduling currently. Source pod IP is preserved so that appropriate
147-
network policies can be applied.
148-
149-
### Pod Ingress Firewall
150-
151-
[Enforcing Kubernetes network policies with iptables](https://cloudnativelabs.github.io/post/2017-05-1-kube-network-policies/)
152-
153-
Kube-router provides an implementation of Kubernetes Network Policies through
154-
the use of iptables, ipset and conntrack. All the Pods in a Namespace with
155-
'DefaultDeny' ingress isolation policy has ingress blocked. Only traffic that
156-
matches whitelist rules specified in the network policies are permitted to reach
157-
those Pods. The following set of iptables rules and chains in the 'filter' table
158-
are used to achieve the Network Policies semantics.
159-
160-
Each Pod running on the Node which needs ingress blocked by default is matched
161-
in FORWARD and OUTPUT chains of the fliter table and are sent to a pod specific
162-
firewall chain. Below rules are added to match various cases
163-
164-
- Traffic getting switched between the Pods on the same Node through the local
165-
bridge
166-
- Traffic getting routed between the Pods on different Nodes
167-
- Traffic originating from a Pod and going through the Service proxy and getting
168-
routed to a Pod on the same Node
169-
170-
![FORWARD/OUTPUT chain](./Documentation/img/forward.png)
171-
172-
Each Pod specific firewall chain has default rule to block the traffic. Rules
173-
are added to jump traffic to the Network Policy specific policy chains. Rules
174-
cover only policies that apply to the destination pod ip. A rule is added to
175-
accept the the established traffic to permit the return traffic.
176-
177-
![Pod firewall chain](./Documentation/img/podfw.png)
178-
179-
Each policy chain has rules expressed through source and destination ipsets. Set
180-
of pods matching ingress rule in network policy spec forms a source Pod ip
181-
ipset. set of Pods matching pod selector (for destination Pods) in the Network
182-
Policy forms destination Pod ip ipset.
183-
184-
![Policy chain](./Documentation/img/policyfw.png)
185-
186-
Finally ipsets are created that are used in forming the rules in the Network
187-
Policy specific chain
188-
189-
![ipset](./Documentation/img/ipset.jpg)
190-
191-
Kube-router at runtime watches Kubernetes API server for changes in the
192-
namespace, network policy and pods and dynamically updates iptables and ipset
193-
configuration to reflect desired state of ingress firewall for the the pods.
194-
195-
### Pod Networking
196-
197-
[Kubernetes pod networking and beyond with BGP](https://cloudnativelabs.github.io/post/2017-05-22-kube-pod-networking)
198-
199-
Kube-router is expected to run on each Node. The subnet of the Node is obtained
200-
from the CNI configuration file on the Node or through the Node.PodCidr. Each
201-
kube-router instance on the Node acts as a BGP router and advertises the Pod
202-
CIDR assigned to the Node. Each Node peers with rest of the Nodes in the cluster
203-
forming full mesh. Learned routes about the Pod CIDR from the other Nodes (BGP
204-
peers) are injected into local Node routing table. On the data path, inter Node
205-
Pod-to-Pod communication is done by the routing stack on the Node.
206-
207-
## TODO
208-
- ~~convert Kube-router to docker image and run it as daemonset~~
209-
- heathcheck pods
210-
- explore integration of an ingress controller so Kube-router will be one complete solution for both east-west and north-south traffic
211-
- ~~get pod CIDR from node.PodCidr when kube-controller-manager is run with `--allocate-node-cidrs=true` option~~
212-
- explore the possibility of using IPVS direct routing mode
213-
- Explore the possibilities of making Kube-router on the node a Prometheus endpoint
214-
- ~~session persistence~~
215-
216116
## Acknowledgement
217117

218118
Kube-router build upon following libraries:
@@ -221,5 +121,4 @@ Kube-router build upon following libraries:
221121
- GoBGP: https://github.com/osrg/gobgp
222122
- Netlink: https://github.com/vishvananda/netlink
223123
- Ipset: https://github.com/janeczku/go-ipset
224-
- IPVS: https://github.com/mqliang/libipvs
225-
124+
- IPVS: https://github.com/docker/libnetwork/

0 commit comments

Comments
 (0)