Skip to content

Conversation

@matmerr
Copy link
Member

@matmerr matmerr commented May 10, 2022

Reason for Change:

In the event that HNS gets into a bad state, due to some other service configuring HNS outside of CNI, this script can be used to provide manual mitigation

Issue Fixed:

Requirements:

Notes:

@@ -0,0 +1,76 @@
$Global:ClusterConfiguration = ConvertFrom-Json ((Get-Content "c:\k\kubeclusterconfig.json" -ErrorAction Stop) | out-string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works only for k8s cluster.. can we make this script work irrespective of orchestrator?

$global:NetworkMode = "L2Bridge"
$global:ContainerRuntime = $Global:ClusterConfiguration.Cri.Name
$global:NetworkPlugin = $Global:ClusterConfiguration.Cni.Name
$global:HNSModule = "c:\k\hns.psm1"
Copy link
Member

@tamilmani1989 tamilmani1989 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can get this from their github repo directly instead of relying on local disk

Copy link
Member

@tamilmani1989 tamilmani1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor suggestion

@@ -0,0 +1,73 @@
# ./cleanupnetwork.ps1 -CniName azure
param (
[Parameter(Mandatory=$true)][string]$CniName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shud be networkname

Comment on lines 15 to 17
if ($global:NetworkPlugin -eq "azure") {
$networkname = "azure"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this code?

}
}

if ($global:NetworkPlugin -eq "azure") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this check


Invoke-WebRequest -Uri https://raw.githubusercontent.com/microsoft/SDN/master/Kubernetes/windows/hns.psm1 -OutFile "c:\hns.psm1" -UseBasicParsing

$global:NetworkMode = "L2Bridge"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is networkmode used anywhere. if not remove it

@@ -0,0 +1,43 @@
# ./cleanupnetwork.ps1 -CniDirectory c:\k -NetworkName azure
param (
[string]$CniDirectory = "c:\k",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets have c:\windows\system32 as default

# ./cleanupnetwork.ps1 -CniDirectory c:\k -NetworkName azure
param (
[string]$CniDirectory = "c:\k",
[Parameter(Mandatory=$true)][string]$NetworkName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove networkname parameter if not used

Copy link
Member

@tamilmani1989 tamilmani1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@matmerr matmerr enabled auto-merge (squash) May 19, 2022 18:51
@tamilmani1989 tamilmani1989 disabled auto-merge May 19, 2022 18:58
@tamilmani1989 tamilmani1989 merged commit 1d5f682 into Azure:master May 19, 2022
matmerr added a commit to matmerr/azure-container-networking that referenced this pull request Jun 29, 2022
* add cleanup network script

* generalize

* generic cwd

* loop through with prefix

* simplify checks

* remove network option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants