Skip to content

Commit

Permalink
Update parameter description
Browse files Browse the repository at this point in the history
  • Loading branch information
yinghsugn committed Feb 13, 2023
1 parent 79bf2b1 commit db0351e
Showing 1 changed file with 45 additions and 30 deletions.
75 changes: 45 additions & 30 deletions src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,32 @@ function New-AzConnectedKubernetes {
[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')]
[System.Uri]
# The http URI for the proxy server to use
# The http URI of the proxy server for the kubernetes cluster to use
${ProxyHttp},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')]
[System.Uri]
# The https URI for the proxy server to use
# The https URI of the proxy server for the kubernetes cluster to use
${ProxyHttps},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')]
[System.String]
# The skip range URI for the proxy server to use
# The comma-separated list of hostnames that should be excluded from the proxy server for the kubernetes cluster to use
${ProxyNo},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')]
[System.String]
# The path to the certificate file for proxy or custom Certificate Authority.
${ProxyCert},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')]
[ValidateRange(0,3600)]
[Int]
# The timeout for onboarding azure-arc
# The time required (in seconds) for the arc-agent pods to be installed on the kubernetes cluster.
${OnboardingTimeout} = 600,

[Parameter()]
Expand Down Expand Up @@ -209,14 +215,14 @@ function New-AzConnectedKubernetes {
[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
# The URI of the proxy server for host os to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
# The credential of the proxy server for host os to use
${ProxyCredential},

[Parameter(DontShow)]
Expand Down Expand Up @@ -399,7 +405,7 @@ function New-AzConnectedKubernetes {
}
} else {
$AgentPublicKey = [System.Convert]::ToBase64String($RSA.ExportRSAPublicKey())
$AgentPrivateKey = "-----BEGIN RSA PRIVATE KEY-----`n" + [System.Convert]::ToBase64String($RSA.ExportRSAPrivateKey()) + "`n-----END RSA PRIVATE KEY-----"
$AgentPrivateKey = "-----BEGIN RSA PRIVATE KEY-----`n" + [System.Convert]::ToBase64String($RSA.ExportRSAPrivateKey()) + "`n-----END RSA PRIVATE KEY-----"
}

$HelmChartPath = Join-Path -Path $ChartExportPath -ChildPath 'azure-arc-k8sagents'
Expand All @@ -409,77 +415,86 @@ function New-AzConnectedKubernetes {
$ChartPath = $HelmChartPath
}

#Region helm options
$options = ""
$proxyEnableState = $false
if (-not ([string]::IsNullOrEmpty($ProxyHttp))) {
$ProxyHttpStr = $ProxyHttp.ToString()
$ProxyHttpStr = $ProxyHttpStr -replace ',','\,'
$ProxyHttpStr = $ProxyHttpStr -replace '/','\/'
$ProxyHttpStr = $ProxyHttpStr -replace '/','\/'
$options += " --set global.httpProxy=$ProxyHttpStr"
$proxyEnableState = $true
$Null = $PSBoundParameters.Remove('ProxyHttp')
}

if (-not ([string]::IsNullOrEmpty($ProxyHttps))) {
$ProxyHttpsStr = $ProxyHttps.ToString()
$ProxyHttpsStr = $ProxyHttpsStr -replace ',','\,'
$ProxyHttpsStr = $ProxyHttpsStr -replace '/','\/'
$ProxyHttpsStr = $ProxyHttpsStr -replace '/','\/'
$options += " --set global.httpsProxy=$ProxyHttpsStr"
$proxyEnableState = $true
$Null = $PSBoundParameters.Remove('ProxyHttps')
}

if (-not ([string]::IsNullOrEmpty($ProxyNo))) {
$ProxyNo = $ProxyNo -replace ',','\,'
$ProxyNo = $ProxyNo -replace '/','\/'
$ProxyNo = $ProxyNo -replace '/','\/'
$options += " --set global.noProxy=$ProxyNo"
$proxyEnableState = $true
$Null = $PSBoundParameters.Remove('ProxyNo')
}

if($proxyEnableState) {
if ($proxyEnableState) {
$options += " --set global.isProxyEnabled=true"
}

try {
if (($PSBoundParameters.ContainsKey('ProxyCredential')) -and (Test-Path $ProxyCredential)) {
$options += " --set-file global.proxyCert=$ProxyCredential"
if ((-not ([string]::IsNullOrEmpty($ProxyCert))) -and (Test-Path $ProxyCert)) {
$options += " --set-file global.proxyCert=$ProxyCert"
$options += " --set global.isCustomCert=true"
}
} catch {
Write-Error "Unable to find ProxyCrendial"
Write-Error "Unable to find ProxyCert from file path"
throw
}

if($DisableAutoUpgrade) {
if ($DisableAutoUpgrade) {
$options += " --set systemDefaultValues.azureArcAgents.autoUpdate=false"
$Null = $PSBoundParameters.Remove('DisableAutoUpgrade')
}

if(-not ([string]::IsNullOrEmpty($ContainerLogPath))) {
if (-not ([string]::IsNullOrEmpty($ContainerLogPath))) {
$options += " --set systemDefaultValues.fluent-bit.containerLogPath=$ContainerLogPath"
$Null = $PSBoundParameters.Remove('ContainerLogPath')
}

if (-not ([string]::IsNullOrEmpty($KubeConfig))) {
$options += " --kubeconfig $KubeConfig"
}

if (-not ([string]::IsNullOrEmpty($KubeContext))) {
$options += " --kube-context $KubeContext"
}

if (!$NoWait) {
$options += " --wait --timeout $OnboardingTimeout"
$options += "s"
}

}
#Endregion
if ($PSBoundParameters.ContainsKey('OnboardingTimeout')) {
$PSBoundParameters.Remove('OnboardingTimeout')
}

$PSBoundParameters.Add('AgentPublicKeyCertificate', $AgentPublicKey)
$Response = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters
if ((-not ([string]::IsNullOrEmpty($Proxy))) -and (-not $PSBoundParameters.ContainsKey('ProxyCredential'))) {
if ($null -ne $ProxyCredential.UserInfo) {
try{
$userInfo = $ProxyCredential.UserInfo -Split ':'
$pass = ConvertTo-SecureString $userInfo[1] -AsPlainText -Force
$ProxyCredential = New-Object System.Management.Automation.PSCredential ($userInfo[0] , $pass)
} catch {
Write-Error "Bad syntax for username and password of proxy server in the Proxy parameter"
}
} else {
Write-Debug "If the proxy is private proxy, should also pass ProxyCredential parameter"
}
}
try{
$PSBoundParameters.Add('AgentPublicKeyCertificate', $AgentPublicKey)
$Response = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters
} catch {
Write-Error "Failed to register a new Kubernetes cluster"
throw
}

$TenantId = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext.Tenant.Id
helm upgrade --install azure-arc $ChartPath --namespace $ReleaseInstallNamespace --create-namespace --set global.subscriptionId=$SubscriptionId --set global.resourceGroupName=$ResourceGroupName --set global.resourceName=$ClusterName --set global.tenantId=$TenantId --set global.location=$Location --set global.onboardingPrivateKey=$AgentPrivateKey --set systemDefaultValues.spnOnboarding=false --set global.azureEnvironment=AZUREPUBLICCLOUD --set systemDefaultValues.clusterconnect-agent.enabled=true --set global.kubernetesDistro=$Distribution --set global.kubernetesInfra=$Infrastructure (-split $options)
Expand Down

0 comments on commit db0351e

Please sign in to comment.