1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
apiVersion: apps/v1
kind: Deployment
metadata:
name: slb
labels:
app: slb
spec:
replicas: 1
selector:
matchLabels:
app: slb
template:
metadata:
labels:
app: slb
annotations:
k8s.plugin.opnfv.org/nfn-network: '{ "type": "ovn4nfv", "interface": [{ "name": "left-pnetwork", "interface": "net0" }, { "name": "dync-net1", "interface": "net1" }]}'
spec:
containers:
- name: slb
image: rkamudhan/netshoot:v1.0
imagePullPolicy: IfNotPresent
stdin: true
tty: true
securityContext:
privileged: true
capabilities:
add: ["NET_ADMIN"]
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ngfw
labels:
app: ngfw
spec:
replicas: 1
selector:
matchLabels:
app: ngfw
template:
metadata:
labels:
app: ngfw
annotations:
k8s.plugin.opnfv.org/nfn-network: '{ "type": "ovn4nfv", "interface": [{ "name": "dync-net1", "interface": "net0" }, { "name": "dync-net2", "interface": "net1" }]}'
spec:
containers:
- name: ngfw
image: rkamudhan/netshoot:v1.0
imagePullPolicy: IfNotPresent
stdin: true
tty: true
securityContext:
privileged: true
capabilities:
add: ["NET_ADMIN"]
---
apiVersion: v1
data:
entrypoint.sh: |-
#!/bin/bash
# Always exit on errors.
set -ex
echo "" > /etc/config/network
cat > /etc/config/mwan3 <<EOF
config globals 'globals'
option mmx_mask '0x3F00'
option local_source 'lan'
EOF
eval "networks=$(grep nfn-network /tmp/podinfo/annotations | awk -F '=' '{print $2}')"
for net in $(echo -e $networks | jq -c ".interface[]")
do
interface=$(echo $net | jq -r .interface)
ipaddr=$(ifconfig $interface | awk '/inet/{print $2}' | cut -f2 -d ":" | awk 'NR==1 {print $1}')
vif="$interface"
cat >> /etc/config/network <<EOF
config interface '$vif'
option ifname '$interface'
option proto 'static'
option ipaddr '$ipaddr'
option netmask '255.255.255.0'
EOF
cat >> /etc/config/mwan3 <<EOF
config interface '$vif'
option enabled '1'
option family 'ipv4'
option reliability '2'
option count '1'
option timeout '2'
option failure_latency '1000'
option recovery_latency '500'
option failure_loss '20'
option recovery_loss '5'
option interval '5'
option down '3'
option up '8'
EOF
done
/sbin/procd &
/sbin/ubusd &
iptables -t nat -L
sleep 1
/etc/init.d/rpcd start
/etc/init.d/dnsmasq start
/etc/init.d/network start
/etc/init.d/odhcpd start
/etc/init.d/uhttpd start
/etc/init.d/log start
/etc/init.d/dropbear start
/etc/init.d/mwan3 restart
/etc/init.d/firewall restart
echo "Entering sleep... (success)"
# Sleep forever.
while true; do sleep 100; done
kind: ConfigMap
metadata:
name: sdewan-sh
namespace: default
...
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sdwan
namespace: default
labels:
app: sdwan
sdewanPurpose: cnf1
spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: sdwan
sdewanPurpose: cnf1
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
k8s.plugin.opnfv.org/nfn-network: '{ "type": "ovn4nfv", "interface": [{ "name": "dync-net2", "interface": "net0" }, { "name": "right-pnetwork", "interface": "net1" }]}'
labels:
app: sdwan
sdewanPurpose: cnf1
spec:
containers:
- command:
#- sleep
#- "3600"
- /bin/sh
- /tmp/sdewan/entrypoint.sh
image: integratedcloudnative/openwrt:0.3.0
imagePullPolicy: IfNotPresent
name: sdewan
readinessProbe:
failureThreshold: 5
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 1
securityContext:
privileged: true
capabilities:
add: ["NET_ADMIN"]
procMount: Default
volumeMounts:
- mountPath: /tmp/sdewan
name: sdewan-sh
readOnly: true
- mountPath: /tmp/podinfo
name: podinfo
readOnly: true
restartPolicy: Always
volumes:
- configMap:
defaultMode: 420
name: sdewan-sh
name: sdewan-sh
- name: podinfo
downwardAPI:
items:
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
|