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
|
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2018
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
set -o errexit
set -o nounset
set -o pipefail
source _common.sh
source _functions.sh
# populate_CSAR_ovn4nfv() - Create content used for OVN4NFV functional test
function populate_CSAR_provider_network {
local csar_id=$1
_checks_args $csar_id
pushd ${CSAR_DIR}/${csar_id}
cat << MULTUS_NET > onap-ovn4nfvk8s-network.yaml
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: $ovn_multus_network_name
spec:
config: '{
"cniVersion": "0.3.1",
"name": "ovn4nfv-k8s-plugin",
"type": "ovn4nfvk8s-cni"
}'
MULTUS_NET
cat << NETWORK > ovn-virt-net1.yaml
apiVersion: v1
kind: onapNetwork
metadata:
name: ovn-virt-net1
cnitype : ovn4nfvk8s
spec:
name: ovn-virt-net1
subnet: 10.1.20.0/24
gateway: 10.1.20.1/24
NETWORK
cat << NETWORK > ovn-virt-net2.yaml
apiVersion: v1
kind: onapNetwork
metadata:
name: ovn-virt-net2
cnitype : ovn4nfvk8s
spec:
name: ovn-virt-net2
subnet: 10.1.21.0/24
gateway: 10.1.21.1/24
NETWORK
cat << DEPLOYMENT > firewall.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: firewall
labels:
app: ovn4nfv
spec:
replicas: 1
selector:
matchLabels:
app: ovn4nfv
template:
metadata:
labels:
app: ovn4nfv
annotations:
k8s.v1.cni.cncf.io/networks: '[{ "name": "$ovn_multus_network_name"}]'
ovnNetwork: '[ { "name": ""ovn-virt-net1"", "interface": "net0" , "defaultGateway": "false", "ipAddress":"10.1.20.2"},
{ "name": "prod-net1", "interface": "net1", "defaultGateway": "false", "ipAddress":"10.1.5.1/24"}]'
ovnNetworkRoutes: '[{ "dst": "0.0.0.0/0", "gw": "10.1.20.3", "dev": "net0" }]'
spec:
containers:
- name: firewall
image: "busybox"
command: ["top"]
stdin: true
tty: true
DEPLOYMENT
cat << DEPLOYMENT > webcache.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: webcache
labels:
app: ovn4nfv
spec:
replicas: 1
selector:
matchLabels:
app: ovn4nfv
template:
metadata:
labels:
app: ovn4nfv
annotations:
k8s.v1.cni.cncf.io/networks: '[{ "name": "$ovn_multus_network_name"}]'
ovnNetwork: '[{ "name": "ovn-virt-net1", "interface": "net0" , "defaultGateway": "false", "ipAddress":"10.1.20.3"},
{ "name": "ovn-virt-net2", "interface": "net1" , "defaultGateway": "false", "ipAddress":"10.1.21.2"}]'
ovnNetworkRoutes: '[{ "dst": "10.1.5.0/24", "gw": "10.1.20.2", "dev": "net0" },
{ "dst": "0.0.0.0/0", "gw": "10.1.21.3", "dev": "net1" }]'
spec:
containers:
- name: webcache
image: "busybox"
command: ["top"]
stdin: true
tty: true
DEPLOYMENT
cat << DEPLOYMENT > sdwan.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sdwan
labels:
app: ovn4nfv
spec:
replicas: 1
selector:
matchLabels:
app: ovn4nfv
template:
metadata:
labels:
app: ovn4nfv
annotations:
k8s.v1.cni.cncf.io/networks: '[{ "name": "$ovn_multus_network_name"}]'
ovnNetwork: '[ { "name": ""ovn-virt-net2"", "interface": "net0" , "defaultGateway": "false", "ipAddress":"10.1.21.3"},
{ "name": "prod-net2", "interface": "net1", "defaultGateway": "false", "ipAddress":"10.1.10.2/24"}]'
ovnNetworkRoutes: '[{ "dst": "0.0.0.0/0", "gw": "10.1.10.1", "dev": "net1" },
{ "dst": "10.1.5.0/24", "gw": "10.1.21.2", "dev": "net0" },
{ "dst": "10.1.20.0/24", "gw": "10.1.21.2", "dev": "net0" }]'
spec:
containers:
- name: sdwan
image: "busybox"
command: ["top"]
stdin: true
tty: true
DEPLOYMENT
popd
}
csar_id=d5718572-3b9a-11e9-b210-d663bd873dda
# Setup
install_ovn_deps
populate_CSAR_provider_network $csar_id
pushd ${CSAR_DIR}/${csar_id}
for net in ovn-virt-net1 ovn-virt-net2; do
cleanup_network $net.yaml
echo "Create OVN Network $net network"
init_network $net.yaml
done
kubectl apply -f onap-ovn4nfvk8s-network.yaml
setup firewall webcache sdwan
# Test
deployment_pod=$(kubectl get pods | grep firewall | awk '{print $1}')
echo "===== $deployment_pod details ====="
kubectl exec -it $deployment_pod -- ip a
multus_nic=$(kubectl exec -it $deployment_pod -- ifconfig | grep "net1")
if [ -z "$multus_nic" ]; then
echo "The $deployment_pod pod doesn't contain the net1 nic"
exit 1
fi
# Teardown
teardown firewall webcache sdwan
cleanup_network ovn-virt-net1.yaml
cleanup_network ovn-virt-net2.yaml
popd
|