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
@@ -4,15 +4,14 @@ titleSuffix: Azure Kubernetes Service
4
4
description: Learn how to use Planned Maintenance in Azure Kubernetes Service (AKS).
5
5
services: container-service
6
6
ms.topic: article
7
-
ms.date: 03/03/2021
7
+
ms.date: 01/17/2023
8
8
ms.author: qpetraroia
9
9
author: qpetraroia
10
-
11
10
---
12
11
13
12
# Use Planned Maintenance to schedule maintenance windows for your Azure Kubernetes Service (AKS) cluster (preview)
14
13
15
-
Your AKS cluster has regular maintenance performed on it automatically. By default, this work can happen at any time. Planned Maintenance allows you to schedule weekly maintenance windows that will update your control plane as well as your kube-system pods on a VMSS instance, and minimize workload impact. Once scheduled, all your maintenance will occur during the window you selected. You can schedule one or more weekly windows on your cluster by specifying a day or time range on a specific day. Maintenance Windows are configured using the Azure CLI.
14
+
Your AKS cluster has regular maintenance performed on it automatically. By default, this work can happen at any time. Planned Maintenance allows you to schedule weekly maintenance windows to perform updates and minimize workload impact. Once scheduled, maintenance will occur only during the window you selected.
16
15
17
16
## Before you begin
18
17
@@ -30,7 +29,7 @@ When you use Planned Maintenance, the following restrictions apply:
30
29
31
30
### Install aks-preview CLI extension
32
31
33
-
You also need the *aks-preview* Azure CLI extension version 0.5.4 or later. Install the *aks-preview* Azure CLI extension by using the [az extension add][az-extension-add] command. Or install any available updates by using the [az extension update][az-extension-update] command.
32
+
You also need the *aks-preview* Azure CLI extension version 0.5.124 or later. Install the *aks-preview* Azure CLI extension by using the [az extension add][az-extension-add] command. Or install any available updates by using the [az extension update][az-extension-update] command.
34
33
35
34
```azurecli-interactive
36
35
# Install the aks-preview extension
@@ -40,163 +39,237 @@ az extension add --name aks-preview
40
39
az extension update --name aks-preview
41
40
```
42
41
43
-
## Allow maintenance on every Monday at 1:00am to 2:00am
There are currently two available configuration types: `default` and `aksManagedAutoUpgradeSchedule`:
45
+
46
+
-`default` corresponds to a basic configuration that will update your control plane and your kube-system pods on a virtual machine scale sets instance. It is a legacy configuration that is mostly suitable for basic scheduling of [weekly releases][release-tracker].
47
+
48
+
-`aksManagedAutoUpgradeSchedule` is a more complex configuration that controls when upgrades scheduled by your designated auto-upgrade channel are performed. More finely controlled cadence and recurrence settings are possible. For more information on cluster auto-upgrade, see [Automatically an Azure Kubernetes Service (AKS) cluster][aks-upgrade].
49
+
50
+
### Choosing between configuration types
51
+
52
+
We recommend using `aksManagedAutoUpgradeSchedule` for all maintenance and upgrade scenarios, while `default` is meant exclusively for weekly releases. You can port `default` configurations to `aksManagedAutoUpgradeSchedule` configurations via the `az aks maintenanceconfiguration update` command.
53
+
54
+
> [!NOTE]
55
+
> When using auto-upgrade, to ensure proper functionality, use a maintenance window with a duration of four hours or more.
56
+
57
+
## Creating a maintenance window
58
+
59
+
To create a maintenance window, you can use the `az aks maintenanceconfiguration add` command using the `--name` value `default` or `aksManagedAutoUpgradeSchedule`. The name value should reflect the desired configuration type. Using any other name will cause your maintenance window not to run.
60
+
61
+
Planned Maintenance windows are specified in Coordinated Universal Time (UTC).
62
+
63
+
A `default` maintenance window has the following properties:
44
64
45
-
To add a maintenance window, you can use the `az aks maintenanceconfiguration add` command.
65
+
|Name|Description|Default value|
66
+
|--|--|--|
67
+
|`timeInWeek`|In a `default` configuration, this property contains the `day` and `hourSlots` values defining a maintenance window|N/A|
68
+
|`timeInWeek.day`|The day of the week to perform maintenance in a `default` configuration|N/A|
69
+
|`timeInWeek.hourSlots`|A list of hour-long time slots to perform maintenance on a given day in a `default` configuration|N/A|
70
+
|`notAllowedTime`|Specifies a range of dates that maintenance cannot run, determined by `start` and `end` child properties. Only applicable when creating the maintenance window using a config file|N/A|
71
+
72
+
An `aksManagedAutoUpgradeSchedule` has the following properties:
73
+
74
+
|Name|Description|Default value|
75
+
|--|--|--|
76
+
|`utcOffset`|Used to determine the timezone for cluster maintenance|`+00:00`|
77
+
|`startDate`|The date on which the maintenance window will begin to take effect|The current date at creation time|
78
+
|`startTime`|The time for maintenance to begin, based on the timezone determined by `utcOffset`|N/A|
79
+
|`schedule`|Used to determine frequency. Three types are available: `Weekly`, `AbsoluteMonthly`, and `RelativeMonthly`|N/A|
80
+
|`intervalWeeks`|The interval in weeks for maintenance runs|N/A|
81
+
|`intervalMonths`|The interval in months for maintenance runs|N/A|
82
+
|`dayOfWeek`|The specified day of the week for maintenance to begin|N/A|
83
+
|`durationHours`|The duration of the window for maintenance to run|N/A|
84
+
|`notAllowedDates`|Specifies a range of dates that maintenance cannot run, determined by `start` and `end` child properties. Only applicable when creating the maintenance window using a config file|N/A|
85
+
86
+
### Understanding schedule types
87
+
88
+
There are currently three available schedule types: `Weekly`, `AbsoluteMonthly`, and `RelativeMonthly`. These schedule types are only applicable to `aksManagedClusterAutoUpgrade` configurations.
89
+
90
+
#### Weekly schedule
91
+
92
+
A `Weekly` schedule may look like *"every two weeks on Friday"*:
93
+
94
+
```json
95
+
"schedule": {
96
+
"weekly": {
97
+
"intervalWeeks": 2,
98
+
"dayOfWeek": "Friday"
99
+
}
100
+
}
101
+
```
46
102
47
-
> [!IMPORTANT]
48
-
> At this time, you must set `default` as the value for `--name`. Using any other name will cause your maintenance window to not run.
49
-
>
50
-
> Planned Maintenance windows are specified in Coordinated Universal Time (UTC).
103
+
#### AbsoluteMonthly schedule
104
+
105
+
An `AbsoluteMonthly` schedule may look like *"every three months, on the first day of the month"*:
106
+
107
+
```json
108
+
"schedule": {
109
+
"absoluteMonthly": {
110
+
"intervalMonths": 3,
111
+
"dayOfMonth": 1
112
+
}
113
+
}
114
+
```
115
+
116
+
#### RelativeMonthly schedule
117
+
118
+
A `RelativeMonthly` schedule may look like *"every two months, on the last Monday"*:
119
+
120
+
```json
121
+
"schedule": {
122
+
"relativeMonthly": {
123
+
"intervalMonths": 2,
124
+
"dayOfWeek": "Monday",
125
+
"weekIndex": "Last"
126
+
}
127
+
}
128
+
```
129
+
130
+
## Add a maintenance window configuration with Azure CLI
131
+
132
+
The following example shows a command to add a new `default` configuration that schedules maintenance to run from 1:00am to 2:00am every Monday:
51
133
52
134
```azurecli-interactive
53
-
az aks maintenanceconfiguration add -g MyResourceGroup --cluster-name myAKSCluster --name default --weekday Monday --start-hour 1
135
+
az aks maintenanceconfiguration add -g myResourceGroup --cluster-name myAKSCluster --name default --weekday Monday --start-hour 1
54
136
```
55
137
56
-
The following example output shows the maintenance window from 1:00am to 2:00am every Monday.
138
+
> [!NOTE]
139
+
> When using a `default` configuration type, to allow maintenance anytime during a day omit the `--start-time` parameter.
140
+
141
+
The following example shows a command to add a new `aksManagedAutoUpgradeSchedule` configuration that schedules maintenance to run every third Friday between 12:00 AM and 8:00 AM in the `UTC+5:30` timezone:
## Add a maintenance window configuration with a JSON file
148
+
149
+
You can also use a JSON file create a maintenance configuration instead of using parameters. This method has the added benefit of allowing maintenance to be prevented during a range of dates, specified by `notAllowedTimes` for `default` configurations and `notAllowedDates` for `aksManagedAutoUpgradeSchedule` configurations.
150
+
151
+
Create a `default.json` file with the following contents:
To allow maintenance anytime during a day, omit the *start-hour* parameter. For example, the following command sets the maintenance window for the full day every Monday:
78
-
79
-
```azurecli-interactive
80
-
az aks maintenanceconfiguration add -g MyResourceGroup --cluster-name myAKSCluster --name default --weekday Monday
81
-
```
82
-
83
-
## Add a maintenance configuration with a JSON file
180
+
The above JSON file specifies maintenance windows every Tuesday at 1:00am - 3:00am and every Wednesday at 1:00am - 2:00am and at 6:00am - 7:00am in the `UTC` timezone. There is also an exception from *2021-05-26T03:00:00Z* to *2021-05-30T12:00:00Z* where maintenance isn't allowed even if it overlaps with a maintenance window.
84
181
85
-
You can also use a JSON file create a maintenance window instead of using parameters. Create a `test.json` file with the following contents:
182
+
Create an `autoUpgradeWindow.json` file with the following contents:
86
183
87
184
```json
88
-
{
89
-
"timeInWeek": [
90
-
{
91
-
"day": "Tuesday",
92
-
"hour_slots": [
93
-
1,
94
-
2
95
-
]
96
-
},
97
-
{
98
-
"day": "Wednesday",
99
-
"hour_slots": [
100
-
1,
101
-
6
102
-
]
103
-
}
104
-
],
105
-
"notAllowedTime": [
106
-
{
107
-
"start": "2021-05-26T03:00:00Z",
108
-
"end": "2021-05-30T12:00:00Z"
109
-
}
185
+
{
186
+
"properties": {
187
+
"maintenanceWindow": {
188
+
"schedule": {
189
+
"absoluteMonthly": {
190
+
"intervalMonths": 3,
191
+
"dayOfMonth": 1
192
+
}
193
+
},
194
+
"durationHours": 4,
195
+
"utcOffset": "-08:00",
196
+
"startTime": "09:00",
197
+
"notAllowedDates": [
198
+
{
199
+
"start": "2023-12-23",
200
+
"end": "2024-01-05"
201
+
}
110
202
]
203
+
}
204
+
}
111
205
}
112
206
```
113
207
114
-
The above JSON file specifies maintenance windows every Tuesday at 1:00am - 3:00am and every Wednesday at 1:00am - 2:00am and at 6:00am - 7:00am. There is also an exception from *2021-05-26T03:00:00Z* to *2021-05-30T12:00:00Z* where maintenance isn't allowed even if it overlaps with a maintenance window. The following command adds the maintenance windows from `test.json`.
208
+
The above JSON file specifies maintenance windows every three months on the first of the month between 9:00 AM - 1:00 PM in the `UTC-08` timezone. There is also an exception from *2023-12-23* to *2024-01-05* where maintenance isn't allowed even if it overlaps with a maintenance window.
209
+
210
+
The following command adds the maintenance windows from `default.json` and `autoUpgradeWindow.json`:
115
211
116
212
```azurecli-interactive
117
-
az aks maintenanceconfiguration add -g MyResourceGroup --cluster-name myAKSCluster --name default --config-file ./test.json
213
+
az aks maintenanceconfiguration add -g myResourceGroup --cluster-name myAKSCluster --name default --config-file ./test.json
214
+
215
+
az aks maintenanceconfiguration add -g myResourceGroup --cluster-name myAKSCluster --name aksManagedAutoUpgradeSchedule --config-file ./autoUpgradeWindow.json
118
216
```
119
217
120
218
## Update an existing maintenance window
121
219
122
220
To update an existing maintenance configuration, use the `az aks maintenanceconfiguration update` command.
123
221
124
222
```azurecli-interactive
125
-
az aks maintenanceconfiguration update -g MyResourceGroup --cluster-name myAKSCluster --name default --weekday Monday --start-hour 1
223
+
az aks maintenanceconfiguration update -g myResourceGroup --cluster-name myAKSCluster --name default --weekday Monday --start-hour 2
126
224
```
127
225
128
226
## List all maintenance windows in an existing cluster
129
227
130
228
To see all current maintenance configuration windows in your AKS cluster, use the `az aks maintenanceconfiguration list` command.
131
229
132
230
```azurecli-interactive
133
-
az aks maintenanceconfiguration list -g MyResourceGroup --cluster-name myAKSCluster
134
-
```
135
-
136
-
In the output below, you can see that there are two maintenance windows configured for myAKSCluster. One window is on Mondays at 1:00am and another window is on Friday at 4:00am.
@@ -206,16 +279,9 @@ The following example output shows the maintenance window for *default*:
206
279
To delete a certain maintenance configuration window in your AKS Cluster, use the `az aks maintenanceconfiguration delete` command.
207
280
208
281
```azurecli-interactive
209
-
az aks maintenanceconfiguration delete -g MyResourceGroup --cluster-name myAKSCluster --name default
282
+
az aks maintenanceconfiguration delete -g MyResourceGroup --cluster-name myAKSCluster --name autoUpgradeSchedule
210
283
```
211
284
212
-
## Using Planned Maintenance with Cluster Auto-Upgrade
213
-
214
-
Planned Maintenance will detect if you are using Cluster Auto-Upgrade and schedule your upgrades during your maintenance window automatically. For more details on about Cluster Auto-Upgrade, see [Upgrade an Azure Kubernetes Service (AKS) cluster][aks-upgrade].
215
-
216
-
> [!NOTE]
217
-
> To ensure proper functionality, use a maintenance window of four hours or more.
218
-
219
285
## Next steps
220
286
221
287
- To get started with upgrading your AKS cluster, see [Upgrade an AKS cluster][aks-upgrade]
@@ -233,3 +299,5 @@ Planned Maintenance will detect if you are using Cluster Auto-Upgrade and schedu
0 commit comments