-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient-daemonset.yaml
More file actions
49 lines (49 loc) · 1.42 KB
/
client-daemonset.yaml
File metadata and controls
49 lines (49 loc) · 1.42 KB
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
43
44
45
46
47
48
49
# TCP client that connects to the demo server every 5 seconds.
# Runs on nodes labeled role=client (multiple nodes in the demo cluster).
#
# Reads the server address from the server-config ConfigMap, which is
# created by setup.sh with the server node's internal IP.
#
# Usage:
# kubectl apply -f client-daemonset.yaml
# kubectl logs -l app=demo-client --all-containers --prefix -f
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: demo-client
labels:
app: demo-client
spec:
selector:
matchLabels:
app: demo-client
template:
metadata:
labels:
app: demo-client
spec:
runtimeClassName: reaper-v2
nodeSelector:
role: client
containers:
- name: client
image: busybox
env:
- name: SERVER_IP
valueFrom:
configMapKeyRef:
name: server-config
key: SERVER_IP
command: ["/bin/sh", "-c"]
args:
- |
echo "Client starting on $(hostname), server at $SERVER_IP:9090"
while true; do
response=$(echo "" | socat -T2 - TCP:$SERVER_IP:9090 2>&1)
if [ $? -eq 0 ]; then
echo "[$(hostname)] $(date -u +%H:%M:%S) <- $response"
else
echo "[$(hostname)] $(date -u +%H:%M:%S) ERROR: $response"
fi
sleep 5
done