You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/aks/image-cleaner.md
+56-6Lines changed: 56 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@ ms.author: nickoman
5
5
author: nickomang
6
6
services: container-service
7
7
ms.topic: article
8
-
ms.date: 12/14/2022
8
+
ms.date: 02/03/2023
9
9
---
10
10
11
11
# Use Image Cleaner to clean up stale images on your Azure Kubernetes Service cluster (preview)
12
12
13
-
It's common to use pipelines to build and deploy images on Azure Kubernetes Service (AKS) clusters. While great for image creation, this process often doesn't account for the stale images left behind and can lead to image bloat on cluster nodes. These images can present security issues as they may contain vulnerabilities. By cleaning these unreferenced images, you can remove an area of risk in your clusters. When done manually, this process can be time intensive, which Image Cleaner can mitigate via automatic image identification and removal.
13
+
It's common to use pipelines to build and deploy images on Azure Kubernetes Service (AKS) clusters. While great for image creation, this process often doesn't account for the stale images left behind and can lead to image bloat on cluster nodes. These images can present security issues as they may contain vulnerabilities. By cleaning these unreferenced images, you can remove an area of risk in your clusters. When done manually, this process can be time intensive, which Image Cleaner can mitigate via automatic image identification and removal.
14
14
15
15
> [!NOTE]
16
-
> Image Cleaner is a feature based on [Eraser](https://github.com/Azure/eraser).
16
+
> Image Cleaner is a feature based on [Eraser](https://github.com/Azure/eraser).
17
17
> On an AKS cluster, the feature name and property name is `Image Cleaner` while the relevant Image Cleaner pods' names contain `Eraser`.
18
18
19
19
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
@@ -92,8 +92,7 @@ When enabled, an `eraser-controller-manager` pod is deployed on each agent node,
92
92
93
93
Once an `ImageList` is generated, Image Cleaner will remove all the images in the list from node VMs.
94
94
95
-
96
-
:::image type="content" source="./media/image-cleaner/image-cleaner.jpg" alt-text="A diagram showing ImageCleaner's workflow. The ImageCleaner pods running on the cluster can generate an ImageList, or manual input can be provided.":::
95
+
:::image type="content" source="./media/image-cleaner/image-cleaner.jpg" alt-text="Screenshot of a diagram showing ImageCleaner's workflow. The ImageCleaner pods running on the cluster can generate an ImageList, or manual input can be provided.":::
97
96
98
97
## Configuration options
99
98
@@ -167,7 +166,58 @@ az aks update -g MyResourceGroup -n MyManagedCluster
167
166
168
167
## Logging
169
168
170
-
The deletion logs are stored in the `image-cleaner-kind-worker` pods. You can check these via `kubectl logs` or via the Container Insights pod log table if the [Azure Monitor add-on](./monitor-aks.md) is enabled.
169
+
Deletion image logs are stored in `eraser-aks-nodepool-xxx` pods for manually deleted images, and in `eraser-collector-xxx` pods for automatically deleted images.
170
+
171
+
You can view these logs by running `kubectl logs <pod name> -n kubesystem`. However, this command may return only the most recent logs, since older logs are routinely deleted. To view all logs, follow these steps to enable the [Azure Monitor add-on](./monitor-aks.md) and use the Container Insights pod log table.
172
+
173
+
1. Ensure that Azure monitoring is enabled on the cluster. For detailed steps, see [Enable Container Insights for AKS cluster](../azure-monitor/containers/container-insights-enable-aks.md#existing-aks-cluster).
174
+
175
+
1. Get the Log Analytics resource ID:
176
+
177
+
```azurecli
178
+
az aks show -g <resourceGroupofAKSCluster> -n <nameofAksCluster>
179
+
```
180
+
181
+
After a few minutes, the command returns JSON-formatted information about the solution, including the workspace resource ID:
1. In the Azure portal, search for the workspace resource ID, then select **Logs**.
195
+
196
+
1. Copy this query into the table, replacing `name` with either `eraser-aks-nodepool-xxx` (for manual mode) or `eraser-collector-xxx` (for automatic mode).
197
+
198
+
```kusto
199
+
let startTimestamp = ago(1h);
200
+
KubePodInventory
201
+
| where TimeGenerated > startTimestamp
202
+
| project ContainerID, PodName=Name, Namespace
203
+
| where PodName contains "name" and Namespace startswith "kube-system"
204
+
| distinct ContainerID, PodName
205
+
| join
206
+
(
207
+
ContainerLog
208
+
| where TimeGenerated > startTimestamp
209
+
)
210
+
on ContainerID
211
+
// at this point before the next pipe, columns from both tables are available to be "projected". Due to both
212
+
// tables having a "Name" column, we assign an alias as PodName to one column which we actually want
0 commit comments