Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Registering cleanup Antrea interface #4393

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2057,9 +2057,64 @@ spec:
start-service kubelet
start-service kube-proxy
start-service antrea-agent
- op: add
knabben marked this conversation as resolved.
Show resolved Hide resolved
path: /spec/template/spec/files/-
value:
path: 'C:\k\antrea_cleanup.ps1'
content: |
stop-service antrea-agent -ErrorAction SilentlyContinue
C:\k\antrea\Clean-AntreaNetwork.ps1
- op: add
path: /spec/template/spec/files/-
value:
path: 'C:\k\register_antrea_cleanup.ps1'
content: |
$methodScript = "C:\k\antrea\Clean-AntreaNetwork.ps1"
if (Test-Path "$methodScript") {
$cleanScriptPath = "C:\k\antrea_cleanup.ps1"
$method = "Shutdown"
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy"
$RegScriptsPath = "$RegPath\Scripts\$method\0"
$RegSmScriptsPath = "$RegPath\State\Machine\Scripts\$method\0"
# Create the path if not exist
$gpoPath = "$ENV:systemRoot\System32\GroupPolicy\Machine"
$methodPath = "$gpoPath\Scripts\$method"
if (-not (Test-Path $methodPath)) {
New-Item -path $methodPath -itemType Directory
}
# Create sub-path
$items = @("$RegScriptsPath\0", "$RegSmScriptsPath\0")
foreach ($item in $items) {
if (-not (Test-Path $item)) {
New-Item -path $item -force
}
}
# Register callback script to GPO
$items = @("$RegScriptsPath", "$RegSmScriptsPath")
foreach ($item in $items) {
New-ItemProperty -path "$item" -name DisplayName -propertyType String -value "Local Group Policy" -force
New-ItemProperty -path "$item" -name FileSysPath -propertyType String -value "$gpoPath" -force
New-ItemProperty -path "$item" -name GPO-ID -propertyType String -value "LocalGPO" -force
New-ItemProperty -path "$item" -name GPOName -propertyType String -value "Local Group Policy" -force
New-ItemProperty -path "$item" -name PSScriptOrder -propertyType DWord -value 2 -force
New-ItemProperty -path "$item" -name SOM-ID -propertyType String -value "Local" -force
}
$BinaryString = "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00"
$ExecTime = $BinaryString.Split(',') | ForEach-Object {"0x$_"}
$items = @("$RegScriptsPath\0", "$RegSmScriptsPath\0")
foreach ($item in $items) {
New-ItemProperty -path "$item" -name Script -propertyType String -value $cleanScriptPath -force
New-ItemProperty -path "$item" -name Parameters -propertyType String -value $method -force
New-ItemProperty -path "$item" -name IsPowershell -propertyType DWord -value 1 -force
New-ItemProperty -path "$item" -name ExecTime -propertyType Binary -value ([byte[]]$ExecTime) -force
}
}
- op: add
path: /spec/template/spec/postKubeadmCommands/-
value: powershell C:/Temp/antrea.ps1 -ExecutionPolicy Bypass
- op: add
path: /spec/template/spec/postKubeadmCommands/-
value: powershell C:/k/register_antrea_cleanup.ps1 -ExecutionPolicy Bypass
- name: ntpServers
enabledIf: '{{ not (empty .ntpServers) }}'
definitions:
Expand Down
55 changes: 55 additions & 0 deletions providers/infrastructure-vsphere/v1.5.1/cconly/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2057,9 +2057,64 @@ spec:
start-service kubelet
start-service kube-proxy
start-service antrea-agent
- op: add
path: /spec/template/spec/files/-
value:
path: 'C:\k\antrea_cleanup.ps1'
content: |
stop-service antrea-agent -ErrorAction SilentlyContinue
C:\k\antrea\Clean-AntreaNetwork.ps1
- op: add
path: /spec/template/spec/files/-
value:
path: 'C:\k\register_antrea_cleanup.ps1'
content: |
$methodScript = "C:\k\antrea\Clean-AntreaNetwork.ps1"
if (Test-Path "$methodScript") {
$cleanScriptPath = "C:\k\antrea_cleanup.ps1"
$method = "Shutdown"
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy"
$RegScriptsPath = "$RegPath\Scripts\$method\0"
$RegSmScriptsPath = "$RegPath\State\Machine\Scripts\$method\0"
# Create the path if not exist
$gpoPath = "$ENV:systemRoot\System32\GroupPolicy\Machine"
$methodPath = "$gpoPath\Scripts\$method"
if (-not (Test-Path $methodPath)) {
New-Item -path $methodPath -itemType Directory
}
# Create sub-path
$items = @("$RegScriptsPath\0", "$RegSmScriptsPath\0")
foreach ($item in $items) {
if (-not (Test-Path $item)) {
New-Item -path $item -force
}
}
# Register callback script to GPO
$items = @("$RegScriptsPath", "$RegSmScriptsPath")
foreach ($item in $items) {
New-ItemProperty -path "$item" -name DisplayName -propertyType String -value "Local Group Policy" -force
New-ItemProperty -path "$item" -name FileSysPath -propertyType String -value "$gpoPath" -force
New-ItemProperty -path "$item" -name GPO-ID -propertyType String -value "LocalGPO" -force
New-ItemProperty -path "$item" -name GPOName -propertyType String -value "Local Group Policy" -force
New-ItemProperty -path "$item" -name PSScriptOrder -propertyType DWord -value 2 -force
New-ItemProperty -path "$item" -name SOM-ID -propertyType String -value "Local" -force
}
$BinaryString = "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00"
$ExecTime = $BinaryString.Split(',') | ForEach-Object {"0x$_"}
$items = @("$RegScriptsPath\0", "$RegSmScriptsPath\0")
foreach ($item in $items) {
New-ItemProperty -path "$item" -name Script -propertyType String -value $cleanScriptPath -force
New-ItemProperty -path "$item" -name Parameters -propertyType String -value $method -force
New-ItemProperty -path "$item" -name IsPowershell -propertyType DWord -value 1 -force
New-ItemProperty -path "$item" -name ExecTime -propertyType Binary -value ([byte[]]$ExecTime) -force
}
}
- op: add
path: /spec/template/spec/postKubeadmCommands/-
value: powershell C:/Temp/antrea.ps1 -ExecutionPolicy Bypass
- op: add
path: /spec/template/spec/postKubeadmCommands/-
value: powershell C:/k/register_antrea_cleanup.ps1 -ExecutionPolicy Bypass
- name: ntpServers
enabledIf: '{{ not (empty .ntpServers) }}'
definitions:
Expand Down