or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

agent-pools.mdindex.mdmachines.mdmaintenance.mdmanaged-clusters.mdmodels.mdprivate-endpoints.mdsnapshots.mdtrusted-access.md

managed-clusters.mddocs/

0

# Managed Cluster Operations

1

2

Core AKS cluster management operations including creation, updates, scaling, credential rotation, and deletion. The ManagedClustersOperations class provides comprehensive cluster lifecycle management with support for advanced networking, security, and monitoring configurations.

3

4

## Capabilities

5

6

### Cluster Retrieval

7

8

Get information about existing AKS clusters, including their configuration, status, and properties.

9

10

```python { .api }

11

def get(

12

resource_group_name: str,

13

resource_name: str,

14

**kwargs

15

) -> ManagedCluster:

16

"""

17

Get the specified managed cluster.

18

19

Parameters:

20

- resource_group_name (str): The name of the resource group

21

- resource_name (str): The name of the managed cluster

22

23

Returns:

24

ManagedCluster: The managed cluster resource

25

26

Raises:

27

ResourceNotFoundError: If the cluster doesn't exist

28

"""

29

```

30

31

Usage example:

32

33

```python

34

from azure.mgmt.containerservice import ContainerServiceClient

35

from azure.identity import DefaultAzureCredential

36

37

client = ContainerServiceClient(DefaultAzureCredential(), "subscription-id")

38

cluster = client.managed_clusters.get("my-rg", "my-cluster")

39

print(f"Cluster location: {cluster.location}")

40

print(f"Kubernetes version: {cluster.kubernetes_version}")

41

print(f"Node count: {len(cluster.agent_pool_profiles)}")

42

```

43

44

### Cluster Creation and Updates

45

46

Create new AKS clusters or update existing ones with comprehensive configuration options.

47

48

```python { .api }

49

def begin_create_or_update(

50

resource_group_name: str,

51

resource_name: str,

52

parameters: ManagedCluster,

53

**kwargs

54

) -> LROPoller[ManagedCluster]:

55

"""

56

Create or update a managed cluster.

57

58

Parameters:

59

- resource_group_name (str): The name of the resource group

60

- resource_name (str): The name of the managed cluster

61

- parameters (ManagedCluster): The cluster specification

62

63

Returns:

64

LROPoller[ManagedCluster]: Long-running operation poller

65

"""

66

```

67

68

Usage example:

69

70

```python

71

from azure.mgmt.containerservice.models import (

72

ManagedCluster,

73

ManagedClusterAgentPoolProfile,

74

ContainerServiceLinuxProfile,

75

ContainerServiceSshConfiguration,

76

ContainerServiceSshPublicKey,

77

ManagedClusterIdentity

78

)

79

80

# Create cluster configuration

81

cluster_config = ManagedCluster(

82

location="East US",

83

kubernetes_version="1.28.3",

84

dns_prefix="my-cluster",

85

agent_pool_profiles=[

86

ManagedClusterAgentPoolProfile(

87

name="system",

88

count=3,

89

vm_size="Standard_D2s_v3",

90

os_type="Linux",

91

mode="System"

92

)

93

],

94

linux_profile=ContainerServiceLinuxProfile(

95

admin_username="azureuser",

96

ssh=ContainerServiceSshConfiguration(

97

public_keys=[

98

ContainerServiceSshPublicKey(key_data="ssh-rsa AAAA...")

99

]

100

)

101

),

102

identity=ManagedClusterIdentity(type="SystemAssigned")

103

)

104

105

# Create cluster (async operation)

106

operation = client.managed_clusters.create_or_update("my-rg", "my-cluster", cluster_config)

107

cluster = operation.result() # Wait for completion

108

print(f"Cluster created: {cluster.name}")

109

```

110

111

### Cluster Listing

112

113

List managed clusters across resource groups or subscriptions.

114

115

```python { .api }

116

def list(resource_group_name: str = None, **kwargs) -> ItemPaged[ManagedCluster]:

117

"""

118

Get a list of managed clusters in the specified subscription.

119

120

Parameters:

121

- resource_group_name (str, optional): Scope to specific resource group

122

123

Returns:

124

ItemPaged[ManagedCluster]: Paginated list of clusters

125

"""

126

127

def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[ManagedCluster]:

128

"""

129

List managed clusters in the specified resource group.

130

131

Parameters:

132

- resource_group_name (str): The name of the resource group

133

134

Returns:

135

ItemPaged[ManagedCluster]: Paginated list of clusters

136

"""

137

```

138

139

### Cluster Deletion

140

141

Delete AKS clusters with proper cleanup of associated resources.

142

143

