Add SDWAN build and test script
[icn.git] / sdwan / test / sdwan-openwrt-ovn.yml
1 ---
2 apiVersion: k8s.plugin.opnfv.org/v1alpha1
3 kind: Network
4 metadata:
5   name: ovn-port-net
6 spec:
7   cniType : ovn4nfv
8   ipv4Subnets:
9   - subnet: 172.16.33.0/24
10     name: subnet1
11     gateway: 172.16.33.1/24
12
13 ---
14 apiVersion: k8s.plugin.opnfv.org/v1alpha1
15 kind: Network
16 metadata:
17   name: ovn-priv-net
18 spec:
19   cniType : ovn4nfv
20   ipv4Subnets:
21   - subnet: 172.16.44.0/24
22     name: subnet1
23     gateway: 172.16.44.1/24
24
25 ---
26 apiVersion: v1
27 kind: ConfigMap
28 metadata:
29   name: sdwan-config-ovn
30 data:
31   entrypoint.sh: |
32     #!/bin/bash
33     # Always exit on errors.
34     set -e
35
36     interface0=net0
37     ipaddr0=`ifconfig $interface0 | awk '/inet/{print $2}' | cut -f2 -d ":" | awk 'NR==1 {print $1}'`
38
39     interface1=net1
40     ipaddr1=`ifconfig $interface1 | awk '/inet/{print $2}' | cut -f2 -d ":" | awk 'NR==1 {print $1}'`
41
42     net_config=/etc/config/network
43     cat >> $net_config << EOF
44     config interface 'wan'
45         option ifname '$interface0'
46         option proto 'static'
47         option ipaddr '$ipaddr0'
48         option netmask '255.255.255.0'
49
50     config interface 'wanb'
51         option ifname '$interface1'
52         option proto 'static'
53         option ipaddr '$ipaddr1'
54         option netmask '255.255.255.0'
55     EOF
56
57     /sbin/procd &
58     /sbin/ubusd &
59     iptables -S
60     sleep 1
61     /etc/init.d/rpcd start
62     /etc/init.d/dnsmasq start
63     /etc/init.d/network start
64     /etc/init.d/odhcpd start
65     /etc/init.d/uhttpd start
66     /etc/init.d/log start
67     /etc/init.d/dropbear start
68     /etc/init.d/mwan3 restart
69
70     echo "Entering sleep... (success)"
71
72     # Sleep forever.
73     while true; do sleep 100; done
74
75 ---
76 apiVersion: v1
77 kind: Pod
78 metadata:
79   name: sdwan-ovn-pod
80   annotations:
81     k8s.v1.cni.cncf.io/networks: '[{ "name": "ovn-networkobj"}]'
82     k8s.plugin.opnfv.org/nfn-network: '{ "type": "ovn4nfv", "interface": [{ "name": "ovn-port-net", "interface": "net0" , "defaultGateway": "false"},
83        { "name": "ovn-priv-net", "interface": "net1" , "defaultGateway": "false"}]}'
84 spec:
85   containers:
86   - name: sdwan-ovn-pod
87     image: hle2/openwrt-1806-mwan3:v0.1.0
88     ports:
89       - containerPort: 22
90       - containerPort: 80
91     command:
92     - /bin/sh
93     - /init/entrypoint.sh
94     imagePullPolicy: IfNotPresent
95     securityContext:
96       privileged: true
97     volumeMounts:
98       - name: entrypoint-sh
99         mountPath: /init
100   volumes:
101     - name: entrypoint-sh
102       configMap:
103         name: sdwan-config-ovn
104         items:
105         - key: entrypoint.sh
106           path: entrypoint.sh