A comprehensive Kubernetes network connectivity and Cilium network policy testing solution with both CLI and web-based interfaces.
One-command deployment with full web UI and automated testing:
# Deploy entire application to Kubernetes with web interface
./k8s/deploy.shFeatures:
- ✅ Web UI: Modern React interface with real-time test monitoring
- ✅ Multi-container pod: UI (Next.js) + CLI (Go) with shared storage
- ✅ One-command setup: Automated Docker build, push, and Kubernetes deployment
- ✅ Smart access detection: Auto-detects NodePort vs port-forward
- ✅ Cross-environment: Docker Desktop, Kind, Minikube compatibility
- ✅ 90% faster performance: Optimized cleanup (10-15s vs 2+ minutes)
- ✅ Real-time progress: Live cleanup and test progress reporting
Deploy as web application with full UI interface:
# Complete deployment with auto-browser launch
./k8s/deploy.sh
# Deploy without auto-launch
./k8s/deploy.sh --no-launch
# Deploy with specific image tag
./k8s/deploy.sh --tag v2.0Access Methods:
- Auto-detected: Script automatically opens browser to correct URL
- Port-forward:
kubectl port-forward -n k8s-diagnostic service/k8s-diagnostic-ui 3000:3000 - NodePort: Direct access via cluster node IP (environment dependent)
Use as standalone command-line tool:
- Core Connectivity Tests: Pod-to-Pod, Service, DNS, Cross-Node, NodePort, LoadBalancer
- Policy Testing: L3 (CIDR, node), L4 (port-based), L7 (HTTP, DNS) policies
- Visual Output: Clear test results with progress indicators
- Concurrent Testing: Run multiple policy tests with resource isolation
- Reporting: JSON reports and structured logs for analysis
- Production Ready: Reliable connectivity validation with cleanup
k8s-diagnostic: Main connectivity testing tool./k8s/deploy.sh: One-command Kubernetes deployment./k8s/k8s-ui-access.sh: Smart UI access detectionbuild_test_k8s.sh: Creates test cluster with Cilium CNIdelete_test_k8s.sh: Removes test clusterscilium-policies/: Ready-to-use policy examples
The repository includes organized Cilium network policies by category:
| Category | Description | Examples |
|---|---|---|
| Basic | Baseline policies | allow-all, deny-all |
| Namespace | Namespace filtering | same-namespace, deny-namespace |
| Label | Pod label filtering | same-label, deny-label |
| L3 | Network layer (IP) | CIDR-based, node-based |
| L4 | Transport layer | Port-based, protocol-specific |
| L7 | Application layer | HTTP, DNS filtering |
# Test L3 policies
./k8s-diagnostic test --test-group l3-policies
# Test L4 policies
./k8s-diagnostic test --test-group l4-policies
# Test L7 policies
./k8s-diagnostic test --test-group l7-policies- Pod-to-Pod Connectivity: Tests basic pod networking across nodes
- Service-to-Pod: Verifies service discovery and load balancing
- Cross-Node Service: Validates kube-proxy inter-node routing
- DNS Resolution: Tests DNS functionality for service discovery
- NodePort Service: Validates external access through node ports
- LoadBalancer Service: Tests cloud load balancer integration
- Basic Policies: Allow-all and deny-all baseline tests
- L3 Policies: Tests for network layer (IP-based) filtering
- L4 Policies: Tests for transport layer (port-based) filtering
- L7 Policies: Tests for application layer (HTTP, DNS) filtering
- Docker (running)
- kind, kubectl, helm
- Go 1.21+ (for building from source)
# Clone repository
git clone https://github.com/parlakisik/k8s_diagnostic.git
cd k8s_diagnostic
# Build tool
make build
# Create test cluster (optional)
./build_test_k8s.sh# Basic connectivity tests
./k8s-diagnostic test
# Test L3 policies
./k8s-diagnostic test --test-group l3-policies
# Test L4 policies
./k8s-diagnostic test --test-group l4-policies
# Test L7 policies
./k8s-diagnostic test --test-group l7-policies# Basic usage
./k8s-diagnostic test
# Test flags
--namespace string Namespace for tests (default: "diagnostic-test")
--kubeconfig string Custom kubeconfig path
--verbose Detailed output with DEBUG logs
--test-group string Run tests by group: networking, l3-policies, l4-policies, l7-policies
--test-list string Run specific tests: pod-to-pod,service-to-pod (Limited support - see Test Execution Modes below)
--keep-namespace Preserve namespace after tests
--l3-subgroups Specify L3 policy subgroups to run
--l4-subgroups Specify L4 policy subgroups to run
--l7-subgroups Specify L7 policy subgroups to run# Test cluster creation
./build_test_k8s.sh -n custom-cluster-name
# Test cluster deletion
./delete_test_k8s.sh -fL3 policy tests validate Cilium's Layer 3 network policies using sequential execution:
The L3 tests are organized into 7 subgroups:
| Subgroup | Tests | Description |
|---|---|---|
| ip-cidr | 3 tests | CIDR-based ingress/egress filtering with exceptions |
| endpoint | 1 test | Endpoint label selector policies |
| entities | 1 test | Built-in entity selectors (world, host, cluster) |
| dns | 1 test | DNS-based filtering policies |
| node | 4 tests | Node selectors, pod node filtering, node CIDR targeting |
| service | 1 test | Kubernetes service targeting |
| security | 2 tests | Baseline security policies (allow-all, deny-all) |
# CLI tool
./k8s-diagnostic test --test-group l3-policies
./k8s-diagnostic test --test-group l3-policies --l3-subgroups ip-cidr,entitiesYou can run any combination of subgroups together:
ip-cidr+entities: Runs CIDR-based and entity-based testsentities+endpoint+service: Runs label-based, entity-based, and service-based testsnode+ip-cidr: Runs all node-based and CIDR-based tests- Any other combination based on your testing needs
This section provides a focused guide to all 13 individual L3 policy tests, explaining what each test validates and how to run them.
What it tests: Validates that pods can receive traffic from specific IP address ranges using fromCIDRSet
Why we test it: Ensures IP-based ingress filtering works correctly for network segmentation
How to run:
# Run only CIDR tests (includes this one)
./k8s-diagnostic test --test-group l3-policies --l3-subgroups ip-cidr
# Run all L3 tests (includes this one)
./k8s-diagnostic test --test-group l3-policiesWhat it tests: Validates that pods can send traffic to specific IP address ranges using toCIDR
Why we test it: Ensures IP-based egress filtering works for controlling outbound traffic
How to run: Same commands as cidr-ingress (part of ip-cidr subgroup)
What it tests: Validates complex CIDR rules with IP exclusions using fromCIDRSet with except
Why we test it: Ensures granular IP filtering works (allow range but block specific IPs)
How to run: Same commands as cidr-ingress (part of ip-cidr subgroup)
What it tests: Validates pod-to-pod communication filtering based on source pod labels using fromEndpoints
Why we test it: Core functionality for label-based micro-segmentation in Kubernetes
How to run:
# Run only endpoint tests
./k8s-diagnostic test --test-group l3-policies --l3-subgroups endpoint
# Combine with other subgroups
./k8s-diagnostic test --test-group l3-policies --l3-subgroups endpoint,entitiesWhat it tests: Validates filtering using Cilium's built-in entities (host, cluster, world) with fromEntities
Why we test it: Ensures entity-based filtering works for common traffic patterns
How to run:
# Run only entities tests
./k8s-diagnostic test --test-group l3-policies --l3-subgroups entities
# Combine with endpoint (both are 1 test each)
./k8s-diagnostic test --test-group l3-policies --l3-subgroups entities,endpointWhat it tests: Validates egress filtering based on domain names using toFQDNs
Why we test it: Ensures DNS-based policies work for controlling external service access
How to run:
# Run only DNS tests
./k8s-diagnostic test --test-group l3-policies --l3-subgroups dns
# Combine with service tests
./k8s-diagnostic test --test-group l3-policies --l3-subgroups dns,serviceWhat it tests: Validates node-based filtering using fromNodes selector
Why we test it: Tests node-based policies (requires enable-node-selector-labels: true)
How to run:
# Run all node tests (4 tests total)
./k8s-diagnostic test --test-group l3-policies --l3-subgroups node
# Can combine with other subgroups as neededWhat it tests: Validates filtering based on pod's node location using io.kubernetes.pod.nodeName label
Why we test it: Tests node-based filtering that works with default Cilium configuration
How to run: Same as node-selector (part of node subgroup)
What it tests: Validates node-based filtering using CIDR ranges that correspond to node pod subnets
Why we test it: Tests alternative approach to node-based filtering using IP ranges
How to run: Same as node-selector (part of node subgroup)
What it tests: Validates cross-namespace node policies using CiliumClusterwideNetworkPolicy
Why we test it: Ensures node-based policies work across namespace boundaries
How to run: Same as node-selector (part of node subgroup)
What it tests: Validates service-to-service communication filtering using toServices
Why we test it: Ensures policies can target Kubernetes services by name and namespace
How to run:
# Run only service tests
./k8s-diagnostic test --test-group l3-policies --l3-subgroups service
# Combine with other single-test subgroups
./k8s-diagnostic test --test-group l3-policies --l3-subgroups service,dns,entitiesWhat it tests: Validates baseline allow-all policies that permit all ingress and egress traffic
Why we test it: Establishes baseline connectivity and ensures policy infrastructure works before restrictive tests
How to run:
# Run only security tests (includes allow-all and deny-all)
./k8s-diagnostic test --test-group l3-policies --l3-subgroups security
# Combine with other subgroups (security tests run last to prevent conflicts)
./k8s-diagnostic test --test-group l3-policies --l3-subgroups ip-cidr,securityWhat it tests: Validates restrictive deny-all policies that block all ingress and egress traffic
Why we test it: Ensures policy enforcement works and tests policy isolation capabilities
How to run: Same commands as allow-all (part of security subgroup)
Note: Security tests are automatically run last to prevent interference with other policy tests.
./k8s-diagnostic test --test-group l3-policies./k8s-diagnostic test --test-group l3-policies --verbose# Run CIDR and entity tests
./k8s-diagnostic test --test-group l3-policies --l3-subgroups ip-cidr,entities
# Run multiple single-test subgroups
./k8s-diagnostic test --test-group l3-policies --l3-subgroups endpoint,entities,dns
# Run node and CIDR tests together
./k8s-diagnostic test --test-group l3-policies --l3-subgroups ip-cidr,nodeThis guide provides everything you need to understand and run each of the 11 L3 policy tests individually or in any combination.
L4 policy tests validate Cilium's Layer 4 network policies using sequential execution:
The L4 tests are organized into 3 subgroups:
| Subgroup | Tests | Description |
|---|---|---|
| port | 4 tests | TCP port-based ingress/egress filtering with ranges and multiple ports |
| icmp | 3 tests | ICMP and ICMPv6 protocol-based filtering |
| tls-sni | 3 tests | TLS Server Name Indication (SNI) filtering |
# CLI tool
./k8s-diagnostic test --test-group l4-policies
./k8s-diagnostic test --test-group l4-policies --l4-subgroups port,icmp
You can run any combination of subgroups together:
port+icmp: Runs port-based and ICMP-based testsport+tls-sni: Runs port-based and TLS SNI testsicmp+tls-sni: Runs ICMP-based and TLS SNI tests- Any other combination based on your testing needs
This section provides a focused guide to all 10 individual L4 policy tests, explaining what each test validates and how to run them.
What it tests: Validates that pods can receive TCP traffic on specific ports using toPorts ingress rules
Why we test it: Ensures port-based ingress filtering works correctly for service access control
How to run:
# Run only port tests (includes this one)
./k8s-diagnostic test --test-group l4-policies --l4-subgroups port
# Run all L4 tests (includes this one)
./k8s-diagnostic test --test-group l4-policiesWhat it tests: Validates that pods can send TCP traffic on specific ports using toPorts egress rules
Why we test it: Ensures port-based egress filtering works for controlling outbound service connections
How to run: Same commands as tcp-port-ingress (part of port subgroup)
What it tests: Validates filtering using port ranges (e.g., 8080-8090) instead of individual ports
Why we test it: Ensures port range specifications work for services using multiple consecutive ports
How to run: Same commands as tcp-port-ingress (part of port subgroup)
What it tests: Validates policies that allow traffic on multiple specific ports (e.g., 80, 443, 8080)
Why we test it: Ensures multiple port specifications work for services using different ports
How to run: Same commands as tcp-port-ingress (part of port subgroup)
What it tests: Validates ICMP protocol filtering using specific ICMP types (e.g., echo request/reply)
Why we test it: Ensures ICMP-based network diagnostics can be controlled at the policy level
How to run:
# Run only ICMP tests
./k8s-diagnostic test --test-group l4-policies --l4-subgroups icmp
# Combine with other subgroups
./k8s-diagnostic test --test-group l4-policies --l4-subgroups icmp,portWhat it tests: Validates ICMPv6 protocol filtering for IPv6 networks using specific ICMPv6 types
Why we test it: Ensures IPv6 ICMP traffic can be controlled separately from IPv4 ICMP
How to run: Same commands as icmp-type (part of icmp subgroup)
What it tests: Validates policies that handle both ICMP and ICMPv6 traffic simultaneously
Why we test it: Ensures dual-stack (IPv4/IPv6) ICMP policies work correctly
How to run: Same commands as icmp-type (part of icmp subgroup)
What it tests: Validates TLS Server Name Indication (SNI) filtering for specific domain names
Why we test it: Ensures TLS traffic can be filtered based on the requested domain name
How to run:
# Run only TLS SNI tests
./k8s-diagnostic test --test-group l4-policies --l4-subgroups tls-sni
# Combine with port tests
./k8s-diagnostic test --test-group l4-policies --l4-subgroups tls-sni,portWhat it tests: Validates SNI policies that allow TLS connections to multiple domains
Why we test it: Ensures applications can connect to multiple external services with SNI filtering
How to run: Same commands as basic-sni (part of tls-sni subgroup)
What it tests: Validates policies combining both port restrictions and SNI domain filtering
Why we test it: Ensures complex L4 policies with both port and TLS domain restrictions work together
How to run: Same commands as basic-sni (part of tls-sni subgroup)
./k8s-diagnostic test --test-group l4-policies./k8s-diagnostic test --test-group l4-policies --verbose# Run port and ICMP tests
./k8s-diagnostic test --test-group l4-policies --l4-subgroups port,icmp
# Run TLS SNI tests only
./k8s-diagnostic test --test-group l4-policies --l4-subgroups tls-sni
# Run all three subgroups
./k8s-diagnostic test --test-group l4-policies --l4-subgroups port,icmp,tls-sniThis guide provides everything you need to understand and run each of the 10 L4 policy tests individually or in any combination.
L7 policy tests validate Cilium's Layer 7 application-layer network policies using sequential execution:
The L7 tests are organized into 2 subgroups:
| Subgroup | Tests | Description |
|---|---|---|
| http | 3 tests | HTTP protocol filtering with methods, paths, and headers |
| dns | 2 tests | DNS query filtering with name matching and pattern matching |
# CLI tool
./k8s-diagnostic test --test-group l7-policies
./k8s-diagnostic test --test-group l7-policies --l7-subgroups http,dnsYou can run any combination of subgroups together:
http+dns: Runs all HTTP-based and DNS-based testshttponly: Runs HTTP method, path, and header filtering testsdnsonly: Runs DNS name and pattern matching tests- Any other combination based on your testing needs
This section provides a focused guide to all 5 individual L7 policy tests, explaining what each test validates and how to run them.
What it tests: Validates HTTP method filtering allowing only GET requests using L7 HTTP policy rules
Why we test it: Ensures application-layer HTTP method restrictions work correctly for API endpoint protection
How to run:
# Run only HTTP tests (includes this one)
./k8s-diagnostic test --test-group l7-policies --l7-subgroups http
# Run all L7 tests (includes this one)
./k8s-diagnostic test --test-group l7-policiesWhat it tests: Validates HTTP header-based filtering using specific header requirements in L7 policies
Why we test it: Ensures application-layer header validation works for authentication and API versioning
How to run: Same commands as basic-http-get (part of http subgroup)
What it tests: Validates HTTP path and method combination filtering using L7 path-based rules
Why we test it: Ensures granular endpoint protection based on both URL paths and HTTP methods
How to run: Same commands as basic-http-get (part of http subgroup)
What it tests: Validates DNS query filtering for specific domain names using matchName rules
Why we test it: Ensures L7 DNS policies can control access to specific external services by domain name
How to run:
# Run only DNS tests (includes this one)
./k8s-diagnostic test --test-group l7-policies --l7-subgroups dns
# Combine with HTTP tests
./k8s-diagnostic test --test-group l7-policies --l7-subgroups dns,httpWhat it tests: Validates DNS query filtering using pattern matching with matchPattern for domain wildcards
Why we test it: Ensures L7 DNS policies can control access to domain patterns (e.g., *.example.com)
How to run: Same commands as dns-matchname (part of dns subgroup)
./k8s-diagnostic test --test-group l7-policies./k8s-diagnostic test --test-group l7-policies --verbose# Run HTTP and DNS tests
./k8s-diagnostic test --test-group l7-policies --l7-subgroups http,dns
# Run HTTP tests only
./k8s-diagnostic test --test-group l7-policies --l7-subgroups http
# Run DNS tests only
./k8s-diagnostic test --test-group l7-policies --l7-subgroups dnsThis guide provides everything you need to understand and run each of the 5 L7 policy tests individually or in any combination.
Test results include:
- Visual indicators (✅/❌) for each test result
- Timestamped logs with test progress
- Detailed JSON reports in the
test_results/folder - Verbose option (--verbose) for detailed debug information