```python { .api }

144

def begin_delete(

145

resource_group_name: str,

146

resource_name: str,

147

ignore_pod_disruption_budget: bool = None,

148

**kwargs

149

) -> LROPoller[None]:

150

"""

151

Delete a managed cluster.

152

153

Parameters:

154

- resource_group_name (str): The name of the resource group

155

- resource_name (str): The name of the managed cluster

156

- ignore_pod_disruption_budget (bool): Ignore PodDisruptionBudget during deletion

157

158

Returns:

159

LROPoller[None]: Long-running operation poller

160

"""

161

```

162

163

### Credential Operations

164

165

Manage cluster credentials and access keys.

166

167

```python { .api }

168

def list_cluster_admin_credentials(

169

resource_group_name: str,

170

resource_name: str,

171

server_fqdn: str = None,

172

**kwargs

173

) -> CredentialResults:

174

"""

175

Get cluster admin credentials.

176

177

Parameters:

178

- resource_group_name (str): The name of the resource group

179

- resource_name (str): The name of the managed cluster

180

- server_fqdn (str): The server FQDN

181

182

Returns:

183

CredentialResults: Cluster admin credentials

184

"""

185

186

def list_cluster_user_credentials(

187

resource_group_name: str,

188

resource_name: str,

189

server_fqdn: str = None,

190

format: str = None,

191

**kwargs

192

) -> CredentialResults:

193

"""

194

Get cluster user credentials.

195

196

Parameters:

197

- resource_group_name (str): The name of the resource group

198

- resource_name (str): The name of the managed cluster

199

- server_fqdn (str): The server FQDN

200

- format (str): Credential format (azure, exec)

201

202

Returns:

203

CredentialResults: Cluster user credentials

204

"""

205

```

206

207

### Cluster Operations

208

209

Additional cluster management operations including start, stop, and reset.

210

211

```python { .api }

212

def start(

213

resource_group_name: str,

214

resource_name: str,

215

**kwargs

216

) -> LROPoller[None]:

217

"""

218

Start a previously stopped managed cluster.

219

220

Parameters:

221

- resource_group_name (str): The name of the resource group

222

- resource_name (str): The name of the managed cluster

223

224

Returns:

225

LROPoller[None]: Long-running operation poller

226

"""

227

228

def stop(

229

resource_group_name: str,

230

resource_name: str,

231

**kwargs

232

) -> LROPoller[None]:

233

"""

234

Stop a running managed cluster.

235

236

Parameters:

237

- resource_group_name (str): The name of the resource group

238

- resource_name (str): The name of the managed cluster

239

240

Returns:

241

LROPoller[None]: Long-running operation poller

242

"""

243

244

def rotate_cluster_certificates(

245

resource_group_name: str,

246

resource_name: str,

247

**kwargs

248

) -> LROPoller[None]:

249

"""

250

Rotate cluster certificates.

251

252

Parameters:

253

- resource_group_name (str): The name of the resource group

254

- resource_name (str): The name of the managed cluster

255

256

Returns:

257

LROPoller[None]: Long-running operation poller

258

"""

259

```

260

261

## Types

262

263

### ManagedCluster

264

265

```python { .api }

266

class ManagedCluster:

267

"""

268

Managed cluster resource.

269

270

Attributes:

271

- location (str): Resource location

272

- kubernetes_version (str): Kubernetes version

273

- dns_prefix (str): DNS name prefix

274

- fqdn (str): FQDN for the master pool

275

- agent_pool_profiles (List[ManagedClusterAgentPoolProfile]): Agent pool profiles

276

- linux_profile (ContainerServiceLinuxProfile): Linux VM configuration

277

- windows_profile (ManagedClusterWindowsProfile): Windows VM configuration

278

- service_principal_profile (ManagedClusterServicePrincipalProfile): Service principal

279

- addon_profiles (Dict[str, ManagedClusterAddonProfile]): Addon profiles

280

- node_resource_group (str): Node resource group name

281

- enable_rbac (bool): Enable Kubernetes RBAC

282

- network_profile (ContainerServiceNetworkProfile): Network configuration

283

- aad_profile (ManagedClusterAADProfile): AAD integration configuration

284

- auto_upgrade_profile (ManagedClusterAutoUpgradeProfile): Auto-upgrade settings

285

- identity (ManagedClusterIdentity): Cluster identity configuration

286

- provisioning_state (str): Provisioning state

287

- power_state (PowerState): Current power state

288

- api_server_access_profile (ManagedClusterAPIServerAccessProfile): API server access

289

"""

290

```

291

292

## Async Operations

293

294

All operations have async equivalents in the `aio` module:

295

296

```python

297

from azure.mgmt.containerservice.aio import ContainerServiceClient

298

299

async with ContainerServiceClient(credential, subscription_id) as client:

300

cluster = await client.managed_clusters.get("my-rg", "my-cluster")

301

302

# Long-running operations return async pollers

303

operation = await client.managed_clusters.begin_create_or_update("my-rg", "my-cluster", cluster_config)

304

result = await operation.result()

305

```