Files
monok8s/clitools
2026-03-30 19:40:47 +08:00
..
2026-03-27 18:34:53 +08:00
2026-03-30 19:40:47 +08:00
2026-03-27 18:34:53 +08:00
2026-03-27 18:34:53 +08:00
2026-03-29 22:27:13 +08:00
2026-03-30 17:40:27 +08:00

## For development workflow

Run this on device
```bash
while true; do nc -l -p 1234 -e sh; done
```

Run this script on the dev machine
```bash
#!/bin/bash
make build

SIZE=$(wc -c < ./bin/ctl-linux-aarch64-dev)

(
  echo 'base64 -d > /var/ctl <<'"'"'EOF'"'"''
  pv -s "$SIZE" < ./bin/ctl-linux-aarch64-dev | base64
  echo 'EOF'
  echo 'chmod +x /var/ctl'
  echo '/var/ctl create config > /var/abc.yaml'
  echo "/var/ctl internal run-step $1 -c /var/abc.yaml 2>&1"
) | nc 10.0.0.10 1234
```

And use it like this
```bash
./send.sh start_crio
```


Create join token from control plane
```
kubeadm token create --print-join-command
```

Export the token inside the device
```
export DEBUG=1
export HOSTNAME=monok8s-master-1
export BOOTSTRAP_TOKEN=
export TOKEN_CACERT_HASH=
```

Generate using kubectl
```
TOKEN_NAME=bootstrap-token-iwotl0

API_SERVER=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}' | sed 's|https://||') && \
TOKEN=$(kubectl -n kube-system get secret ${TOKEN_NAME} -o jsonpath='{.data.token-id}' | base64 -d).$(kubectl -n kube-system get secret ${TOKEN_NAME} -o jsonpath='{.data.token-secret}' | base64 -d) && \
HASH=$(kubectl -n kube-public get configmap cluster-info -o jsonpath='{.data.kubeconfig}' \
| grep 'certificate-authority-data' \
| awk '{print $2}' \
| base64 -d \
| openssl x509 -pubkey -noout \
| openssl rsa -pubin -outform der 2>/dev/null \
| openssl dgst -sha256 -hex \
| awk '{print "sha256:" $2}')
echo "export API_SERVER_ENDPOINT=${API_SERVER}"
echo "export BOOTSTRAP_TOKEN=${TOKEN}"
echo "export TOKEN_CACERT_HASH=${HASH}"
```