Skip to content

Commit

Permalink
move forward clab dev
Browse files Browse the repository at this point in the history
Signed-off-by: karampok <karampok@gmail.com>
  • Loading branch information
karampok committed May 8, 2024
1 parent 1c6c6eb commit 2f900b4
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 184 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
clab-vlab
*.bak
.pull-secret.json
.github-argo
pull-secret.yaml
Expand Down
105 changes: 105 additions & 0 deletions graceful/red-pod-two.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: red-two
spec:
replicas: 2
selector:
matchLabels:
app: red-two
template:
metadata:
labels:
app: red-two
spec:
containers:
- name: agnhost
image: quay.io/karampok/snife:latest
imagePullPolicy: Always
securityContext:
privileged: true
- name: server
image: registry.k8s.io/e2e-test-images/agnhost:2.40
command:
- /agnhost
- netexec
- --http-port=8080
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
ports:
- name: http
containerPort: 8080
- command: ["bash", "-c"]
args: ["iperf3 -s -p 60000"]
image: quay.io/karampok/snife:latest
imagePullPolicy: Always
name: iperf3
ports:
- name: iperf3
containerPort: 60000
---
apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/address-pool: red
metallb.universe.tf/allow-shared-ip: "key-to-share-red-two"
name: red-two-svc-http
spec:
type: LoadBalancer
externalTrafficPolicy: Local
allocateLoadBalancerNodePorts: false
ports:
- name: http
port: 5555
protocol: TCP
targetPort: 8080
selector:
app: red-two
---
apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/address-pool: red
metallb.universe.tf/allow-shared-ip: "key-to-share-red-two"
name: red-two-svc-iperf-tcp
spec:
type: LoadBalancer
externalTrafficPolicy: Local
allocateLoadBalancerNodePorts: false
ports:
- name: tcp
port: 60000
protocol: TCP
targetPort: 60000
selector:
app: red-two
---
apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/address-pool: red
metallb.universe.tf/allow-shared-ip: "key-to-share-red-two"
name: red-two-svc-iperf-udp
spec:
type: LoadBalancer
externalTrafficPolicy: Local
allocateLoadBalancerNodePorts: false
ports:
- name: udp
port: 60000
protocol: UDP
targetPort: 60000
selector:
app: red-two

# show bgp vrf red ipv4 summary
# from red
# alias urlencode="python3 -c \"import sys, urllib.parse; print(urllib.parse.quote(''.join(sys.stdin.readlines())))\""
# curl -s http://6.6.6.1/shell?cmd="$(echo "env|grep -i node" | urlencode)"|jq -r '.output'
6 changes: 3 additions & 3 deletions k00-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ nodes:
- role: worker
labels:
metallb-speaker: ""
# - role: worker
# labels:
# metallb-speaker: ""
- role: worker
labels:
metallb-speaker: ""
19 changes: 11 additions & 8 deletions opt/frr-one/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ no ipv6 forwarding
!
ip router-id 10.10.10.21
!
interface eth0
ip address 10.10.20.1/24
exit
interface eth1.blue
ip address 10.10.10.1/24
exit
Expand All @@ -44,11 +47,11 @@ router bgp 65001
no bgp ebgp-requires-policy
no bgp network import-check

! neighbor SPINE peer-group
! neighbor SPINE remote-as external
! neighbor SPINE description spine
! neighbor SPINE advertisement-interval 0
! neighbor eth0 interface peer-group SPINE
neighbor SPINE peer-group
neighbor SPINE remote-as external
neighbor SPINE description spine
neighbor SPINE advertisement-interval 0
neighbor eth0 interface peer-group SPINE

neighbor METALLB peer-group
neighbor METALLB passive
Expand All @@ -57,10 +60,10 @@ router bgp 65001
neighbor METALLB timers 30 90

neighbor 10.10.10.102 peer-group METALLB
! neighbor 10.10.10.103 peer-group METALLB
neighbor 10.10.10.103 peer-group METALLB
!
address-family ipv4 unicast
! network 10.10.10.0/24
network 10.10.10.0/24
neighbor METALLB activate
exit-address-family
exit
Expand Down Expand Up @@ -99,7 +102,7 @@ router bgp 8012 vrf red
neighbor RD timers 30 90

