Preserve Disk space in ImageStore for Service Fabric Managed Clusters
As mentioned in this article: Service Fabric: Best Practices to preserve disk space in Image Store ImageStore keeps copied packages and provisioned packages.
In this article, we will discuss how can you configure cleaning up the copied application package for Service Fabric Managed Cluster ‘SFMC’.
The mitigation is to set “AllowRuntimeCleanupUnusedApplicationTypesPolicy“: “true“.
For properties, specify the following tags:
…
“applicationTypeVersionsCleanupPolicy”: {
“maxUnusedVersionsToKeep”: 3
}
Let me show you a step-by-step guide to automatically remove the unwanted application versions in your Service Fabric Managed cluster below:
Scenario:
– I have deployed 4 versions of my app (1 InUse – 3 UnUsed) to my managed cluster as the following:
Symptom:
I need Service Fabric to do automatic cleanup for the Application Unused Versions and keep only the last 3 so as not to fill the disk space.
Mitigation Steps:
From https://resources.azure.com/ open your managed cluster resource and open the read/write mode.
Add the tag “AllowRuntimeCleanupUnusedApplicationTypesPolicy“: “true“
Under fabricsettings, add the param “name”: “CleanupUnusedApplicationTypes”, “value”: “true” under fabricsettings and set the “maxUnusedVersionsToKeep”: 3
Click on PUT to save the changes, and I deployed the 5th version (1.0.4) to the cluster, which should make the cleaning happens for the oldest version (1.0.0)
Note: The automatic clean-up should be effective after 24 hours of making those changes.
Then I tried to deploy a new version, and I could see that the oldest version was also cleaned up.
For manual cleanup of the ImageStoreService:
You can use PowerShell commands to delete copied packages and unregister application types as needed.
This includes using Get-ServiceFabricImageStoreContent to retrieve content and Remove-ServiceFabricApplicationPackage to delete it, as well as Unregister-ServiceFabricApplicationType to remove application packages from the image store and image cache on nodes.
Microsoft Tech Community – Latest Blogs –Read More