Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abdotaskies committed Sep 1, 2024
1 parent ac1987f commit 998f181
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
25 changes: 24 additions & 1 deletion configure-k3s.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ function Write-Log {
}
}

function Invoke-Operations {
Param(
[string]$flagName,
[bool]$flagInput
)

if ($flagName -eq "CriticalAddonsOnly=true:NoExecute" -and $flagInput) {
Write-Log "Tainting control place with $flagName"
$nodes = kubectl get nodes --selector='node-role.kubernetes.io/control-plane' -o jsonpath='{.items[*].metadata.name}'
foreach ($node in $nodes) {
kubectl taint nodes $node CriticalAddonsOnly=true:NoExecute
}
} elseif ($flagName -eq "CriticalAddonsOnly=true:NoExecute" -and $flagInput -eq $false) {
write-Log "Removing taint $flagname from control plane"
$nodes = kubectl get nodes --selector='node-role.kubernetes.io/control-plane' -o jsonpath='{.items[*].metadata.name}'
foreach ($node in $nodes) {
kubectl taint nodes $node CriticalAddonsOnly-
}
}
}

$serviceFilePath = "/etc/systemd/system/k3s.service"

if (-not (Test-Path $serviceFilePath)) {
Expand Down Expand Up @@ -76,6 +97,8 @@ foreach ($flag in $flags.GetEnumerator()) {
$lines.Insert($serverFlagIndex + 1, "`t'$flagKey' \")
$lines.Insert($serverFlagIndex + 2, "`t'$flagValue' \")
}

Invoke-Operations -flagName $flagValue -flagInput $flagInput
}

# Remove empty lines from the content
Expand All @@ -88,4 +111,4 @@ Start-Process -NoNewWindow -FilePath "sudo" -ArgumentList "systemctl daemon-relo
Write-Log "Systemd daemon reloaded successfully"
# # Restart the k3s service
Start-Process -NoNewWindow -FilePath "sudo" -ArgumentList "systemctl restart k3s" -Wait
Write-Log "k3s service restarted successfully"
Write-Log "k3s service restarted successfully"
5 changes: 4 additions & 1 deletion nginx-vales.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ controller:
use-forwarded-headers: true
ingressClassResource:
default: true
watchIngressWithoutClass: true
watchIngressWithoutClass: true
tolerations:
- key: CriticalAddonsOnly
operator: Exists

0 comments on commit 998f181

Please sign in to comment.