在Service Fabric中取消预配旧应用程序类型版本的策略 [英] Strategy to unprovision old applicationtype versions in Service Fabric

查看:71
本文介绍了在Service Fabric中取消预配旧应用程序类型版本的策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在集群上设置某种配置以删除服务结构应用程序类型的版本?喜欢只保留最近5个版本还是什么?

Is there a way to set some sort of configuration on the cluster to remove service fabric application type versions? Like only keep the last 5 versions or something?

例如,我有CI/CD将新版本的Service Fabric应用程序部署到我们的集群中,这在集群中留下了许多应用程序版本类型.有没有一种方法可以随着时间的推移自动取消设置它们或仅保留一定数量的版本?

For example i have CI/CD deploying new versions of a service fabric app to our cluster, it leaves a bunch of application version types in the cluster. Is there a way to automatically unprovision them over time or only keep a certain number of versions?

推荐答案

有两个选择让我大吃一惊-

There are two options that cross my mind -

  • 在执行Deploy-FabricApplication.ps1时指定 UnregisterUnusedApplicationVersionsAfterUpgrade = $ true .此参数指示是否注销升级完成后存在的任何未使用的应用程序版本.

  • Specify UnregisterUnusedApplicationVersionsAfterUpgrade = $true when you execute Deploy-FabricApplication.ps1. This parameter indicates whether to unregister any unused application versions that exist after an upgrade is finished.

将自定义脚本添加到您的发行版定义,部署脚本或任何您想要的位置中,它将解析所有已部署的应用程序类型,并取消设置您认为过时的那些类型.这是命令 您将需要使用- Unregister-ServiceFabricApplicationType .这是一些脚本示例,该脚本注销所有正在运行的应用程序类型以外的所有应用程序类型-

Add custom script into your release defintion, deployment script or whereever you want that will resolve all the deployed app types and unprovision those ones that you think are obsolete. Here is the command that you will need to use - Unregister-ServiceFabricApplicationType. Here is some example of the script that unregisters all the app types except running ones -

#resolve all app types
$appTypes = Get-ServiceFabricApplicationType
foreach($appType in $appTypes)
{
   #try to find the match with any of installed applications
   $match = Get-ServiceFabricApplication -ApplicationTypeName $appType.ApplicationTypeName | Where-Object {$_.ApplicationTypeVersion -eq $appType.ApplicationTypeVersion}
   if(!$match)
   {
       Write-Host "Deleting $($appType.ApplicationTypeName) $($appType.ApplicationTypeVersion)"
       Unregister-ServiceFabricApplicationType -ApplicationTypeName $appType.ApplicationTypeName -ApplicationTypeVersion $appType.ApplicationTypeVersion -Force -Confirm
   }    
}

这篇关于在Service Fabric中取消预配旧应用程序类型版本的策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