Skip to content

Commit

Permalink
update lab to fit a graceful restart demo
Browse files Browse the repository at this point in the history
  • Loading branch information
karampok committed May 2, 2024
1 parent 24f3ca0 commit 1c6c6eb
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 100 deletions.
71 changes: 50 additions & 21 deletions dayX/green-net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
app: green
spec:
containers:
- name: snife-c
- name: agnhost
image: quay.io/karampok/snife:latest
imagePullPolicy: Always
securityContext:
Expand All @@ -33,17 +33,25 @@ spec:
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: green
name: green-svc-local
metallb.universe.tf/allow-shared-ip: "key-to-share"
name: green-svc-http
spec:
type: LoadBalancer
externalTrafficPolicy: Local
externalTrafficPolicy: Cluster
allocateLoadBalancerNodePorts: false
ports:
- name: http
Expand All @@ -53,23 +61,44 @@ spec:
selector:
app: green
---
# apiVersion: v1
# kind: Service
# metadata:
# annotations:
# metallb.universe.tf/address-pool: green
# name: green-svc-cluster
# spec:
# type: LoadBalancer
# externalTrafficPolicy: Cluster
# ports:
# - name: http
# port: 80
# protocol: TCP
# targetPort: 8080
# selector:
# app: green
#
apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/address-pool: green
metallb.universe.tf/allow-shared-ip: "key-to-share"
name: green-svc-iperf-tcp
spec:
type: LoadBalancer
externalTrafficPolicy: Cluster
allocateLoadBalancerNodePorts: false
ports:
- name: tcp
port: 60000
protocol: TCP
targetPort: 60000
selector:
app: green
---
apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/address-pool: green
metallb.universe.tf/allow-shared-ip: "key-to-share"
name: green-svc-iperf-udp
spec:
type: LoadBalancer
externalTrafficPolicy: Cluster
allocateLoadBalancerNodePorts: false
ports:
- name: udp
port: 60000
protocol: UDP
targetPort: 60000
selector:
app: green

# show bgp vrf green ipv4 summary
# from green
# alias urlencode="python3 -c \"import sys, urllib.parse; print(urllib.parse.quote(''.join(sys.stdin.readlines())))\""
Expand Down
1 change: 1 addition & 0 deletions graceful/blue-peering.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ spec:
peerASN: 65001
myASN: 7003
holdTime: 60s
gracefulRestart: true
nodeSelectors:
- matchLabels:
metallb-speaker: ""
Expand Down
1 change: 0 additions & 1 deletion graceful/green-peering.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
peerASN: 8011
myASN: 7003
holdTime: 60s
gracefulRestart: true
nodeSelectors:
- matchLabels:
metallb-speaker: ""
Expand Down
12 changes: 9 additions & 3 deletions mno-template/day1/metallb-green.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# passiveMode: false
# minimumTtl: 254
---
apiVersion: metallb.io/v1beta1
apiVersion: metallb.io/v1beta2
kind: BGPPeer
metadata:
name: green
Expand All @@ -22,8 +22,14 @@ spec:
peerAddress: 10.10.1.1
peerASN: 65001
myASN: 7003
# holdTime: "180s"
# bfdProfile: bfd-profile
holdTime: 60s
gracefulRestart: true
nodeSelectors:
- matchLabels:
metallb-speaker: ""
# - matchExpressions:
# - key: node-role.kubernetes.io/control-plane
# operator: DoesNotExist
---
apiVersion: v1
kind: ConfigMap
Expand Down
19 changes: 13 additions & 6 deletions opt/frr-one/frr.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
frr defaults datacenter
hostname frr-one
log file /tmp/frr.log debugging
log timestamp precision 3

!
!debug bgp keepalives
debug zebra events
debug zebra kernel
debug zebra rib
debug zebra nht
debug zebra nexthop
debug bgp keepalives
debug bgp neighbor-events
no debug bgp nh0
debug bgp bfd
no debug bgp update-groups
debug bgp updates out
debug bgp nht
debug bgp updates in
debug bgp updates out
debug bgp zebra
no debug zebra kernel
debug bfd peer
debug bfd zebra
debug bfd network
!
no ipv6 forwarding
!
Expand Down
95 changes: 26 additions & 69 deletions pkg/run-bgp-restart-demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,97 +4,54 @@ import (
. "github.com/saschagrunert/demo"
)

