diff --git a/src/ConnectedKubernetes/ChangeLog.md b/src/ConnectedKubernetes/ChangeLog.md index b3d442472f79..861cbfffd0e8 100644 --- a/src/ConnectedKubernetes/ChangeLog.md +++ b/src/ConnectedKubernetes/ChangeLog.md @@ -18,6 +18,10 @@ - Additional information about change #1 --> ## Upcoming Release +* Added optional configs (-HttpProxy, -HttpsProxy, -NoProxy, -ProxyCert) for connection behind outbound proxy server. +* Added optional configs (-ContainerLogPath, -DisableAutoUpgrade, -NoWait, -OnboardingTimeout). +* Fixed invalid URI issue with display name of location. +* Fixed response can't be parsed issue with UseBasicParsing. ## Version 0.7.1 * Made `New-AzConnectedKubernetes` support PowerShell 5. diff --git a/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 b/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 index b9956b42bfe5..35d9e715ad5d 100644 --- a/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 +++ b/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 @@ -54,12 +54,55 @@ function New-AzConnectedKubernetes { # The ID of the target subscription. ${SubscriptionId}, + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')] + [System.Uri] + # The http URI of the proxy server for the kubernetes cluster to use + ${HttpProxy}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')] + [System.Uri] + # The https URI of the proxy server for the kubernetes cluster to use + ${HttpsProxy}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')] + [System.String] + # The comma-separated list of hostnames that should be excluded from the proxy server for the kubernetes cluster to use + ${NoProxy}, + + [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 time required (in seconds) for the arc-agent pods to be installed on the kubernetes cluster. + ${OnboardingTimeout} = 600, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')] + [System.Management.Automation.SwitchParameter] + # Flag to disable auto upgrade of arc agents. + ${DisableAutoUpgrade}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')] + [System.String] + # Override the default container log path to enable fluent-bit logging. + ${ContainerLogPath}, + [Parameter(HelpMessage="Path to the kube config file")] [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Body')] [System.String] # Path to the kube config file ${KubeConfig}, - + [Parameter(HelpMessage="Kubconfig context from current machine")] [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Body')] [System.String] @@ -172,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)] @@ -224,7 +267,7 @@ function New-AzConnectedKubernetes { if ($PSBoundParameters.ContainsKey('KubeContext')) { $Null = $PSBoundParameters.Remove('KubeContext') } - if (($KubeContext -eq $null) -or ($KubeContext -eq '')) { + if (($null -eq $KubeContext) -or ($KubeContext -eq '')) { $KubeContext = kubectl config current-context } @@ -260,9 +303,10 @@ function New-AzConnectedKubernetes { #EndRegion #Region get release namespace + Set-Variable ReleaseInstallNamespace -option Constant -value "azure-arc-release" $ReleaseNamespace = $null try { - $ReleaseNamespace = (helm status azure-arc -o json --kubeconfig $KubeConfig --kube-context $KubeContext | ConvertFrom-Json).namespace + $ReleaseNamespace = (helm status azure-arc -o json --kubeconfig $KubeConfig --kube-context $KubeContext -n $ReleaseInstallNamespace | ConvertFrom-Json).namespace } catch { Write-Error "Fail to find the namespace for azure-arc." } @@ -302,6 +346,15 @@ function New-AzConnectedKubernetes { } else { $ReleaseTrain = 'stable' } + + $AzLocation = Get-AzLocation | Where-Object { ($_.DisplayName -ieq $Location) -or ($_.Location -ieq $Location)} + $Region = $AzLocation.Location + if ($null -eq $Region) { + Write-Error "Invalid location: $Location" + return + } else { + $Location = $Region + } $ChartLocationUrl = "https://${Location}.dp.kubernetesconfiguration.azure.com/azure-arc-k8sagents/GetLatestHelmPackagePath?api-version=2019-11-01-preview&releaseTrain=${ReleaseTrain}" $Uri = [System.Uri]::New($ChartLocationUrl) @@ -315,7 +368,7 @@ function New-AzConnectedKubernetes { $HeaderParameter = @{ "Authorization" = "Bearer $AccessToken" } - $Response = Invoke-WebRequest -Uri $Uri -Headers $HeaderParameter -Method Post + $Response = Invoke-WebRequest -Uri $Uri -Headers $HeaderParameter -Method Post -UseBasicParsing if ($Response.StatusCode -eq 200) { $RegisteryPath = ($Response.Content | ConvertFrom-Json).repositoryPath } else { @@ -354,15 +407,16 @@ function New-AzConnectedKubernetes { . "$PSScriptRoot/../utils/RSAHelper.ps1" $AgentPublicKey = ExportRSAPublicKeyBase64($RSA) $AgentPrivateKey = ExportRSAPrivateKeyBase64($RSA) + $AgentPrivateKey = "-----BEGIN RSA PRIVATE KEY-----`n" + $AgentPrivateKey + "`n-----END RSA PRIVATE KEY-----" } catch { Write-Error "Unable to generate RSA keys" throw } } 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' if (Test-Path Env:HELMCHART) { $ChartPath = Get-ChildItem -Path Env:HELMCHART @@ -370,11 +424,87 @@ function New-AzConnectedKubernetes { $ChartPath = $HelmChartPath } + #Region helm options + $options = "" + $proxyEnableState = $false + if (-not ([string]::IsNullOrEmpty($HttpProxy))) { + $HttpProxyStr = $HttpProxy.ToString() + $HttpProxyStr = $HttpProxyStr -replace ',','\,' + $HttpProxyStr = $HttpProxyStr -replace '/','\/' + $options += " --set global.httpProxy=$HttpProxyStr" + $proxyEnableState = $true + $Null = $PSBoundParameters.Remove('HttpProxy') + } + if (-not ([string]::IsNullOrEmpty($HttpsProxy))) { + $HttpsProxyStr = $HttpsProxy.ToString() + $HttpsProxyStr = $HttpsProxyStr -replace ',','\,' + $HttpsProxyStr = $HttpsProxyStr -replace '/','\/' + $options += " --set global.httpsProxy=$HttpsProxyStr" + $proxyEnableState = $true + $Null = $PSBoundParameters.Remove('HttpsProxy') + } + if (-not ([string]::IsNullOrEmpty($NoProxy))) { + $NoProxy = $NoProxy -replace ',','\,' + $NoProxy = $NoProxy -replace '/','\/' + $options += " --set global.noProxy=$NoProxy" + $proxyEnableState = $true + $Null = $PSBoundParameters.Remove('NoProxy') + } + if ($proxyEnableState) { + $options += " --set global.isProxyEnabled=true" + } + try { + 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 ProxyCert from file path" + throw + } + if ($DisableAutoUpgrade) { + $options += " --set systemDefaultValues.azureArcAgents.autoUpdate=false" + $Null = $PSBoundParameters.Remove('DisableAutoUpgrade') + } + 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') + } + if ((-not ([string]::IsNullOrEmpty($Proxy))) -and (-not $PSBoundParameters.ContainsKey('ProxyCredential'))) { + if (-not ([string]::IsNullOrEmpty($Proxy.UserInfo))) { + try{ + $userInfo = $Proxy.UserInfo -Split ':' + $pass = ConvertTo-SecureString $userInfo[1] -AsPlainText -Force + $ProxyCredential = New-Object System.Management.Automation.PSCredential ($userInfo[0] , $pass) + $PSBoundParameters.Add('ProxyCredential', $ProxyCredential) + } catch { + Write-Warning "Please set ProxyCredential or provide username and password in the Proxy parameter" + throw + } + } else { + Write-Warning "If the proxy is a private proxy, pass ProxyCredential parameter or provide username and password in the Proxy parameter" + } + } + $PSBoundParameters.Add('AgentPublicKeyCertificate', $AgentPublicKey) $Response = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters - $TenantId = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext.Tenant.Id - helm upgrade --install azure-arc $ChartPath --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 --kubeconfig $KubeConfig --kube-context $KubeContext --wait --timeout 600s + $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) Return $Response } } diff --git a/src/ConnectedKubernetes/custom/Remove-AzConnectedKubernetes.ps1 b/src/ConnectedKubernetes/custom/Remove-AzConnectedKubernetes.ps1 index b9616a9cd8dc..1ee62412b9f0 100644 --- a/src/ConnectedKubernetes/custom/Remove-AzConnectedKubernetes.ps1 +++ b/src/ConnectedKubernetes/custom/Remove-AzConnectedKubernetes.ps1 @@ -186,9 +186,10 @@ param( #Endregion #Region get release namespace + Set-Variable ReleaseInstallNamespace -option Constant -value "azure-arc-release" $ReleaseNamespace = $null try { - $ReleaseNamespace = (helm status azure-arc -o json --kubeconfig $KubeConfig --kube-context $KubeContext | ConvertFrom-Json).namespace + $ReleaseNamespace = (helm status azure-arc -o json --kubeconfig $KubeConfig --kube-context $KubeContext -n $ReleaseInstallNamespace | ConvertFrom-Json).namespace } catch { Write-Error "Fail to find the namespace for azure-arc." } @@ -211,7 +212,7 @@ param( } if (($ResourceGroupName -eq $ConfigmapRgName) -and ($ClusterName -eq $ConfigmapClusterName)) { Az.ConnectedKubernetes.internal\Remove-AzConnectedKubernetes @PSBoundParameters - helm delete azure-arc --namespace $ReleaseNamespace --kubeconfig $KubeConfig --kube-context $KubeContext + helm delete azure-arc --namespace $ReleaseInstallNamespace --kubeconfig $KubeConfig --kube-context $KubeContext } else { Write-Error "The current context in the kubeconfig file does not correspond to the connected cluster resource specified. Agents installed on this cluster correspond to the resource group name '$ConfigmapRgName' and resource name '$ConfigmapClusterName'." } diff --git a/src/ConnectedKubernetes/docs/Az.ConnectedKubernetes.md b/src/ConnectedKubernetes/docs/Az.ConnectedKubernetes.md new file mode 100644 index 000000000000..67f8cb3bb1e4 --- /dev/null +++ b/src/ConnectedKubernetes/docs/Az.ConnectedKubernetes.md @@ -0,0 +1,28 @@ +--- +Module Name: Az.ConnectedKubernetes +Module Guid: 683047b8-5094-43e1-96c7-6792b93e81cb +Download Help Link: https://learn.microsoft.com/powershell/module/az.connectedkubernetes +Help Version: 1.0.0.0 +Locale: en-US +--- + +# Az.ConnectedKubernetes Module +## Description +Microsoft Azure PowerShell: ConnectedKubernetes cmdlets + +## Az.ConnectedKubernetes Cmdlets +### [Get-AzConnectedKubernetes](Get-AzConnectedKubernetes.md) +Returns the properties of the specified connected cluster, including name, identity, properties, and additional cluster details. + +### [Get-AzConnectedKubernetesUserCredential](Get-AzConnectedKubernetesUserCredential.md) +Gets cluster user credentials of the connected cluster with a specified resource group and name. + +### [New-AzConnectedKubernetes](New-AzConnectedKubernetes.md) +API to register a new Kubernetes cluster and create a tracked resource in Azure Resource Manager (ARM). + +### [Remove-AzConnectedKubernetes](Remove-AzConnectedKubernetes.md) +Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM). + +### [Update-AzConnectedKubernetes](Update-AzConnectedKubernetes.md) +API to update certain properties of the connected cluster resource + diff --git a/src/ConnectedKubernetes/docs/Get-AzConnectedKubernetes.md b/src/ConnectedKubernetes/docs/Get-AzConnectedKubernetes.md new file mode 100644 index 000000000000..f0517895e0bc --- /dev/null +++ b/src/ConnectedKubernetes/docs/Get-AzConnectedKubernetes.md @@ -0,0 +1,204 @@ +--- +external help file: +Module Name: Az.ConnectedKubernetes +online version: https://learn.microsoft.com/powershell/module/az.connectedkubernetes/get-azconnectedkubernetes +schema: 2.0.0 +--- + +# Get-AzConnectedKubernetes + +## SYNOPSIS +Returns the properties of the specified connected cluster, including name, identity, properties, and additional cluster details. + +## SYNTAX + +### List1 (Default) +``` +Get-AzConnectedKubernetes [-SubscriptionId ] [-DefaultProfile ] [] +``` + +### Get +``` +Get-AzConnectedKubernetes -ClusterName -ResourceGroupName [-SubscriptionId ] + [-DefaultProfile ] [] +``` + +### GetViaIdentity +``` +Get-AzConnectedKubernetes -InputObject [-DefaultProfile ] + [] +``` + +### List +``` +Get-AzConnectedKubernetes -ResourceGroupName [-SubscriptionId ] + [-DefaultProfile ] [] +``` + +## DESCRIPTION +Returns the properties of the specified connected cluster, including name, identity, properties, and additional cluster details. + +## EXAMPLES + +### Example 1: Get all connected kubernetes under a subscription. +```powershell +Get-AzConnectedKubernetes +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +eastus azps_test_cluster_ahb azps_test_group +``` + +This command gets all connected kubernetes under a subscription. + +### Example 2: Get all connected kubernetes under the resource group. +```powershell +Get-AzConnectedKubernetes -ResourceGroupName azps_test_group +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +eastus azps_test_cluster_ahb azps_test_group +``` + +This command gets all connected kubernetes under the resource group. + +### Example 3: Get a connected kubernetes. +```powershell +Get-AzConnectedKubernetes -ResourceGroupName azps_test_group -Name azps_test_cluster +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command gets a connected kubernetes. + +### Example 4: Get a connected kubernetes by object. +```powershell +$conAks = Get-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group +Get-AzConnectedKubernetes -InputObject $conAks +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +This command gets a connected kubernetes by object. + +## PARAMETERS + +### -ClusterName +The name of the Kubernetes cluster on which get is called. + +```yaml +Type: System.String +Parameter Sets: Get +Aliases: Name + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.IConnectedKubernetesIdentity +Parameter Sets: GetViaIdentity +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. +The name is case insensitive. + +```yaml +Type: System.String +Parameter Sets: Get, List +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubscriptionId +The ID of the target subscription. + +```yaml +Type: System.String[] +Parameter Sets: Get, List, List1 +Aliases: + +Required: False +Position: Named +Default value: (Get-AzContext).Subscription.Id +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.IConnectedKubernetesIdentity + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.Api20221001Preview.IConnectedCluster + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +`INPUTOBJECT `: Identity Parameter + - `[ClusterName ]`: The name of the Kubernetes cluster on which get is called. + - `[Id ]`: Resource identity path + - `[ResourceGroupName ]`: The name of the resource group. The name is case insensitive. + - `[SubscriptionId ]`: The ID of the target subscription. + +## RELATED LINKS + diff --git a/src/ConnectedKubernetes/docs/Get-AzConnectedKubernetesUserCredential.md b/src/ConnectedKubernetes/docs/Get-AzConnectedKubernetesUserCredential.md new file mode 100644 index 000000000000..43212265d335 --- /dev/null +++ b/src/ConnectedKubernetes/docs/Get-AzConnectedKubernetesUserCredential.md @@ -0,0 +1,235 @@ +--- +external help file: +Module Name: Az.ConnectedKubernetes +online version: https://learn.microsoft.com/powershell/module/az.connectedkubernetes/get-azconnectedkubernetesusercredential +schema: 2.0.0 +--- + +# Get-AzConnectedKubernetesUserCredential + +## SYNOPSIS +Gets cluster user credentials of the connected cluster with a specified resource group and name. + +## SYNTAX + +### ListExpanded (Default) +``` +Get-AzConnectedKubernetesUserCredential -ClusterName -ResourceGroupName + -AuthenticationMethod -ClientProxy [-SubscriptionId ] + [-DefaultProfile ] [-Confirm] [-WhatIf] [] +``` + +### List +``` +Get-AzConnectedKubernetesUserCredential -ClusterName -ResourceGroupName + -Property [-SubscriptionId ] [-DefaultProfile ] + [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +Gets cluster user credentials of the connected cluster with a specified resource group and name. + +## EXAMPLES + +### Example 1: Gets cluster user credentials of the connected cluster with a specified resource group and name. +```powershell +Get-AzConnectedKubernetesUserCredential -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -AuthenticationMethod AAD -ClientProxy +``` + +```output +HybridConnectionConfigExpirationTime : 1635508790 +HybridConnectionConfigHybridConnectionName : microsoft.kubernetes/connectedclusters/8d3bccced1f3ad1d0e01b03e87d1c8f8a312df7ff028e642512a7999542e46fc/1635497990523092736 +HybridConnectionConfigRelay : azgnrelay-eastus-l1 +HybridConnectionConfigToken : SharedAccessSignature sr=http%3A%2F%2Fazgnrelay-eastus-l1.servicebus.windows.net%2Fmicrosoft.kubernetes%2Fconnectedclusters%2F8d3bccced1f3ad1d0e01b03e87d1c8f8a312df7ff028e642512a7999542e46fc%2F1635497990523092736%2F&sig=wrukC6KAxVFb%2FmsdaTwSv3ChHo0hvTWjf5A80IZs2P4%3D&se=1635509390&skn=sender20211026 +Kubeconfig : {{ + "name": "KubeConfig", + "value": "YXBpVm***G9wDQo=" + }} +``` + +Gets cluster user credentials of the connected cluster with a specified resource group and name. + +### Example 2: Gets cluster user credentials of the connected cluster with a specified resource group and name. +```powershell +Get-AzConnectedKubernetesUserCredential -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -AuthenticationMethod Token -ClientProxy:$false +``` + +```output +HybridConnectionConfigExpirationTime : +HybridConnectionConfigHybridConnectionName : +HybridConnectionConfigRelay : +HybridConnectionConfigToken : +Kubeconfig : {{ + "name": "KubeConfig", + "value": "YXBpVm***G9wDQo=" + }} +``` + +Gets cluster user credentials of the connected cluster with a specified resource group and name. + +## PARAMETERS + +### -AuthenticationMethod +The mode of client authentication. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Support.AuthenticationMethod +Parameter Sets: ListExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ClientProxy +Boolean value to indicate whether the request is for client side proxy or not + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: ListExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ClusterName +The name of the Kubernetes cluster on which get is called. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: Name + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Property +. +To construct, see NOTES section for PROPERTY properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.Api20221001Preview.IListClusterUserCredentialProperties +Parameter Sets: List +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. +The name is case insensitive. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubscriptionId +The ID of the target subscription. + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: (Get-AzContext).Subscription.Id +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.Api20221001Preview.IListClusterUserCredentialProperties + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.Api20221001Preview.ICredentialResults + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +`PROPERTY `: . + - `AuthenticationMethod `: The mode of client authentication. + - `ClientProxy `: Boolean value to indicate whether the request is for client side proxy or not + +## RELATED LINKS + diff --git a/src/ConnectedKubernetes/docs/New-AzConnectedKubernetes.md b/src/ConnectedKubernetes/docs/New-AzConnectedKubernetes.md new file mode 100644 index 000000000000..0c2bf28dca13 --- /dev/null +++ b/src/ConnectedKubernetes/docs/New-AzConnectedKubernetes.md @@ -0,0 +1,563 @@ +--- +external help file: +Module Name: Az.ConnectedKubernetes +online version: https://learn.microsoft.com/powershell/module/az.connectedkubernetes/new-azconnectedkubernetes +schema: 2.0.0 +--- + +# New-AzConnectedKubernetes + +## SYNOPSIS +API to register a new Kubernetes cluster and create a tracked resource in Azure Resource Manager (ARM). + +## SYNTAX + +``` +New-AzConnectedKubernetes -ClusterName -ResourceGroupName -Location + [-ContainerLogPath ] [-DisableAutoUpgrade] [-HttpProxy ] [-HttpsProxy ] [-NoProxy ] + [-OnboardingTimeout ] [-ProxyCert ] [-SubscriptionId ] [-AcceptEULA] + [-AzureHybridBenefit ] [-Distribution ] [-DistributionVersion ] + [-Infrastructure ] [-KubeConfig ] [-KubeContext ] + [-PrivateLinkScopeResourceId ] [-PrivateLinkState ] + [-ProvisioningState ] [-Tag ] [-DefaultProfile ] [-AsJob] [-NoWait] + [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +API to register a new Kubernetes cluster and create a tracked resource in Azure Resource Manager (ARM). + +## EXAMPLES + +### Example 1: Create a connected kubernetes. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command creates a connected kubernetes. + +### Example 2: Create a connected kubernetes with parameters kubeConfig and kubeContext. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command creates a connected kubernetes with parameters kubeConfig and kubeContext. + +### Example 3: Create a ConnectedKubernetes's AzureHybridBenefit. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 -PrivateLinkState 'Enabled' -Distribution "AKS_Management" -DistributionVersion "1.0" -PrivateLinkScopeResourceId "/subscriptions/{subscriptionId}/resourceGroups/azps_test_group/providers/Microsoft.HybridCompute/privateLinkScopes/azps-privatelinkscope" -infrastructure "azure_stack_hci" -ProvisioningState 'Succeeded' -AzureHybridBenefit 'True' +``` + +```output +I confirm I have an eligible Windows Server license with Azure Hybrid Benefit to apply this benefit to AKS on Azure Stack HCI or Windows Server. Visit https://aka.ms/ahb-aks for details. +[Y] Yes [N] No (default is "N"): Y + +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +Create a ConnectedKubernetes's AzureHybridBenefit. + +### Example 4: Using [-AcceptEULA] will default to your acceptance of the terms of our legal agreement and create a connected kubernetes. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 -PrivateLinkState 'Enabled' -Distribution "AKS_Management" -DistributionVersion "1.0" -PrivateLinkScopeResourceId "/subscriptions/{subscriptionId}/resourceGroups/azps_test_group/providers/Microsoft.HybridCompute/privateLinkScopes/azps-privatelinkscope" -infrastructure "azure_stack_hci" -ProvisioningState 'Succeeded' -AzureHybridBenefit 'True' -AcceptEULA +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +Using [-AcceptEULA] will default to your acceptance of the terms of our legal agreement and create a connected kubernetes. + +### Example 5: Create a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy and Proxy. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 -HttpProxy "http://proxy-user:proxy-password@proxy-ip:port" -HttpsProxy "http://proxy-user:proxy-password@proxy-ip:port" -NoProxy "localhost,127.0.0.0/8,192.168.0.0/16,172.17.0.0/16,10.96.0.0/12,10.244.0.0/16,10.43.0.0/24,.svc" -Proxy "http://proxy-user:proxy-password@proxy-ip:port" +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +This command creates a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy and Proxy. + +### Example 6: Create a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy, Proxy and ProxyCredential. +```powershell +$pwd = ConvertTo-SecureString "proxy-password" -AsPlainText -Force +$cred = New-Object System.Management.Automation.PSCredential ("proxy-user", $pwd) +New-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 -HttpProxy "http://proxy-user:proxy-password@proxy-ip:port" -HttpsProxy "http://proxy-user:proxy-password@proxy-ip:port" -NoProxy "localhost,127.0.0.0/8,192.168.0.0/16,172.17.0.0/16,10.96.0.0/12,10.244.0.0/16,10.43.0.0/24,.svc" -Proxy "http://proxy-ip:port" -ProxyCredential $cred +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +This command creates a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy, Proxy and ProxyCredential. + +### Example 7: Create a connected kubernetes and disable auto upgrade of arc agents. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus -DisableAutoUpgrade +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command creates a connected kubernetes and disable auto upgrade of arc agents. + +### Example 8: Create a connected kubernetes with custom onboarding timeout. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus -OnboardingTimeout 600 +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command creates a connected kubernetes with custom onboarding timeout. + +## PARAMETERS + +### -AcceptEULA +Accept EULA of ConnectedKubernetes, legal term will pop up without this parameter provided + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AsJob +Run the command as a job + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AzureHybridBenefit +Indicates whether Azure Hybrid Benefit is opted in + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Support.AzureHybridBenefit +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ClusterName +The name of the Kubernetes cluster on which get is called. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: Name + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ContainerLogPath +Override the default container log path to enable fluent-bit logging. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DisableAutoUpgrade +Flag to disable auto upgrade of arc agents. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Distribution +The Kubernetes distribution running on this connected cluster. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DistributionVersion +The Kubernetes distribution version on this connected cluster. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -HttpProxy +The http URI of the proxy server for the kubernetes cluster to use + +```yaml +Type: System.Uri +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -HttpsProxy +The https URI of the proxy server for the kubernetes cluster to use + +```yaml +Type: System.Uri +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Infrastructure +The infrastructure on which the Kubernetes cluster represented by this connected cluster is running on. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -KubeConfig +Path to the kube config file + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -KubeContext +Kubconfig context from current machine + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Location +The geo-location where the resource lives + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NoProxy +The comma-separated list of hostnames that should be excluded from the proxy server for the kubernetes cluster to use + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NoWait +Run the command asynchronously + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -OnboardingTimeout +The time required (in seconds) for the arc-agent pods to be installed on the kubernetes cluster. + +```yaml +Type: System.Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PrivateLinkScopeResourceId +The resource id of the private link scope this connected cluster is assigned to, if any. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PrivateLinkState +Property which describes the state of private link on a connected cluster resource. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Support.PrivateLinkState +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProvisioningState +Provisioning state of the connected cluster resource. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Support.ProvisioningState +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProxyCert +The path to the certificate file for proxy or custom Certificate Authority. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. +The name is case insensitive. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubscriptionId +The ID of the target subscription. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: (Get-AzContext).Subscription.Id +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Resource tags. + +```yaml +Type: System.Collections.Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.Api20221001Preview.IConnectedCluster + +## NOTES + +ALIASES + +## RELATED LINKS + diff --git a/src/ConnectedKubernetes/docs/Remove-AzConnectedKubernetes.md b/src/ConnectedKubernetes/docs/Remove-AzConnectedKubernetes.md new file mode 100644 index 000000000000..69854a4a6b4e --- /dev/null +++ b/src/ConnectedKubernetes/docs/Remove-AzConnectedKubernetes.md @@ -0,0 +1,260 @@ +--- +external help file: +Module Name: Az.ConnectedKubernetes +online version: https://learn.microsoft.com/powershell/module/az.connectedkubernetes/remove-azconnectedkubernetes +schema: 2.0.0 +--- + +# Remove-AzConnectedKubernetes + +## SYNOPSIS +Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM). + +## SYNTAX + +### Delete (Default) +``` +Remove-AzConnectedKubernetes -ClusterName -ResourceGroupName [-SubscriptionId ] + [-KubeConfig ] [-KubeContext ] [-DefaultProfile ] [-AsJob] [-NoWait] [-PassThru] + [-Confirm] [-WhatIf] [] +``` + +### DeleteViaIdentity +``` +Remove-AzConnectedKubernetes -InputObject [-KubeConfig ] + [-KubeContext ] [-DefaultProfile ] [-AsJob] [-NoWait] [-PassThru] [-Confirm] [-WhatIf] + [] +``` + +## DESCRIPTION +Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM). + +## EXAMPLES + +### Example 1: Remove a connected kubernetes. +```powershell +Remove-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group +``` + +This command removes a connected kubernetes. + +### Example 2: Remove a connected kubernetes by object. +```powershell +Get-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group | Remove-AzConnectedKubernetes +``` + +This command removes a connected kubernetes by object. + +## PARAMETERS + +### -AsJob +Run the command as a job + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ClusterName +The name of the Kubernetes cluster on which get is called. + +```yaml +Type: System.String +Parameter Sets: Delete +Aliases: Name + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.IConnectedKubernetesIdentity +Parameter Sets: DeleteViaIdentity +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -KubeConfig +Path to the kube config file + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -KubeContext +Kubconfig context from current machine + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NoWait +Run the command asynchronously + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +Returns true when the command succeeds + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. +The name is case insensitive. + +```yaml +Type: System.String +Parameter Sets: Delete +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubscriptionId +The ID of the target subscription. + +```yaml +Type: System.String +Parameter Sets: Delete +Aliases: + +Required: False +Position: Named +Default value: (Get-AzContext).Subscription.Id +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.IConnectedKubernetesIdentity + +## OUTPUTS + +### System.Boolean + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +`INPUTOBJECT `: Identity Parameter + - `[ClusterName ]`: The name of the Kubernetes cluster on which get is called. + - `[Id ]`: Resource identity path + - `[ResourceGroupName ]`: The name of the resource group. The name is case insensitive. + - `[SubscriptionId ]`: The ID of the target subscription. + +## RELATED LINKS + diff --git a/src/ConnectedKubernetes/docs/Update-AzConnectedKubernetes.md b/src/ConnectedKubernetes/docs/Update-AzConnectedKubernetes.md new file mode 100644 index 000000000000..7bd5ceca63ee --- /dev/null +++ b/src/ConnectedKubernetes/docs/Update-AzConnectedKubernetes.md @@ -0,0 +1,302 @@ +--- +external help file: +Module Name: Az.ConnectedKubernetes +online version: https://learn.microsoft.com/powershell/module/az.connectedkubernetes/update-azconnectedkubernetes +schema: 2.0.0 +--- + +# Update-AzConnectedKubernetes + +## SYNOPSIS +API to update certain properties of the connected cluster resource + +## SYNTAX + +### UpdateExpanded (Default) +``` +Update-AzConnectedKubernetes -ClusterName -ResourceGroupName [-SubscriptionId ] + [-AcceptEULA] [-AzureHybridBenefit ] [-Distribution ] + [-DistributionVersion ] [-Tag ] [-DefaultProfile ] [-Confirm] [-WhatIf] + [] +``` + +### UpdateViaIdentityExpanded +``` +Update-AzConnectedKubernetes -InputObject [-AcceptEULA] + [-AzureHybridBenefit ] [-Distribution ] [-DistributionVersion ] + [-Tag ] [-DefaultProfile ] [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +API to update certain properties of the connected cluster resource + +## EXAMPLES + +### Example 1: Update a connected kubernetes. +```powershell +Update-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Tag @{'key'='1'} +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command updates a connected kubernetes. + +### Example 2: Update a connected kubernetes by object. +```powershell +Get-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group | Update-AzConnectedKubernetes -Tag @{'key'='2'} +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command updates a connected kubernetes by object. + +### Example 3: Update a ConnectedKubernetes's AzureHybridBenefit. +```powershell +Update-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Tag @{'key'='1'} -AzureHybridBenefit 'True' +``` + +```output +I confirm I have an eligible Windows Server license with Azure Hybrid Benefit to apply this benefit to AKS on Azure Stack HCI or Windows Server. Visit https://aka.ms/ahb-aks for details. +[Y] Yes [N] No (default is "N"): y + +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +Update a ConnectedKubernetes's AzureHybridBenefit. + +### Example 4: Using [-AcceptEULA] will default to your acceptance of the terms of our legal agreement and update a ConnectedKubernetes's AzureHybridBenefit. +```powershell +Update-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Tag @{'key'='1'} -AzureHybridBenefit 'True' -AcceptEULA +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +Using [-AcceptEULA] will default to your acceptance of the terms of our legal agreement and update a ConnectedKubernetes's AzureHybridBenefit. + +## PARAMETERS + +### -AcceptEULA +Accept EULA of ConnectedKubernetes, legal term will pop up without this parameter provided + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AzureHybridBenefit +Indicates whether Azure Hybrid Benefit is opted in + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Support.AzureHybridBenefit +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ClusterName +The name of the Kubernetes cluster on which get is called. + +```yaml +Type: System.String +Parameter Sets: UpdateExpanded +Aliases: Name + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Distribution +Represents the distribution of the connected cluster + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DistributionVersion +Represents the Kubernetes distribution version on this connected cluster. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.IConnectedKubernetesIdentity +Parameter Sets: UpdateViaIdentityExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. +The name is case insensitive. + +```yaml +Type: System.String +Parameter Sets: UpdateExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubscriptionId +The ID of the target subscription. + +```yaml +Type: System.String +Parameter Sets: UpdateExpanded +Aliases: + +Required: False +Position: Named +Default value: (Get-AzContext).Subscription.Id +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Resource tags. + +```yaml +Type: System.Collections.Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.IConnectedKubernetesIdentity + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.Api20221001Preview.IConnectedCluster + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +`INPUTOBJECT `: Identity Parameter + - `[ClusterName ]`: The name of the Kubernetes cluster on which get is called. + - `[Id ]`: Resource identity path + - `[ResourceGroupName ]`: The name of the resource group. The name is case insensitive. + - `[SubscriptionId ]`: The ID of the target subscription. + +## RELATED LINKS + diff --git a/src/ConnectedKubernetes/examples/New-AzConnectedKubernetes.md b/src/ConnectedKubernetes/examples/New-AzConnectedKubernetes.md index ee2c13280548..b6de62dd9825 100644 --- a/src/ConnectedKubernetes/examples/New-AzConnectedKubernetes.md +++ b/src/ConnectedKubernetes/examples/New-AzConnectedKubernetes.md @@ -51,4 +51,58 @@ Location Name ResourceGroupName eastus azps_test_cluster_ahb azps_test_group ``` -Using [-AcceptEULA] will default to your acceptance of the terms of our legal agreement and create a connected kubernetes. \ No newline at end of file +Using [-AcceptEULA] will default to your acceptance of the terms of our legal agreement and create a connected kubernetes. + +### Example 5: Create a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy and Proxy. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 -HttpProxy "http://proxy-user:proxy-password@proxy-ip:port" -HttpsProxy "http://proxy-user:proxy-password@proxy-ip:port" -NoProxy "localhost,127.0.0.0/8,192.168.0.0/16,172.17.0.0/16,10.96.0.0/12,10.244.0.0/16,10.43.0.0/24,.svc" -Proxy "http://proxy-user:proxy-password@proxy-ip:port" +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +This command creates a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy and Proxy. + +### Example 6: Create a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy, Proxy and ProxyCredential. +```powershell +$pwd = ConvertTo-SecureString "proxy-password" -AsPlainText -Force +$cred = New-Object System.Management.Automation.PSCredential ("proxy-user", $pwd) +New-AzConnectedKubernetes -ClusterName azps_test_cluster_ahb -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 -HttpProxy "http://proxy-user:proxy-password@proxy-ip:port" -HttpsProxy "http://proxy-user:proxy-password@proxy-ip:port" -NoProxy "localhost,127.0.0.0/8,192.168.0.0/16,172.17.0.0/16,10.96.0.0/12,10.244.0.0/16,10.43.0.0/24,.svc" -Proxy "http://proxy-ip:port" -ProxyCredential $cred +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster_ahb azps_test_group +``` + +This command creates a connected kubernetes with parameters HttpProxy, HttpsProxy, NoProxy, Proxy and ProxyCredential. + +### Example 7: Create a connected kubernetes and disable auto upgrade of arc agents. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus -DisableAutoUpgrade +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command creates a connected kubernetes and disable auto upgrade of arc agents. + +### Example 8: Create a connected kubernetes with custom onboarding timeout. +```powershell +New-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus -OnboardingTimeout 600 +``` + +```output +Location Name ResourceGroupName +-------- ---- ----------------- +eastus azps_test_cluster azps_test_group +``` + +This command creates a connected kubernetes with custom onboarding timeout. diff --git a/src/ConnectedKubernetes/test/AzConnectedKubernetes.Tests.ps1 b/src/ConnectedKubernetes/test/AzConnectedKubernetes.Tests.ps1 index fdfb3a487168..40893d06e0f5 100644 --- a/src/ConnectedKubernetes/test/AzConnectedKubernetes.Tests.ps1 +++ b/src/ConnectedKubernetes/test/AzConnectedKubernetes.Tests.ps1 @@ -18,7 +18,7 @@ Describe 'AzConnectedKubernetes' { $config.ProvisioningState | Should -Be 'Succeeded' # Clear helm azure-arc environment - helm delete azure-arc --no-hooks + helm delete azure-arc -n azure-arc-release --no-hooks } | Should -Not -Throw } diff --git a/src/ConnectedKubernetes/utils/RSAHelper.ps1 b/src/ConnectedKubernetes/utils/RSAHelper.ps1 index d02ec6d90d46..d163b6f26ccc 100644 --- a/src/ConnectedKubernetes/utils/RSAHelper.ps1 +++ b/src/ConnectedKubernetes/utils/RSAHelper.ps1 @@ -30,20 +30,7 @@ function ExportRSAPrivateKeyBase64{ $base64 = [Convert]::ToBase64String($stream.GetBuffer(), 0, ([int]($stream.Length))) - $offset = 0 - $line_length = 64 - - $sb = [System.Text.StringBuilder]::new() - [void]$sb.AppendLine("-----BEGIN RSA PRIVATE KEY-----") - while ($offset -lt $base64.Length) { - $line_end = [Math]::Min($offset + $line_length, $base64.Length) - [void]$sb.AppendLine($base64.Substring($offset, $line_end - $offset)) - $offset = $line_end - } - - [void]$sb.AppendLine("-----END RSA PRIVATE KEY-----") - - return $sb.ToString() + return $base64 } } @@ -58,7 +45,7 @@ function ExportRSAPublicKeyBase64{ [byte]$Sequence = 0x30 $stream = [System.IO.MemoryStream]::new() $writer = [System.IO.BinaryWriter]::new($stream) - $writer.Write($Sequence); # SEQUENCE + $writer.Write($Sequence); $innerStream = [System.IO.MemoryStream]::new() $innerWriter = [System.IO.BinaryWriter]::new($innerStream) EncodeIntegerBigEndian $innerWriter $RSAParams.Modulus @@ -70,18 +57,7 @@ function ExportRSAPublicKeyBase64{ $base64 = [Convert]::ToBase64String($stream.GetBuffer(), 0, ([int]($stream.Length))) - $offset = 0 - $line_length = 64 - - $sb = [System.Text.StringBuilder]::new() - - while ($offset -lt $base64.Length) { - $line_end = [Math]::Min($offset + $line_length, $base64.Length) - [void]$sb.AppendLine($base64.Substring($offset, $line_end - $offset)) - $offset = $line_end - } - - return $sb.ToString() + return $base64 } }