Last active
January 8, 2021 23:33
-
-
Save janeczku/e20e6298462918b0570dda8c66c47f62 to your computer and use it in GitHub Desktop.
Replay/test the initial registration handshake between Cattle node agent and Rancher server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Execute this script in a cattle-node-agent container | |
# Successful websocket handshake is indicated by following line being printed: | |
# HTTP/1.1 101 Switching Protocols | |
TOKEN=$(cat /cattle-credentials/token) | |
URL="$(cat /cattle-credentials/url)/v3/connect/register" | |
echo "Using TOKEN: $TOKEN" | |
echo "Using URL: $URL" | |
read -r -d '' PARAMS_JSON << EOF | |
{ | |
"Node": { | |
"customConfig": { | |
"address": "8.8.8.8", | |
"roles": [ | |
], | |
"labels": [ | |
] | |
}, | |
"etcd": false, | |
"controlPlane": false, | |
"worker": false, | |
"requestedHostname": "hostname1" | |
} | |
} | |
EOF | |
echo "Using PARAMS:" | |
echo "$PARAMS_JSON" | |
PARAMS_BASE64=$(echo "$PARAMS_JSON" | base64 -w0) | |
#docker run --net=host appropriate/curl -i -N \ | |
curl -v -i -N --http1.1 \ | |
-H "Connection: Upgrade" \ | |
-H "Upgrade: websocket" \ | |
-H "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \ | |
-H "Sec-WebSocket-Version: 13" \ | |
-H "X-API-Tunnel-Token: $TOKEN" \ | |
-H "X-API-Tunnel-Params: $PARAMS_BASE64" \ | |
-k $URL | |
Fixed formatting error.
I'm trying to debug an issue in Rancher (rancher/rancher#17617), and found this gist. Would you happen to know the curl equivalent of an agent already registered connecting to rancher?
time="2019-08-08T14:36:05Z" level=info msg="Connecting to wss://rancher.domain/v3/connect with token atoken"
time="2019-08-08T14:36:05Z" level=info msg="Connecting to proxy" url="wss://rancher.domain/v3/connect"
time="2019-08-08T14:36:14Z" level=info msg="Starting plan monitor"
time="2019-08-08T14:36:19Z" level=debug msg="Wrote ping"
time="2019-08-08T14:36:24Z" level=debug msg="Wrote ping"
time="2019-08-08T14:36:24Z" level=error msg="Failed to connect to proxy" error="read tcp machine_ip:59454->rancher_ip:443: i/o timeout"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess there is an issue with
read
parameter-d
: