Visitar URL original
GitHub - mfordjody/k8s-local-network: Kubernetes cluster network testing based on Linux network namespaces · GitHub
Skip to content

About

Kubernetes cluster network testing based on Linux network namespaces

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8s-local-network

Create local Kubernetes-style networks, nodes, and pods with Linux bridges, network namespaces, veth pairs, and routes.

Requirements

  • Linux with iproute2 and ping installed.

Create resource

cargo run -- create --network kln-lab1
cargo run -- create node node-1 --network kln-lab1
cargo run -- create node node-2 --network kln-lab1
cargo run -- create pod app-1 --node node-1 --network kln-lab1
cargo run -- create pod app-2 --node node-2 --network kln-lab1

Network names start with kln- and cannot exceed Linux's 15-byte interface limit. With multiple networks, specify --network. With multiple nodes, specify --node; a node ID from status is also accepted.

Creating a network or node does not create pods. Pod creation installs the routes needed to reach pods on other nodes.

Inspect and run

cargo run -- status
cargo run -- ping app-1 app-2 --network kln-lab1
cargo run -- exec app-1 --network kln-lab1 -- ip addr

status shows network names, node and pod IDs, ownership, and addresses. Arguments after exec's -- are passed unchanged to the command inside the pod.

The current context is stored in .k8s-local-network-context; resource names, ownership, and address slots are stored in .k8s-local-network-state in the current working directory. Live namespace addresses and peers are used to recover missing state.

Delete resource

cargo run -- delete pod app-1 --network kln-lab1
cargo run -- delete node node-2 --network kln-lab1
cargo run -- delete --network kln-lab1

Node deletion also removes its pods and their remote routes. Pod deletion removes its remote routes. Freed address slots can be reused without changing surviving resources. A network cannot be deleted while it still has namespaces.

Use the IDs shown by status to delete resources without a network flag:

cargo run -- delete pod <pod-id>
cargo run -- delete node <node-id>

Default topology and plans

cargo run -- plan
cargo run -- up
cargo run -- ping
cargo run -- down

With no saved resources, plan previews a default node and three pods: proxy, server, and client. up creates and saves the topology; down removes it. Saved empty networks remain empty in resource plans.

cargo run -- check
cargo run -- smoke
cargo run -- smoke --i-understand

smoke previews the default setup, ping, and cleanup commands. --i-understand executes them. Previewing plans works on macOS; namespace execution requires Linux.

About

Kubernetes cluster network testing based on Linux network namespaces

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages