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
name: Multi node cluster with managed runners, Ubuntu, Kubespray | |
on: | |
push: | |
# branches: [ main ] | |
workflow_dispatch: | |
env: | |
num_nodes: 4 | |
jobs: | |
define-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
nodes: ${{ steps.nodes.outputs.nodes }} | |
steps: | |
- id: nodes | |
run: | | |
nodes=$(python -c "print(list(range($num_nodes)))") | |
echo nodes="$nodes" >>$GITHUB_OUTPUT | |
control-node: | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
hostname -i >control-node-ip.txt | |
ssh-keygen -q -b 2048 -t rsa -N '' -C 'cluster key' -f ~/.ssh/id_rsa | |
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys | |
cp ~/.ssh/id_rsa.pub . | |
sudo iptables -P INPUT ACCEPT | |
sudo iptables -P OUTPUT ACCEPT | |
sudo iptables -P FORWARD ACCEPT | |
sudo iptables -F | |
- name: Upload control node data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: control-node | |
path: | | |
control-node-ip.txt | |
id_rsa.pub | |
- run: | | |
set -vx | |
#ssh -o StrictHostKeyChecking=no $(hostname -i) echo hello | |
ip addr | |
sudo iptables -L -v -n | |
ps -ef | |
sleep 200 | |
nodes: | |
needs: [define-matrix] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
id: ${{ fromJSON(needs.define-matrix.outputs.nodes) }} | |
steps: | |
- run: | | |
sleep 60 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: control-node | |
- run: | | |
set -vx | |
echo ${{ matrix.id }} | |
ip=$(cat control-node-ip.txt) | |
mkdir .ssh | |
chmod 700 .ssh | |
chmod 600 id_rsa.pub | |
mv id_rsa.pub .ssh/ | |
ip addr | |
ssh -o StrictHostKeyChecking=no $ip echo hello | |