forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cnetwork.go
42 lines (39 loc) · 898 Bytes
/
cnetwork.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package openshift
import (
"fmt"
)
const podNetworkTestCmd = `#!/bin/bash
set -e
echo 'Testing connectivity to master API'
failed=0
for i in {1..40}; do
if curl -s -S -k -m 1 https://${MASTER_IP}:8443; then
failed=0
break
else
failed=1
fi
done
if [[ failed -eq 1 ]]; then
exit 1
fi
echo 'Testing connectivity to master DNS server'
for i in {1..40}; do
if curl -s -S -k -m 1 https://kubernetes.default.svc.cluster.local; then
exit 0
fi
done
exit 1
`
// TestContainerNetworking launches a container that will check whether the container
// can communicate with the master API and DNS endpoints.
func (h *Helper) TestContainerNetworking(ip string) error {
_, err := h.runHelper.New().Image(h.image).
DiscardContainer().
Env(fmt.Sprintf("MASTER_IP=%s", ip)).
DNS("172.30.0.1").
Entrypoint("/bin/bash").
Command("-c", podNetworkTestCmd).
Run()
return err
}