Open wbuchwalter opened 7 years ago
@wbuchwalter how could I check these deployments? Is there a way to clean them manually?
We're using the following powershell code in Azure Automation:
(
[Parameter(Mandatory=$true)][String]$clusterResourceGroup,
[Parameter(Mandatory=$true)][Int]$daysToKeep
)
write-output "starting..."
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID `
-ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$ResourceGroup = Get-AzureRmResourceGroup -Name $clusterResourceGroup
$daysToClean = $daysToKeep * (-1)
$AllDeployments = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroup.ResourceGroupName) | Where-Object { ($_.Timestamp -lt (Get-Date).AddDays($daysToClean)) -and $_.DeploymentName.StartsWith("autoscaler") }
Write-output "Removing $($AllDeployments.count) deployments from $clusterResourceGroup"
foreach($deployment in $AllDeployments)
{
Remove-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroup.ResourceGroupName -Name $deployment.DeploymentName -force
Write-output "Removed deployment $($deployment.DeploymentName)"
}
Thanks! I’ll port it to bash I guess though.
El El mar, ene. 16, 2018 a las 2:48 a. m., oryagel notifications@github.com escribió:
We're using the following powershell code in Azure Automation:
( [Parameter(Mandatory=$true)][String]$clusterResourceGroup, [Parameter(Mandatory=$true)][Int]$daysToKeep ) write-output "starting..." $Conn = Get-AutomationConnection -Name AzureRunAsConnection Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID ` -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$ResourceGroup = Get-AzureRmResourceGroup -Name $clusterResourceGroup $daysToClean = $daysToKeep * (-1) $AllDeployments = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroup.ResourceGroupName) | Where-Object { ($.Timestamp -lt (Get-Date).AddDays($daysToClean)) -and $.DeploymentName.StartsWith("autoscaler") }
Write-output "Removing $($AllDeployments.count) deployments from $clusterResourceGroup" foreach($deployment in $AllDeployments) { Remove-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroup.ResourceGroupName -Name $deployment.DeploymentName -force Write-output "Removed deployment $($deployment.DeploymentName)" }```
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler/issues/63#issuecomment-357860180, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKvqJ-ctCQJHWNMDOB8hGMWu5Z9PNzaks5tLDg4gaJpZM4QNBEQ .
The autoscaler should either always use the same deployment name, or clean older deployments at some point.