neighbor 12.12.12.102 peer-group RD
! neighbor 12.12.12.103 peer-group RD
neighbor 12.12.12.103 peer-group RD
!
address-family ipv4 unicast
neighbor RD activate
Expand Down
5 changes: 3 additions & 2 deletions opt/frr-zero/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ no ipv6 forwarding
!
ip router-id 10.10.10.11
!
interface eth1
interface eth0
description lower part
ip address 10.10.0.1/24
ip address 10.10.20.254/24
exit
!
interface lo
Expand All @@ -29,6 +29,7 @@ router bgp 65000
neighbor LEAF remote-as external
neighbor LEAF description leaf
neighbor LEAF advertisement-interval 0
neighbor LEAF default-originate
neighbor eth0 interface peer-group LEAF
!
address-family ipv4 unicast
Expand Down
10 changes: 1 addition & 9 deletions pkg/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ import (

func Clean() *Run {
r := NewRun("Clean")
r.StepCanFail(S("Clean Red/Green-in"), S(cleanup06))
r.StepCanFail(S("Clean Workstation"), S(cleanup05))
r.StepCanFail(S("Clean VMS"), S(cleanup04))
r.StepCanFail(S("Clean clients"), S(cleanup03))
r.StepCanFail(S("Clean SVC"), S(cleanup02))
r.Step(S("Clean L3"), nil)
for _, cmd := range cleanupL3 {
r.StepCanFail(nil, S(cmd))
}
//r.StepCanFail(S("Clean VMS"), S(cleanup04))
r.Step(S("Clean L2"), nil)
for _, cmd := range cleanupL2 {
r.StepCanFail(nil, S(cmd))
Expand Down
83 changes: 37 additions & 46 deletions pkg/gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,56 @@ func SetupInfra() *Run {
r := NewRun("Setup Virtual Infra")
r.BreakPoint()
r.Step(S("Build L2 fabric"), S(bridges))
if true {
return r
}

r.BreakPoint()
r.Step(S("Enable podman to attach containers"), nil)
r.StepCanFail(nil, S(cmd02))

r.BreakPoint()
r.Step(S("Enable libvirt to attach vms"), nil)
r.StepCanFail(nil, S(cmd03))
r.Step(nil, S(cmd03))

r.BreakPoint()
r.Step(S("Setup GW-zero (L3 Gateway) on access net"), S(gw0))
r.Step(S("Configure GW-zero with upstream"), S(gw00))

r.BreakPoint()
r.Step(S("Setup workstation"), S(workstation))
r.Step(S("Config workstation"), S(workstationConfig))
r.Step(S("podman logs workstation"), nil)

r.BreakPoint()
r.Step(S("Setup GW-one (L3 Gateway) on baremetal,access net"), S(gw1))
r.Step(S("Configure GW-one with vlan"), S(gw10))

r.BreakPoint()
r.Step(S("Setup GW-two (L3 Gateway) on baremetal,access,green net"), S(gw2))
r.Step(S("Configure GW-two with vlan"), S(gw20))
r.Step(S("Setup green VRF in router"), S(gw21))
r.Step(S("Setup red VRF in router"), S(gw22))
// r.Step(S("Configure GW-zero with upstream"), S(gw00))

r.BreakPoint()
r.Step(S("Setup green client on green net "), S(green))
r.Step(S("Setup red client on red net "), S(red))
r.Step(S("Setup macnet host on baremetal net "), S(macnet))
c := "containerlab deploy"
r.Step(S("Containerlab"), S(c))
//r.Step(S("Setup workstation"), S(workstation))

r.BreakPoint()
r.Step(S("Setup DNS (CoreDNS) service"), S(dns))
r.Step(S("Configure routing for DNS"), S(dns01))

r.BreakPoint()
r.Step(S("Setup proxy"), S(proxy))
r.Step(S("Configure routing for proxy"), S(proxy01))

r.Step(S("proxy/dns needs connectivity"), nil)
// r.BreakPoint()
// r.Step(S("Setup GW-one (L3 Gateway) on baremetal,access net"), S(gw1))
// r.Step(S("Configure GW-one with vlan"), S(gw10))
//
// r.BreakPoint()
// r.Step(S("Setup GW-two (L3 Gateway) on baremetal,access,green net"), S(gw2))
// r.Step(S("Configure GW-two with vlan"), S(gw20))
// r.Step(S("Setup green VRF in router"), S(gw21))
// r.Step(S("Setup red VRF in router"), S(gw22))
//
// r.BreakPoint()
// r.Step(S("Setup green client on green net "), S(green))
// r.Step(S("Setup red client on red net "), S(red))
// r.Step(S("Setup macnet host on baremetal net "), S(macnet))
//
// r.BreakPoint()
// r.Step(S("Setup DNS (CoreDNS) service"), S(dns))
// r.Step(S("Configure routing for DNS"), S(dns01))
//
// r.BreakPoint()
// r.Step(S("Setup proxy"), S(proxy))
// r.Step(S("Configure routing for proxy"), S(proxy01))
//
// r.Step(S("proxy/dns needs connectivity"), nil)
// not using my image, I can do
// r.Step(S("podman run --net=container:dns --rm --privileged -it quay.io/karampok/snife /bin/bash"), nil)

// r.BreakPoint()
// r.Step(S("Setup DHCPv4"), S(dhcpv4))
// r.Step(S("Setup DHCPv6"), S(dhcpv6))

r.BreakPoint()
r.Step(S("Create baremetal with kcli"), S(vbmh))

r.BreakPoint()
r.Step(S("Create bmc with Sushy"), S(sushy))
r.Step(S("Configure BMC networking (access ACM Hub) "), S(sushyNetconfig))

//
// r.BreakPoint()
// r.Step(S("Create baremetal with kcli"), S(vbmh))
//
// r.BreakPoint()
// r.Step(S("Create bmc with Sushy"), S(sushy))
// r.Step(S("Configure BMC networking (access ACM Hub) "), S(sushyNetconfig))
//
// r.BreakPoint()
// r.Step(S("Setup kernel client on baremetal two interfaces"), S(kernel))
// r.Step(S(helpkernel), nil)
Expand Down
58 changes: 12 additions & 46 deletions pkg/l2-networks.go
Original file line number Diff line number Diff line change
@@ -1,70 +1,36 @@
package pkg

var bridges = `ip link add name sw0 type bridge
ip link set mtu 9000 dev sw0
ip link set dev sw0 up
var bridges = `ip link add name dataplane type bridge
ip link set dev dataplane up
ip link add name sw1 type bridge
ip link set mtu 9000 dev sw1
ip link set dev sw1 up
ip link add name ixp-net type bridge
ip link set mtu 9000 dev ixp-net
ip link set dev ixp-net up`

var cmd02 = `mkdir -p /etc/cni/net.d
cp ./opt/cni.d/{access,baremetal,green-net,red-net,bmc}.conflist /etc/cni/net.d/
# podman network ls (minimal CNI, no ipam, gateway or anything)`

var cmd03 = `cat > /tmp/baremetal.xml <<EOM
<network>
<name>baremetal</name>
<forward mode="bridge"/>
<bridge name="baremetal"/>
</network>
EOM
virsh net-create /tmp/baremetal.xml
cat > /tmp/bmc.xml <<EOM
var cmd03 = `cat > /tmp/sw1.xml <<EOM
<network>
<name>bmc</name>
<name>sw1</name>
<forward mode="bridge"/>
<bridge name="bmc"/>
<bridge name="sw1"/>
</network>
EOM
virsh net-create /tmp/bmc.xml
cat > /tmp/dataplane.xml <<EOM
virsh net-create /tmp/sw1.xml
rm /tmp/sw1.xml
<network>
<name>dataplane</name>
<forward mode="bridge"/>
<bridge name="dataplane"/>
</network>
EOM
virsh net-create /tmp/dataplane.xml
cat > /tmp/access.xml <<EOM
<network>
<name>access</name>
<forward mode="bridge"/>
<bridge name="access"/>
</network>
EOM
virsh net-create /tmp/access.xml
rm /tmp/sw1.xml
#virsh net-list`

var cleanupL2 = []string{
"ip link delete access",
`iptables -F
iptables -X
iptables -t nat -F
iptables -t mangle -F
iptables -X -t nat
ip link del dev cni-podman0
ip link del dev virbr0`,
"ip link delete baremetal",
"ip link delete green-net",
"ip link delete red-net",
"ip link delete bmc",
"ip link delete sw1",
"ip link delete dataplane",
"rm /etc/cni/net.d/*",
"virsh net-destroy baremetal",
"virsh net-destroy access",
"ip link delete ixp-net",
"virsh net-destroy sw1",
"virsh net-destroy dataplane",
"rm /tmp/*.xml",
}
Loading

0 comments on commit 2f900b4

Please sign in to comment.