Skip to content

Commit 82818d8

Browse files
authored
Merge pull request #122 from cloudnativelabs/118-kuber-router-kubeadm
use kube-router as kube-proxy replacement
2 parents 79a176a + d335651 commit 82818d8

File tree

3 files changed

+194
-2
lines changed

3 files changed

+194
-2
lines changed

Documentation/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Please see the [steps](https://github.com/cloudnativelabs/kube-router/blob/maste
6060
#### bootkube
6161
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)
6262

63+
#### kubeadm
64+
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/)
65+
6366
### deployment
6467

6568
Depending on what functionality of kube-router you want to use, multiple deployment options are possible. You can use the flags `--run-firewall`, `--run-router`, `--run-service-proxy` to selectively enable only required functionality of kube-router.

Documentation/kubeadm.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,31 @@
22

33
Please follow the [steps](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/) to install Kubernetes cluster with Kubeadm.
44

5-
Kube-router relies on kube-controll-manager to allocate pod CIDR for the nodes. So you must use `kubeadm init` with `--pod-network-cidr` flag.
5+
Kube-router relies on kube-controll-manager to allocate pod CIDR for the nodes. So you must use `kubeadm init` with `--pod-network-cidr` flag. On the controller node after `kubeadm init` is complete:
6+
7+
Kube-router provides pod networking, network policy and high perfoming IPVS/LVS based service proxy. Depending on you choose to use kube-router for service proxy you have two options.
8+
9+
## kube-router providing pod networking and network policy
610

711
For the step #3 **Installing a pod network** install a kube-router pod network and network policy add-on with the following command:
812

9-
```
13+
```sh
1014
kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml
1115
```
16+
17+
## kube-router providing service proxy, firewall and pod networking.
18+
19+
For the step #3 **Installing a pod network** install a kube-router pod network and network policy add-on with the following command:
20+
21+
```sh
22+
KUBECONFIG=/etc/kubernetes/admin.conf kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter-all-features.yaml
23+
```
24+
25+
Now since kube-router provides service proxy as well. Run below commands to remove kube-proxy and cleanup any iptables configuratin it may have done.
26+
27+
```sh
28+
KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kube-system delete ds kube-proxy
29+
docker run --privileged --net=host gcr.io/google_containers/kube-proxy-amd64:v1.7.3 kube-proxy --cleanup-iptables
30+
```
31+
32+
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: kube-router-cfg
5+
namespace: kube-system
6+
labels:
7+
tier: node
8+
k8s-app: kube-router
9+
data:
10+
cni-conf.json: |
11+
{
12+
"name":"kubernetes",
13+
"type":"bridge",
14+
"bridge":"kube-bridge",
15+
"isDefaultGateway":true,
16+
"ipam": {
17+
"type":"host-local"
18+
}
19+
}
20+
---
21+
apiVersion: extensions/v1beta1
22+
kind: DaemonSet
23+
metadata:
24+
labels:
25+
k8s-app: kube-router
26+
tier: node
27+
name: kube-router
28+
namespace: kube-system
29+
spec:
30+
template:
31+
metadata:
32+
labels:
33+
k8s-app: kube-router
34+
tier: node
35+
annotations:
36+
scheduler.alpha.kubernetes.io/critical-pod: ''
37+
pod.beta.kubernetes.io/init-containers: '[
38+
{
39+
"name": "install-cni",
40+
"image": "busybox",
41+
"command": [ "/bin/sh", "-c", "set -e -x; if [ ! -f /etc/cni/net.d/10-kuberouter.conf ]; then TMP=/etc/cni/net.d/.tmp-kuberouter-cfg; cp /etc/kube-router/cni-conf.json ${TMP}; mv ${TMP} /etc/cni/net.d/10-kuberouter.conf; fi" ],
42+
"volumeMounts": [
43+
{
44+
"name": "cni",
45+
"mountPath": "/etc/cni/net.d"
46+
},
47+
{
48+
"name": "kube-router-cfg",
49+
"mountPath": "/etc/kube-router"
50+
}
51+
],
52+
"volumes": {
53+
"name": "cni",
54+
"hostPath": {
55+
"path": "/etc/cni/net.d"
56+
}
57+
}
58+
}
59+
]'
60+
spec:
61+
serviceAccountName: kube-router
62+
serviceAccount: kube-router
63+
containers:
64+
- name: kube-router
65+
image: cloudnativelabs/kube-router-git
66+
imagePullPolicy: Always
67+
args:
68+
- --run-router=true
69+
- --run-firewall=true
70+
- --run-service-proxy=true
71+
- --kubeconfig=/var/lib/kube-router/kubeconfig
72+
env:
73+
- name: NODE_NAME
74+
valueFrom:
75+
fieldRef:
76+
fieldPath: spec.nodeName
77+
resources:
78+
requests:
79+
cpu: 250m
80+
memory: 250Mi
81+
securityContext:
82+
privileged: true
83+
volumeMounts:
84+
- name: lib-modules
85+
mountPath: /lib/modules
86+
readOnly: true
87+
- name: cni
88+
mountPath: /etc/cni/net.d
89+
- name: kubeconfig
90+
mountPath: /var/lib/kube-router
91+
readOnly: true
92+
hostNetwork: true
93+
tolerations:
94+
- key: CriticalAddonsOnly
95+
operator: Exists
96+
- effect: NoSchedule
97+
key: node-role.kubernetes.io/master
98+
operator: Exists
99+
volumes:
100+
- hostPath:
101+
path: /lib/modules
102+
name: lib-modules
103+
- hostPath:
104+
path: /etc/cni/net.d
105+
name: cni
106+
- name: kubeconfig
107+
configMap:
108+
name: kube-proxy
109+
items:
110+
- key: kubeconfig.conf
111+
path: kubeconfig
112+
- name: kube-router-cfg
113+
configMap:
114+
name: kube-router-cfg
115+
---
116+
apiVersion: v1
117+
kind: ServiceAccount
118+
metadata:
119+
name: kube-router
120+
namespace: kube-system
121+
---
122+
kind: ClusterRole
123+
apiVersion: rbac.authorization.k8s.io/v1beta1
124+
metadata:
125+
name: kube-router
126+
namespace: kube-system
127+
rules:
128+
- apiGroups:
129+
- ""
130+
resources:
131+
- namespaces
132+
- pods
133+
- services
134+
- nodes
135+
- endpoints
136+
verbs:
137+
- list
138+
- get
139+
- watch
140+
- apiGroups:
141+
- "networking.k8s.io"
142+
resources:
143+
- networkpolicies
144+
verbs:
145+
- list
146+
- get
147+
- watch
148+
- apiGroups:
149+
- extensions
150+
resources:
151+
- networkpolicies
152+
verbs:
153+
- get
154+
- list
155+
- watch
156+
---
157+
kind: ClusterRoleBinding
158+
apiVersion: rbac.authorization.k8s.io/v1beta1
159+
metadata:
160+
name: kube-router
161+
roleRef:
162+
apiGroup: rbac.authorization.k8s.io
163+
kind: ClusterRole
164+
name: kube-router
165+
subjects:
166+
- kind: ServiceAccount
167+
name: kube-router
168+
namespace: kube-system

0 commit comments

Comments
 (0)