var runBGP = `
tmux new-window -n clients
func RunBGPGracefulRestart() *Run {
r := NewRun("Run BPG graceful restart demo")

c := `kubectl apply -f graceful/blue-peering.yaml
kubectl apply -f graceful/green-peering.yaml
kubectl apply -f graceful/red-peering.yaml`
r.Step(S("Setup peering"), S(c))

d := `kubectl apply -f graceful/blue-pod-one.yaml
kubectl apply -f graceful/green-pod-one.yaml
kubectl apply -f graceful/red-pod-one.yaml`
r.Step(S("Deploy workloads"), S(d))

c = `kubectl get pods -o wide; kubectl get svc`
r.Step(S("Verify workload"), S(c))

c = `tmux new-window -n clients
tmux send-keys -t clients.0 "docker exec -it clab-vlab-sidecar-gw1 /bin/bash" C-m C-m C-m
tmux send-keys -t clients.0 "curl -sf http://4.4.4.1:5555/hostname" C-m C-m C-m
tmux send-keys -t clients.0 "while true;do curl -sf http://4.4.4.1:5555/hostname --connect-timeout 1 -o /dev/null || printf \"%s \" \$(date +%s) ;sleep 1;done" C-m
tmux split-window -v -t clients
tmux send-keys -t clients.1 "docker exec -it clab-vlab-sidecar-gw1 /bin/bash" C-m C-m C-m
tmux send-keys -t clients.1 "ip vrf exec green /bin/bash" C-m C-m C-m
tmux send-keys -t clients.1 "curl -sf http://5.5.5.1:5555/hostname" C-m C-m C-m
tmux send-keys -t clients.1 "while true;do curl -sf http://5.5.5.1:5555/hostname --connect-timeout 1 -o /dev/null || printf \"%s \" \$(date +%s) ;sleep 1;done" C-m
tmux split-window -v -t clients
tmux send-keys -t clients.2 "docker exec -it clab-vlab-sidecar-gw1 /bin/bash" C-m C-m C-m
tmux send-keys -t clients.2 "ip vrf exec red /bin/bash" C-m C-m C-m
tmux send-keys -t clients.2 "curl -sf http://6.6.6.1:5555/hostname" C-m C-m C-m
tmux send-keys -t clients.2 "while true;do curl -sf http://6.6.6.1:5555/hostname --connect-timeout 1 -o /dev/null || printf \"%s \" \$(date +%s) ;sleep 1;done" C-m
tmux select-layout -t clients even-vertical
tmux select-window -t clients; tmux setw synchronize-panes on
`
r.Step(nil, S(c))

tmux new-window -n gateway
tmux send-keys -t gateway.0 "docker exec clab-vlab-gw1 vtysh -c \"show bgp vrf all summary\"" C-m C-m C-m
c = `tmux new-window -n gateway
tmux send-keys -t gateway.0 "docker exec clab-vlab-gw1 vtysh -c 'show bgp vrf all summary'" C-m C-m C-m
tmux send-keys -t gateway.0 "watch -d -c -n 1 docker exec clab-vlab-gw1 vtysh -c \\\"show ip bgp vrf all\\\""
# tmux send-keys -t gateway.0 "bash" C-m C-m
# tmux send-keys -t gateway.0 "while true; do docker exec clab-vlab-gw1 vtysh -c 'show ip bgp vrf all'|grep 4.4.4.1 ; echo \"== \$(date --utc)\" ; sleep 1; done" C-m
tmux split-window -h -t gateway
tmux send-keys -t gateway.1 "docker exec clab-vlab-gw1 tail -f /tmp/frr.log" C-m
tmux split-window -v -t gateway
tmux send-keys -t gateway.2 "docker exec -it k00-worker /bin/bash" C-m
tmux send-keys -t gateway.2 "while true;do curl -sf http://127.0.0.1:7473/livez --connect-timeout 1 -o /dev/null || printf \"%s \" \$(date +%s) ;sleep 1;done" C-m
tmux split-window -v -t gateway
tmux send-keys -t gateway.3 "kubectl -n metallb-system logs -c reloader (kubectl -n metallb-system get pods -l component=speaker -o name) -f" C-m
tmux send-keys -t gateway.2 "kubectl -n metallb-system logs -c reloader (kubectl -n metallb-system get pods -l component=speaker -o name) -f" C-m
tmux split-window -v -t gateway
tmux send-keys -t gateway.4 "kubectl set image daemonset/speaker frr=quay.io/frrouting/frr:9.1.0 -n metallb-system; kubectl -n metallb-system get pods -o wide -w"
tmux send-keys -t gateway.3 "kubectl set image daemonset/speaker frr=quay.io/frrouting/frr:9.1.0 -n metallb-system; kubectl -n metallb-system get pods -o wide -w"
`

var _ = `
exec -it clab-vlab-h00 /bin/bash" C-m C-m C-m
tmux split-window -h -t Nodes
ip vrf exec green /bin/bash
while true;do curl -sf http://6.6.6.1:5555/hostname --connect-timeout 1 -o /dev/null || printf "%s " $(date +%s) ;done
while true;do curl -sf http://127.0.0.1:7473/livez --connect-timeout 1 -o /dev/null || printf "%3s " $(date +%s) ;done
//
//
watch -d -c -n 1 docker exec -it clab-vlab-gw1 vtysh -c \"show ip bgp vrf all\"
#export KUBECONFIG=/home/kka/.kube/lab0.yaml
#tmux setenv KUBECONFIG /home/kka/.kube/lab0.yaml
tmux new-window -n Nodes
tmux send-keys -t Nodes.0 "docker exec -it clab-vlab-h00 /bin/bash" C-m C-m C-m
tmux split-window -h -t Nodes
tmux send-keys -t Nodes.1 "sudo tcpdump -i sw0 -nnn host 10.10.0.10 -e"
tmux split-window -h -t Nodes
tmux send-keys -t Nodes.2 "docker exec -it clab-vlab-r01 /bin/bash" C-m C-m C-m
tmux split-window -h -t Nodes
tmux send-keys -t Nodes.3 "docker exec -it clab-vlab-r11 /bin/bash" C-m C-m C-m
tmux split-window -h -t Nodes
tmux send-keys -t Nodes.4 "sudo tcpdump -i sw1 -nnn host 10.10.0.10 -e"
tmux split-window -h -t Nodes
tmux send-keys -t Nodes.5 "kubectl -n metallb-system exec -it -c frr (kubectl -n metallb-system get pods -l component=speaker -o name |tail -1) -- /bin/bash" C-m
sudo tcpdump -i sw1 -nnn port 5555 -eodocker exec -it clab-vlab-r11 /bin/bash
tmux send-keys -t Nodes.0 "podman-remote -c lab0 exec -it red-in /bin/bash" C-m
tmux send-keys -t Nodes.0 "ip route add 203.100.100.0/24 via 12.12.12.119" C-m
tmux send-keys -t Nodes.0 "ping -c 1 203.100.100.100"
tmux send-keys -t Nodes.0 "nc -u 5.5.5.5 8888 -p 2424"
tmux send-keys -t Nodes.1 "oc debug node/w0 --image quay.io/karampok/snife:latest" C-m
tmux send-keys -t Nodes.1 "chroot /host" C-m C-m C-m
tmux send-keys -t Nodes.1 "watch -d iptables -nvL FORWARD" C-m C-m C-m
tmux send-keys -t Nodes.2 "oc debug node/w0 --image quay.io/karampok/snife:latest" C-m
tmux send-keys -t Nodes.2 "mount -t debugfs none /sys/kernel/debug" C-m
tmux send-keys -t Nodes.2 "tcpdump -i any -nnn icmp" C-m
`

func RunBGPGracefulRestart() *Run {
r := NewRun("Run BPG graceful restart demo")
// Infra is ready
peers := `kubectl apply -f graceful/blue-peering.yaml
kubectl apply -f graceful/green-peering.yaml
kubectl apply -f graceful/red-peering.yaml`
r.Step(S("Setup peering"), S(peers))

c := `docker exec clab-vlab-gw1 vtysh -c "show bgp vrf all summary"`
r.Step(S("Verify peering"), S(c))

d := `kubectl apply -f graceful/blue-pod-one.yaml
kubectl apply -f graceful/green-pod-one.yaml
kubectl apply -f graceful/red-pod-one.yaml`
r.Step(S("Deploy workloads"), S(d))

c = `kubectl get pods -o wide; kubectl get svc`
r.Step(S("Verify workload"), S(c))
r.Step(nil, S(runBGP))
r.Step(nil, S(c))
return r
}

0 comments on commit 1c6c6eb

Please sign in to comment.