full-mesh.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091
  3. . lib.sh
  4. setup_suite() {
  5. create_cluster
  6. # shellcheck disable=SC2016
  7. $KUBECTL_BINARY patch ds -n kube-system kilo -p '{"spec": {"template":{"spec":{"containers":[{"name":"kilo","args":["--hostname=$(NODE_NAME)","--create-interface=false","--kubeconfig=/etc/kubernetes/kubeconfig","--mesh-granularity=full"]}]}}}}'
  8. block_until_ready_by_name kube-system kilo-userspace
  9. $KUBECTL_BINARY wait pod -l app.kubernetes.io/name=adjacency --for=condition=Ready --timeout 3m
  10. }
  11. teardown_suite () {
  12. delete_cluster
  13. }
  14. test_full_mesh_connectivity() {
  15. assert "retry 30 5 '' check_ping" "should be able to ping all Pods"
  16. assert "retry 10 5 'the adjacency matrix is not complete yet' check_adjacent 12" "adjacency should return the right number of successful pings"
  17. echo "sleep for 30s (one reconciliation period) and try again..."
  18. sleep 30
  19. assert "retry 10 5 'the adjacency matrix is not complete yet' check_adjacent 12" "adjacency should return the right number of successful pings after reconciling"
  20. }
  21. test_full_mesh_peer() {
  22. check_peer wg1 e2e 10.5.0.1/32 full
  23. }
  24. test_full_mesh_allowed_location_ips() {
  25. docker exec kind-cluster-kilo-control-plane ip address add 10.6.0.1/32 dev eth0
  26. $KUBECTL_BINARY annotate node kind-cluster-kilo-control-plane kilo.squat.ai/allowed-location-ips=10.6.0.1/32
  27. assert_equals Unauthorized "$(retry 10 5 'IP is not yet routable' curl_pod -m 1 -s -k https://10.6.0.1:10250/healthz)" "should be able to make HTTP request to allowed location IP"
  28. $KUBECTL_BINARY annotate node kind-cluster-kilo-control-plane kilo.squat.ai/allowed-location-ips-
  29. assert "retry 10 5 'IP is still routable' _not curl_pod -m 1 -s -k https://10.6.0.1:10250/healthz" "should not be able to make HTTP request to allowed location IP"
  30. docker exec kind-cluster-kilo-control-plane ip address delete 10.6.0.1/32 dev eth0
  31. }
  32. test_reject_peer_empty_allowed_ips() {
  33. assert_fail "create_peer e2e '' 0 foo" "should not be able to create Peer with empty allowed IPs"
  34. }
  35. test_reject_peer_empty_public_key() {
  36. assert_fail "create_peer e2e 10.5.0.1/32 0 ''" "should not be able to create Peer with empty public key"
  37. }
  38. test_mesh_granularity_auto_detect() {
  39. assert_equals "$($KGCTL_BINARY graph)" "$($KGCTL_BINARY graph --mesh-granularity full)"
  40. }