Skip to content

Commit d88bc23

Browse files
author
mdrahman-suse
committed
Add node-external-ip to config
1 parent d574a45 commit d88bc23

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

join-rke2-win-agent.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
Server IP of Primary server where rke2 is already installed and the worker will join.`
88
.Parameter Token
99
Token of Primary server.`
10+
.Parameter PublicIP
11+
Public IP of Agent server.`
1012
.Parameter Version
1113
Version of rke2 to download from github.`
1214
.Parameter Commit
@@ -26,10 +28,10 @@ param (
2628
$ServerIP,
2729
[Parameter()]
2830
[String]
29-
$Version,
31+
$Token,
3032
[Parameter()]
3133
[String]
32-
$Token,
34+
$Version,
3335
[Parameter()]
3436
[String]
3537
$Commit
@@ -60,13 +62,16 @@ function Set-Version() {
6062

6163
function Enable-Features() {
6264
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
65+
Restart-Computer -Wait -For PowerShell -Timeout 300 -Delay 2
6366
}
6467

6568
function Setup-Config(){
6669
Write-InfoLog "Creating rke2 directory..."
6770
New-Item -Type Directory c:/etc/rancher/rke2 -Force
71+
Write-InfoLog "Fetch public IP..."
72+
$publicIP = (Invoke-WebRequest -uri "https://api.ipify.org/").Content.Trim()
6873
Write-InfoLog "Setting up rke2 config.yaml file..."
69-
Set-Content -Path c:/etc/rancher/rke2/config.yaml -Value "server: https://$($ServerIP):9345`ntoken: $Token`n"
74+
Set-Content -Path c:/etc/rancher/rke2/config.yaml -Value "server: https://$($ServerIP):9345`ntoken: $Token`nnode-external-ip: $publicIP`n"
7075
Get-Content -Path c:/etc/rancher/rke2/config.yaml
7176
}
7277

0 commit comments

Comments
 (0)