Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abdotaskies committed Aug 27, 2024
1 parent b2a93a9 commit 961b493
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
Empty file added ingress.ps1
Empty file.
42 changes: 32 additions & 10 deletions k3s-worker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ if ($uninstall -eq $true) {
}

# join the k3s cluster using agent token and master node ip
# Start-Process -NoNewWindow -FilePath "sudo" -ArgumentList "systemctl daemon-reload" -Wait
# Write-Log "Systemd daemon reloaded successfully"
# $command = "curl -sfL https://get.k3s.io | K3S_URL=https://$($server_ip):6443 K3S_TOKEN=$token sh -"
$command = "curl -sfL https://get.k3s.io | K3S_URL=https://$($server_ip):6443 K3S_TOKEN=$token sh -"
Write-Log "Joining the k3s cluster with command: $command"
bash -c $command
Start-Process -NoNewWindow -FilePath "sudo" -ArgumentList -FilePat -Wait
if (-not $?) {
Write-Err "Failed to join the k3s cluster: $_"
Write-Err "Failed to join the cluster: $_"
exit 1
}
Write-Log "Joined the cluster successfully."

# verify the cluster
Write-Log "Verifying the cluster..."
kubectl get nodes
Expand All @@ -58,15 +62,33 @@ if (-not $?) {
}

# open firewall ports
$command = "iex '& ([scriptblock]::Create((iwr $firewall_script)))'"
Write-Log "Opening firewall ports with command: $command"
iex $command
# $command = "iex '& ([scriptblock]::Create((iwr $firewall_script)))'"
# Write-Log "Opening firewall ports with command: $command"
# iex $command

# # attach disk
# if ($attach_disk -eq $true) {
# $command = "iex '& ([scriptblock]::Create((iwr $attach_disk_script))) -size $size'"
# Write-Log "Attaching disk with command: $command"
# iex $command
# }

$command = "'& ([scriptblock]::Create((iwr $firewall_script)))'"
Start-Process -NoNewWindow -FilePath "sudo" -ArgumentList "pwsh -Command $command" -Wait
if (-not $?) {
Write-Err "Failed to open firewall ports: $_"
}else[
Write-Log "Firewall ports opened successfully."
]

# attach disk
if ($attach_disk -eq $true) {
$command = "iex '& ([scriptblock]::Create((iwr $attach_disk_script))) -size $size'"
Write-Log "Attaching disk with command: $command"
iex $command
$command = "'& ([scriptblock]::Create((iwr $attach_disk_script))) -size $size'"
Start-Process -NoNewWindow -FilePath "sudo" -ArgumentList "pwsh -Command $command" -Wait
if (-not $?) {
Write-Err "Failed to attach disk: $_"
}else{
Write-Log "Disk attached successfully."
}
}

Write-Log "k3s worker script completed."

0 comments on commit 961b493

Please sign in to comment.