feat: add hosts config agent support for Windows nodes (#3572)

This commit is contained in:
Pengfei Ni 2020-07-08 01:55:30 +08:00 коммит произвёл GitHub
Родитель c2d3abd481
Коммит b9a067a636
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 269 добавлений и 20 удалений

Просмотреть файл

@ -143,6 +143,9 @@ $global:TelemetryKey = "{{WrapAsVariable "applicationInsightsKey" }}";
$global:EnableCsiProxy = [System.Convert]::ToBoolean("{{WrapAsVariable "windowsEnableCSIProxy" }}");
$global:CsiProxyUrl = "{{WrapAsVariable "windowsCSIProxyURL" }}";
# Hosts Config Agent settings
$global:EnableHostsConfigAgent = [System.Convert]::ToBoolean("{{WrapAsVariable "enableHostsConfigAgent" }}");
$global:ProvisioningScriptsPackageUrl = "{{WrapAsVariable "windowsProvisioningScriptsPackageURL" }}";
# Base64 representation of ZIP archive
@ -161,6 +164,7 @@ Expand-Archive scripts.zip -DestinationPath "C:\\AzureData\\"
. c:\AzureData\k8s\windowscsiproxyfunc.ps1
. c:\AzureData\k8s\windowsinstallopensshfunc.ps1
. c:\AzureData\k8s\windowscontainerdfunc.ps1
. c:\AzureData\k8s\windowshostsconfigagentfunc.ps1
$useContainerD = ($global:ContainerRuntime -eq "containerd")
$global:KubeClusterConfigPath = "c:\k\kubeclusterconfig.json"
@ -326,6 +330,11 @@ try
-AgentKey $AgentKey `
-AgentCertificate $global:AgentCertificate
if ($global:EnableHostsConfigAgent) {
Write-Log "Starting hosts config agent"
New-HostsConfigService
}
Write-Log "Create the Pause Container kubletwin/pause"
$infraContainerTimer = [System.Diagnostics.Stopwatch]::StartNew()
New-InfraContainer -KubeDir $global:KubeDir -ContainerRuntime $global:ContainerRuntime

Просмотреть файл

@ -0,0 +1,21 @@
function New-HostsConfigService {
$HostsConfigParameters = [io.path]::Combine($KubeDir, "hostsconfigagent.ps1")
& "$KubeDir\nssm.exe" install hosts-config-agent C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppDirectory "$KubeDir" | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppParameters $HostsConfigParameters | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRestartDelay 5000 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent Description hosts-config-agent | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent Start SERVICE_DEMAND_START | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent ObjectName LocalSystem | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent Type SERVICE_WIN32_OWN_PROCESS | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppThrottle 1500 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStdout "$KubeDir\hosts-config-agent.log" | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStderr "$KubeDir\hosts-config-agent.err.log" | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStdoutCreationDisposition 4 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStderrCreationDisposition 4 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateFiles 1 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateOnline 1 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateSeconds 86400 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateBytes 10485760 | RemoveNulls
}

Просмотреть файл

@ -322,6 +322,9 @@ New-NSSMService {
if ($global:EnableCsiProxy) {
$kubeletDependOnServices += " csi-proxy"
}
if ($global:EnableHostsConfigAgent) {
$kubeletDependOnServices += " hosts-config-agent"
}
# setup kubelet
& "$KubeDir\nssm.exe" install Kubelet C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | RemoveNulls

Просмотреть файл

@ -1906,6 +1906,14 @@ func (o *OrchestratorProfile) IsPrivateCluster() bool {
return o.KubernetesConfig != nil && o.KubernetesConfig.PrivateCluster != nil && to.Bool(o.KubernetesConfig.PrivateCluster.Enabled)
}
// IsHostsConfigAgentEnabled returns true if hosts config agent is enabled
func (o *OrchestratorProfile) IsHostsConfigAgentEnabled() bool {
if !o.IsKubernetes() {
return false
}
return o.KubernetesConfig != nil && o.KubernetesConfig.PrivateCluster != nil && to.Bool(o.KubernetesConfig.PrivateCluster.EnableHostsConfigAgent)
}
// GetPodInfraContainerSpec returns the sandbox image as a string (ex: k8s.gcr.io/pause-amd64:3.1)
func (o *OrchestratorProfile) GetPodInfraContainerSpec() string {
return o.KubernetesConfig.MCRKubernetesImageBase + GetK8sComponentsByVersionMap(o.KubernetesConfig)[o.OrchestratorVersion][common.PauseComponentName]

Просмотреть файл

@ -3401,6 +3401,73 @@ func TestIsAzureCNI(t *testing.T) {
}
}
func TestIsHostsConfigAgentEnabled(t *testing.T) {
cases := []struct {
p Properties
expected bool
}{
{
p: Properties{
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: DCOS,
},
},
expected: false,
},
{
p: Properties{
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
},
},
expected: false,
},
{
p: Properties{
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
KubernetesConfig: &KubernetesConfig{
PrivateCluster: &PrivateCluster{
EnableHostsConfigAgent: to.BoolPtr(true),
},
},
},
},
expected: true,
},
{
p: Properties{
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
KubernetesConfig: &KubernetesConfig{
PrivateCluster: &PrivateCluster{
EnableHostsConfigAgent: to.BoolPtr(false),
},
},
},
},
expected: false,
},
{
p: Properties{
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
KubernetesConfig: &KubernetesConfig{
PrivateCluster: &PrivateCluster{},
},
},
},
expected: false,
},
}
for _, c := range cases {
if c.p.OrchestratorProfile.IsHostsConfigAgentEnabled() != c.expected {
t.Fatalf("expected IsHostsConfigAgentEnabled() to return %t but instead got %t", c.expected, c.p.OrchestratorProfile.IsHostsConfigAgentEnabled())
}
}
}
func TestOrchestrator(t *testing.T) {
cases := []struct {
p Properties

Просмотреть файл

@ -385,6 +385,7 @@ func getK8sMasterVars(cs *api.ContainerService) (map[string]interface{}, error)
}
}
masterVars["primaryScaleSetName"] = cs.Properties.GetPrimaryScaleSetName()
masterVars["enableHostsConfigAgent"] = cs.Properties.OrchestratorProfile.IsHostsConfigAgentEnabled()
if isHostedMaster {
masterVars["kubernetesAPIServerIP"] = "[parameters('kubernetesEndpoint')]"

Просмотреть файл

@ -97,6 +97,7 @@ func TestK8sVars(t *testing.T) {
"applicationInsightsKey": "c92d8284-b550-4b06-b7ba-e80fd7178faa", // should be DefaultApplicationInsightsKey,
"clusterKeyVaultName": "",
"contributorRoleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"enableHostsConfigAgent": false,
"enableTelemetry": false,
"etcdCaFilepath": "/etc/kubernetes/certs/ca.crt",
"etcdClientCertFilepath": "/etc/kubernetes/certs/etcdclient.crt",
@ -700,6 +701,7 @@ func TestK8sVars(t *testing.T) {
"apiVersionStorage": "2017-10-01",
"clusterKeyVaultName": "",
"contributorRoleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"enableHostsConfigAgent": false,
"enableTelemetry": false,
"etcdCaFilepath": "/etc/kubernetes/certs/ca.crt",
"etcdClientCertFilepath": "/etc/kubernetes/certs/etcdclient.crt",
@ -950,6 +952,7 @@ func TestK8sVarsMastersOnly(t *testing.T) {
"contributorRoleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"customCloudAuthenticationMethod": "client_secret",
"customCloudIdentifySystem": "azure_ad",
"enableHostsConfigAgent": false,
"enableTelemetry": false,
"etcdCaFilepath": "/etc/kubernetes/certs/ca.crt",
"etcdClientCertFilepath": "/etc/kubernetes/certs/etcdclient.crt",

Просмотреть файл

@ -77,15 +77,16 @@ const (
const (
kubeConfigJSON = "k8s/kubeconfig.json"
// Windows custom scripts. These should all be listed in template_generator.go:func GetKubernetesWindowsAgentFunctions
kubernetesWindowsAgentCustomDataPS1 = "k8s/kuberneteswindowssetup.ps1"
kubernetesWindowsAgentFunctionsPS1 = "k8s/kuberneteswindowsfunctions.ps1"
kubernetesWindowsConfigFunctionsPS1 = "k8s/windowsconfigfunc.ps1"
kubernetesWindowsContainerdFunctionsPS1 = "k8s/windowscontainerdfunc.ps1"
kubernetesWindowsCsiProxyFunctionsPS1 = "k8s/windowscsiproxyfunc.ps1"
kubernetesWindowsKubeletFunctionsPS1 = "k8s/windowskubeletfunc.ps1"
kubernetesWindowsCniFunctionsPS1 = "k8s/windowscnifunc.ps1"
kubernetesWindowsAzureCniFunctionsPS1 = "k8s/windowsazurecnifunc.ps1"
kubernetesWindowsOpenSSHFunctionPS1 = "k8s/windowsinstallopensshfunc.ps1"
kubernetesWindowsAgentCustomDataPS1 = "k8s/kuberneteswindowssetup.ps1"
kubernetesWindowsAgentFunctionsPS1 = "k8s/kuberneteswindowsfunctions.ps1"
kubernetesWindowsConfigFunctionsPS1 = "k8s/windowsconfigfunc.ps1"
kubernetesWindowsContainerdFunctionsPS1 = "k8s/windowscontainerdfunc.ps1"
kubernetesWindowsCsiProxyFunctionsPS1 = "k8s/windowscsiproxyfunc.ps1"
kubernetesWindowsKubeletFunctionsPS1 = "k8s/windowskubeletfunc.ps1"
kubernetesWindowsCniFunctionsPS1 = "k8s/windowscnifunc.ps1"
kubernetesWindowsAzureCniFunctionsPS1 = "k8s/windowsazurecnifunc.ps1"
kubernetesWindowsHostsConfigAgentFunctionsPS1 = "k8s/windowshostsconfigagentfunc.ps1"
kubernetesWindowsOpenSSHFunctionPS1 = "k8s/windowsinstallopensshfunc.ps1"
)
// cloud-init (i.e. ARM customData) source file references

Просмотреть файл

@ -361,9 +361,7 @@ func getContainerServiceFuncMap(cs *api.ContainerService) template.FuncMap {
return cs.Properties.OrchestratorProfile.IsPrivateCluster()
},
"EnableHostsConfigAgent": func() bool {
return cs.Properties.OrchestratorProfile.KubernetesConfig != nil &&
cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateCluster != nil &&
to.Bool(cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.EnableHostsConfigAgent)
return cs.Properties.OrchestratorProfile.IsHostsConfigAgentEnabled()
},
"ProvisionJumpbox": func() bool {
return cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateJumpboxProvision()
@ -513,6 +511,7 @@ func getContainerServiceFuncMap(cs *api.ContainerService) template.FuncMap {
kubernetesWindowsKubeletFunctionsPS1,
kubernetesWindowsCniFunctionsPS1,
kubernetesWindowsAzureCniFunctionsPS1,
kubernetesWindowsHostsConfigAgentFunctionsPS1,
kubernetesWindowsOpenSSHFunctionPS1,
}

Просмотреть файл

@ -124,6 +124,7 @@
// ../../parts/k8s/windowsconfigfunc.ps1
// ../../parts/k8s/windowscontainerdfunc.ps1
// ../../parts/k8s/windowscsiproxyfunc.ps1
// ../../parts/k8s/windowshostsconfigagentfunc.ps1
// ../../parts/k8s/windowsinstallopensshfunc.ps1
// ../../parts/k8s/windowskubeletfunc.ps1
// ../../parts/masteroutputs.t
@ -23300,6 +23301,9 @@ $global:TelemetryKey = "{{WrapAsVariable "applicationInsightsKey" }}";
$global:EnableCsiProxy = [System.Convert]::ToBoolean("{{WrapAsVariable "windowsEnableCSIProxy" }}");
$global:CsiProxyUrl = "{{WrapAsVariable "windowsCSIProxyURL" }}";
# Hosts Config Agent settings
$global:EnableHostsConfigAgent = [System.Convert]::ToBoolean("{{WrapAsVariable "enableHostsConfigAgent" }}");
$global:ProvisioningScriptsPackageUrl = "{{WrapAsVariable "windowsProvisioningScriptsPackageURL" }}";
# Base64 representation of ZIP archive
@ -23318,6 +23322,7 @@ Expand-Archive scripts.zip -DestinationPath "C:\\AzureData\\"
. c:\AzureData\k8s\windowscsiproxyfunc.ps1
. c:\AzureData\k8s\windowsinstallopensshfunc.ps1
. c:\AzureData\k8s\windowscontainerdfunc.ps1
. c:\AzureData\k8s\windowshostsconfigagentfunc.ps1
$useContainerD = ($global:ContainerRuntime -eq "containerd")
$global:KubeClusterConfigPath = "c:\k\kubeclusterconfig.json"
@ -23483,6 +23488,11 @@ try
-AgentKey $AgentKey ` + "`" + `
-AgentCertificate $global:AgentCertificate
if ($global:EnableHostsConfigAgent) {
Write-Log "Starting hosts config agent"
New-HostsConfigService
}
Write-Log "Create the Pause Container kubletwin/pause"
$infraContainerTimer = [System.Diagnostics.Stopwatch]::StartNew()
New-InfraContainer -KubeDir $global:KubeDir -ContainerRuntime $global:ContainerRuntime
@ -24803,6 +24813,43 @@ func k8sWindowscsiproxyfuncPs1() (*asset, error) {
return a, nil
}
var _k8sWindowshostsconfigagentfuncPs1 = []byte(`function New-HostsConfigService {
$HostsConfigParameters = [io.path]::Combine($KubeDir, "hostsconfigagent.ps1")
& "$KubeDir\nssm.exe" install hosts-config-agent C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppDirectory "$KubeDir" | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppParameters $HostsConfigParameters | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRestartDelay 5000 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent Description hosts-config-agent | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent Start SERVICE_DEMAND_START | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent ObjectName LocalSystem | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent Type SERVICE_WIN32_OWN_PROCESS | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppThrottle 1500 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStdout "$KubeDir\hosts-config-agent.log" | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStderr "$KubeDir\hosts-config-agent.err.log" | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStdoutCreationDisposition 4 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppStderrCreationDisposition 4 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateFiles 1 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateOnline 1 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateSeconds 86400 | RemoveNulls
& "$KubeDir\nssm.exe" set hosts-config-agent AppRotateBytes 10485760 | RemoveNulls
}`)
func k8sWindowshostsconfigagentfuncPs1Bytes() ([]byte, error) {
return _k8sWindowshostsconfigagentfuncPs1, nil
}
func k8sWindowshostsconfigagentfuncPs1() (*asset, error) {
bytes, err := k8sWindowshostsconfigagentfuncPs1Bytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "k8s/windowshostsconfigagentfunc.ps1", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var _k8sWindowsinstallopensshfuncPs1 = []byte(`function
Install-OpenSSH {
Param(
@ -25203,6 +25250,9 @@ New-NSSMService {
if ($global:EnableCsiProxy) {
$kubeletDependOnServices += " csi-proxy"
}
if ($global:EnableHostsConfigAgent) {
$kubeletDependOnServices += " hosts-config-agent"
}
# setup kubelet
& "$KubeDir\nssm.exe" install Kubelet C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | RemoveNulls
@ -28819,6 +28869,7 @@ var _bindata = map[string]func() (*asset, error){
"k8s/windowsconfigfunc.ps1": k8sWindowsconfigfuncPs1,
"k8s/windowscontainerdfunc.ps1": k8sWindowscontainerdfuncPs1,
"k8s/windowscsiproxyfunc.ps1": k8sWindowscsiproxyfuncPs1,
"k8s/windowshostsconfigagentfunc.ps1": k8sWindowshostsconfigagentfuncPs1,
"k8s/windowsinstallopensshfunc.ps1": k8sWindowsinstallopensshfuncPs1,
"k8s/windowskubeletfunc.ps1": k8sWindowskubeletfuncPs1,
"masteroutputs.t": masteroutputsT,
@ -29013,14 +29064,15 @@ var _bintree = &bintree{nil, map[string]*bintree{
"kubernetesmaster-kube-controller-manager.yaml": {k8sManifestsKubernetesmasterKubeControllerManagerYaml, map[string]*bintree{}},
"kubernetesmaster-kube-scheduler.yaml": {k8sManifestsKubernetesmasterKubeSchedulerYaml, map[string]*bintree{}},
}},
"windowsazurecnifunc.ps1": {k8sWindowsazurecnifuncPs1, map[string]*bintree{}},
"windowsazurecnifunc.tests.ps1": {k8sWindowsazurecnifuncTestsPs1, map[string]*bintree{}},
"windowscnifunc.ps1": {k8sWindowscnifuncPs1, map[string]*bintree{}},
"windowsconfigfunc.ps1": {k8sWindowsconfigfuncPs1, map[string]*bintree{}},
"windowscontainerdfunc.ps1": {k8sWindowscontainerdfuncPs1, map[string]*bintree{}},
"windowscsiproxyfunc.ps1": {k8sWindowscsiproxyfuncPs1, map[string]*bintree{}},
"windowsinstallopensshfunc.ps1": {k8sWindowsinstallopensshfuncPs1, map[string]*bintree{}},
"windowskubeletfunc.ps1": {k8sWindowskubeletfuncPs1, map[string]*bintree{}},
"windowsazurecnifunc.ps1": {k8sWindowsazurecnifuncPs1, map[string]*bintree{}},
"windowsazurecnifunc.tests.ps1": {k8sWindowsazurecnifuncTestsPs1, map[string]*bintree{}},
"windowscnifunc.ps1": {k8sWindowscnifuncPs1, map[string]*bintree{}},
"windowsconfigfunc.ps1": {k8sWindowsconfigfuncPs1, map[string]*bintree{}},
"windowscontainerdfunc.ps1": {k8sWindowscontainerdfuncPs1, map[string]*bintree{}},
"windowscsiproxyfunc.ps1": {k8sWindowscsiproxyfuncPs1, map[string]*bintree{}},
"windowshostsconfigagentfunc.ps1": {k8sWindowshostsconfigagentfuncPs1, map[string]*bintree{}},
"windowsinstallopensshfunc.ps1": {k8sWindowsinstallopensshfuncPs1, map[string]*bintree{}},
"windowskubeletfunc.ps1": {k8sWindowskubeletfuncPs1, map[string]*bintree{}},
}},
"masteroutputs.t": {masteroutputsT, map[string]*bintree{}},
"masterparams.t": {masterparamsT, map[string]*bintree{}},

Просмотреть файл

@ -0,0 +1,80 @@
$Global:ClusterConfiguration = ConvertFrom-Json ((Get-Content "c:\k\kubeclusterconfig.json" -ErrorAction Stop) | out-string)
$clusterFQDN = $Global:ClusterConfiguration.Kubernetes.ControlPlane.IpAddress
$hostsFile="C:\Windows\System32\drivers\etc\hosts"
$retryDelaySeconds = 15
filter Timestamp { "$(Get-Date -Format o): $_" }
function Write-Log($message) {
$msg = $message | Timestamp
Write-Output $msg
}
function Retry-Command {
Param(
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]
$Command,
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][hashtable]
$Args,
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][int]
$Retries,
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][int]
$RetryDelaySeconds
)
for ($i = 0; $i -lt $Retries; $i++) {
try {
return & $Command @Args
}
catch {
Start-Sleep $RetryDelaySeconds
}
}
}
function Get-APIServer-IPAddress
{
$uri = "http://169.254.169.254/metadata/instance/compute/tags?api-version=2019-03-11&format=text"
$response = Retry-Command -Command "Invoke-RestMethod" -Args @{Uri=$uri; Method="Get"; ContentType="application/json"; Headers=@{"Metadata"="true"}} -Retries 3 -RetryDelaySeconds 5
if(!$response) {
return ""
}
foreach ($tag in $response.Split(";"))
{
$values = $tag.Split(":")
if ($values.Length -ne 2)
{
return ""
}
if ($values[0] -eq "aksAPIServerIPAddress")
{
return $values[1]
}
}
return ""
}
Write-Log "Get cluster APIServer FQDN: $clusterFQDN"
while ($true)
{
$clusterIP = Get-APIServer-IPAddress
if ($clusterIP -eq "") {
Start-Sleep $retryDelaySeconds
continue
}
$hostsContent=Get-Content -Path $hostsFile -Encoding UTF8
if ($hostsContent -match "$clusterIP $clusterFQDN") {
Write-Log "APIServer FQDN has already been set to $clusterIP in hosts file"
} else {
$hostsContent -notmatch "$clusterFQDN" | Out-File $hostsFile -Encoding UTF8
Add-Content -Path $hostsFile -Value "$clusterIP $clusterFQDN" -Encoding UTF8
Write-Log "Updated APIServer FQDN to $clusterIP in hosts file"
}
Start-Sleep $retryDelaySeconds
}

Просмотреть файл

@ -40,6 +40,11 @@ if ($global:CsiProxyEnabled) {
Stop-Service csi-proxy
}
if ($global:EnableHostsConfigAgent) {
Write-Log "Stopping hosts-config-agent service"
Stop-Service hosts-config-agent
}
#
# Perform cleanup
#