Creates or updates a managed cluster.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}?api-version=2023-08-01
Expand table
Name
In
Required
Type
Description
resourceGroupName
path
True
string
The name of the resource group. The name is case insensitive.
resourceName
path
True
string
The name of the managed cluster resource.
Regex pattern: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$
subscriptionId
path
True
string
The ID of the target subscription.
api-version
query
True
string
The API version to use for this operation.
Expand table
Name
Required
Type
Description
location
True
string
The geo-location where the resource lives
extendedLocation
ExtendedLocation
The extended location of the Virtual Machine.
identity
ManagedClusterIdentity
The identity of the managed cluster, if configured.
properties.aadProfile
ManagedClusterAADProfile
AADProfile specifies attributes for Azure Active Directory integration.
The Azure Active Directory configuration.
properties.addonProfiles
<string,
ManagedClusterAddonProfile >
The profile of managed cluster add-on.
properties.agentPoolProfiles
ManagedClusterAgentPoolProfile []
The agent pool properties.
properties.apiServerAccessProfile
ManagedClusterAPIServerAccessProfile
The access profile for managed cluster API server.
properties.autoScalerProfile
AutoScalerProfile
Parameters to be applied to the cluster-autoscaler when enabled
properties.autoUpgradeProfile
ManagedClusterAutoUpgradeProfile
The auto upgrade configuration.
properties.azureMonitorProfile
ManagedClusterAzureMonitorProfile
Azure Monitor addon profiles for monitoring the managed cluster.
properties.disableLocalAccounts
boolean
If local accounts should be disabled on the Managed Cluster.
If set to true, getting static credentials will be disabled for this cluster. This must only be used on Managed Clusters that are AAD enabled. For more details see disable local accounts .
properties.diskEncryptionSetID
string
The Resource ID of the disk encryption set to use for enabling encryption at rest.
This is of the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{encryptionSetName}'
properties.dnsPrefix
string
The DNS prefix of the Managed Cluster.
This cannot be updated once the Managed Cluster has been created.
properties.enablePodSecurityPolicy
boolean
(DEPRECATED) Whether to enable Kubernetes pod security policy (preview). PodSecurityPolicy was deprecated in Kubernetes v1.21, and removed from Kubernetes in v1.25. Learn more at https://aka.ms/k8s/psp and https://aka.ms/aks/psp .
properties.enableRBAC
boolean
Whether to enable Kubernetes Role-Based Access Control.
properties.fqdnSubdomain
string
The FQDN subdomain of the private cluster with custom private dns zone.
This cannot be updated once the Managed Cluster has been created.
properties.httpProxyConfig
ManagedClusterHTTPProxyConfig
Configurations for provisioning the cluster with HTTP proxy servers.
properties.identityProfile
<string,
UserAssignedIdentity >
Identities associated with the cluster.
properties.kubernetesVersion
string
The version of Kubernetes specified by the user.
Both patch version <major.minor.patch> (e.g. 1.20.13) and <major.minor> (e.g. 1.20) are supported. When <major.minor> is specified, the latest supported GA patch version is chosen automatically. Updating the cluster with the same <major.minor> once it has been created (e.g. 1.14.x -> 1.14) will not trigger an upgrade, even if a newer patch version is available. When you upgrade a supported AKS cluster, Kubernetes minor versions cannot be skipped. All upgrades must be performed sequentially by major version number. For example, upgrades between 1.14.x -> 1.15.x or 1.15.x -> 1.16.x are allowed, however 1.14.x -> 1.16.x is not allowed. See upgrading an AKS cluster for more details.
properties.linuxProfile
ContainerServiceLinuxProfile
The profile for Linux VMs in the Managed Cluster.
properties.networkProfile
ContainerServiceNetworkProfile
The network configuration profile.
properties.nodeResourceGroup
string
The name of the resource group containing agent pool nodes.
properties.oidcIssuerProfile
ManagedClusterOIDCIssuerProfile
The OIDC issuer profile of the Managed Cluster.
properties.podIdentityProfile
ManagedClusterPodIdentityProfile
The pod identity profile of the Managed Cluster.
See use AAD pod identity for more details on AAD pod identity integration.
properties.privateLinkResources
PrivateLinkResource []
Private link resources associated with the cluster.
properties.publicNetworkAccess
PublicNetworkAccess
PublicNetworkAccess of the managedCluster
Allow or deny public network access for AKS
properties.securityProfile
ManagedClusterSecurityProfile
Security profile for the managed cluster.
properties.serviceMeshProfile
ServiceMeshProfile
Service mesh profile for a managed cluster.
properties.servicePrincipalProfile
ManagedClusterServicePrincipalProfile
Information about a service principal identity for the cluster to use for manipulating Azure APIs.
properties.storageProfile
ManagedClusterStorageProfile
Storage profile for the managed cluster.
properties.supportPlan
KubernetesSupportPlan
The support plan for the Managed Cluster. If unspecified, the default is 'KubernetesOfficial'.
properties.upgradeSettings
ClusterUpgradeSettings
Settings for upgrading a cluster.
properties.windowsProfile
ManagedClusterWindowsProfile
The profile for Windows VMs in the Managed Cluster.
properties.workloadAutoScalerProfile
ManagedClusterWorkloadAutoScalerProfile
Workload Auto-scaler profile for the managed cluster.
sku
ManagedClusterSKU
The managed cluster SKU.
tags
object
Resource tags.
Expand table
Name
Type
Description
200 OK
ManagedCluster
The existing managed cluster was successfully updated.
201 Created
ManagedCluster
The new managed cluster was successfully created.
Other Status Codes
CloudError
Error response describing why the operation failed.
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Expand table
Name
Description
user_impersonation
impersonate your user account
Expand table
Create Managed Cluster using an agent pool snapshot
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableFIPS" : true,
"creationData" : {
"sourceResourceId" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
}
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : false
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.CreationData;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterUsingAnAgentPoolSnapshot (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableFips(true )
.withCreationData(
new CreationData()
.withSourceResourceId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1" ))
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(false )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_snapshot.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"creationData" : {
"sourceResourceId" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
},
"enableFIPS" : True ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : False ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterUsingAnAgentPoolSnapshot () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
CreationData: &armcontainerservice.CreationData{
SourceResourceID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1" ),
},
EnableFIPS: to.Ptr(true ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(false ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterUsingAnAgentPoolSnapshot ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
creationData : {
sourceResourceId :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1" ,
},
enableFips : true ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : false ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableFIPS" : true ,
"creationData" : {
"sourceResourceId" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
}
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : false ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableFIPS" : true ,
"creationData" : {
"sourceResourceId" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
}
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : false ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with AKS-managed NAT gateway as outbound type
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : false,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "managedNATGateway",
"natGatewayProfile" : {
"managedOutboundIPProfile" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterManagedOutboundIpProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterNatGatewayProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithAKSManagedNATGatewayAsOutboundType (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(false )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.MANAGED_NATGATEWAY)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withNatGatewayProfile(
new ManagedClusterNatGatewayProfile()
.withManagedOutboundIpProfile(
new ManagedClusterManagedOutboundIpProfile().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_managed_nat_gateway.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : False ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerSku" : "standard" ,
"natGatewayProfile" : {"managedOutboundIPProfile" : {"count" : 2 }},
"outboundType" : "managedNATGateway" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithAksManagedNatGatewayAsOutboundType () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(false ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
NatGatewayProfile: &armcontainerservice.ManagedClusterNATGatewayProfile{
ManagedOutboundIPProfile: &armcontainerservice.ManagedClusterManagedOutboundIPProfile{
Count: to.Ptr[int32 ](2 ),
},
},
OutboundType: to.Ptr(armcontainerservice.OutboundTypeManagedNATGateway),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithAksManagedNatGatewayAsOutboundType ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : false ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerSku : "standard" ,
natGatewayProfile : { managedOutboundIPProfile : { count : 2 } },
outboundType : "managedNATGateway" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : false ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "managedNATGateway" ,
"natGatewayProfile" : {
"idleTimeoutInMinutes" : 4 ,
"managedOutboundIPProfile" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : false ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "managedNATGateway" ,
"natGatewayProfile" : {
"idleTimeoutInMinutes" : 4 ,
"managedOutboundIPProfile" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with Azure KeyVault Secrets Provider Addon
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"enabled" : true,
"config" : {
"enableSecretRotation" : "true",
"rotationPollInterval" : "2m"
}
}
},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAddonProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithAzureKeyVaultSecretsProviderAddon (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(
mapOf(
"azureKeyvaultSecretsProvider" ,
new ManagedClusterAddonProfile()
.withEnabled(true )
.withConfig(
mapOf(
"enableSecretRotation" , "fakeTokenPlaceholder" , "rotationPollInterval" , "2m" ))))
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_azure_keyvault_secrets_provider.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"config" : {"enableSecretRotation" : "true" , "rotationPollInterval" : "2m" },
"enabled" : True ,
}
},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithAzureKeyVaultSecretsProviderAddon () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{
"azureKeyvaultSecretsProvider" : {
Config: map [string ]*string {
"enableSecretRotation" : to.Ptr("true" ),
"rotationPollInterval" : to.Ptr("2m" ),
},
Enabled: to.Ptr(true ),
},
},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithAzureKeyVaultSecretsProviderAddon ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {
azureKeyvaultSecretsProvider : {
config : { enableSecretRotation : "true" , rotationPollInterval : "2m" },
enabled : true ,
},
},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"enabled" : true ,
"config" : {
"enableSecretRotation" : "true" ,
"rotationPollInterval" : "2m"
}
}
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"enabled" : true ,
"config" : {
"enableSecretRotation" : "true" ,
"rotationPollInterval" : "2m"
}
}
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with Dedicated Host Group
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"hostGroupID" : "/subscriptions/subid1/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : false
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithDedicatedHostGroup (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withEnableNodePublicIp(true )
.withHostGroupId(
"/subscriptions/subid1/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1" )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(false )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_dedicated_host_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"hostGroupID" : "/subscriptions/subid1/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : False ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithDedicatedHostGroup () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
HostGroupID: to.Ptr("/subscriptions/subid1/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1" ),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(false ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithDedicatedHostGroup ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
hostGroupID :
"/subscriptions/subid1/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : false ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"hostGroupID" : "/subscriptions/subid1/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : false ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"hostGroupID" : "/subscriptions/subid1/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : false ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with EncryptionAtHost enabled
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithEncryptionAtHostEnabled (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableEncryptionAtHost(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_enable_encryption_at_host.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableEncryptionAtHost" : True ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithEncryptionAtHostEnabled () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableEncryptionAtHost: to.Ptr(true ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithEncryptionAtHostEnabled ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableEncryptionAtHost : true ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with FIPS enabled OS
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableFIPS" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : false
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithFIPSEnabledOS (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableFips(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(false )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_enabled_fips.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableFIPS" : True ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : False ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithFipsEnabledOs () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableFIPS: to.Ptr(true ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(false ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithFipsEnabledOS ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableFips : true ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : false ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableFIPS" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : false ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableFIPS" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : false ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with GPUMIG
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_ND96asr_v4",
"osType" : "Linux",
"gpuInstanceProfile" : "MIG3g",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true,
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080",
"httpsProxy" : "https://myproxy.server.com:8080",
"noProxy" : [
"localhost",
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.GpuInstanceProfile;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterHttpProxyConfig;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithGPUMIG (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_ND96asr_v4" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withGpuInstanceProfile(GpuInstanceProfile.MIG3G)
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" )
.withHttpProxyConfig(
new ManagedClusterHttpProxyConfig()
.withHttpProxy("http://myproxy.server.com:8080" )
.withHttpsProxy("https://myproxy.server.com:8080" )
.withNoProxy(Arrays.asList("localhost" , "127.0.0.1" ))
.withTrustedCa("Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" )),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_gpumig.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"gpuInstanceProfile" : "MIG3g" ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_ND96asr_v4" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : ["localhost" , "127.0.0.1" ],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ,
},
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithGpumig () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
GpuInstanceProfile: to.Ptr(armcontainerservice.GPUInstanceProfileMIG3G),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_ND96asr_v4" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
HTTPProxyConfig: &armcontainerservice.ManagedClusterHTTPProxyConfig{
HTTPProxy: to.Ptr("http://myproxy.server.com:8080" ),
HTTPSProxy: to.Ptr("https://myproxy.server.com:8080" ),
NoProxy: []*string {
to.Ptr("localhost" ),
to.Ptr("127.0.0.1" )},
TrustedCa: to.Ptr("Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ),
},
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithGpumig ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
gpuInstanceProfile : "MIG3g" ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_ND96asr_v4" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
httpProxyConfig : {
httpProxy : "http://myproxy.server.com:8080" ,
httpsProxy : "https://myproxy.server.com:8080" ,
noProxy : ["localhost" , "127.0.0.1" ],
trustedCa : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ,
},
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_ND96asr_v4" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"gpuInstanceProfile" : "MIG3g" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : [
"localhost" ,
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_ND96asr_v4" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"gpuInstanceProfile" : "MIG3g" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : [
"localhost" ,
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true,
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080",
"httpsProxy" : "https://myproxy.server.com:8080",
"noProxy" : [
"localhost",
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterHttpProxyConfig;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithHTTPProxyConfigured (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" )
.withHttpProxyConfig(
new ManagedClusterHttpProxyConfig()
.withHttpProxy("http://myproxy.server.com:8080" )
.withHttpsProxy("https://myproxy.server.com:8080" )
.withNoProxy(Arrays.asList("localhost" , "127.0.0.1" ))
.withTrustedCa("Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" )),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_httpproxy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : ["localhost" , "127.0.0.1" ],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ,
},
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithHttpProxyConfigured () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
HTTPProxyConfig: &armcontainerservice.ManagedClusterHTTPProxyConfig{
HTTPProxy: to.Ptr("http://myproxy.server.com:8080" ),
HTTPSProxy: to.Ptr("https://myproxy.server.com:8080" ),
NoProxy: []*string {
to.Ptr("localhost" ),
to.Ptr("127.0.0.1" )},
TrustedCa: to.Ptr("Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ),
},
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithHttpProxyConfigured ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
httpProxyConfig : {
httpProxy : "http://myproxy.server.com:8080" ,
httpsProxy : "https://myproxy.server.com:8080" ,
noProxy : ["localhost" , "127.0.0.1" ],
trustedCa : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ,
},
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : [
"localhost" ,
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : [
"localhost" ,
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
Create Managed Cluster with LongTermSupport
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Base",
"tier" : "Premium"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"apiServerAccessProfile" : {
"disableRunCommand" : true
},
"addonProfiles" : {},
"enableRBAC" : true,
"enablePodSecurityPolicy" : true,
"supportPlan" : "AKSLongTermSupport"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.KubernetesSupportPlan;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterApiServerAccessProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithLongTermSupport (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.BASE)
.withTier(ManagedClusterSkuTier.PREMIUM))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableEncryptionAtHost(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withSupportPlan(KubernetesSupportPlan.AKSLONG_TERM_SUPPORT)
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withApiServerAccessProfile(new ManagedClusterApiServerAccessProfile().withDisableRunCommand(true )),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_premium.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableEncryptionAtHost" : True ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"apiServerAccessProfile" : {"disableRunCommand" : True },
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"supportPlan" : "AKSLongTermSupport" ,
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Base" , "tier" : "Premium" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithLongTermSupport () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableEncryptionAtHost: to.Ptr(true ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
APIServerAccessProfile: &armcontainerservice.ManagedClusterAPIServerAccessProfile{
DisableRunCommand: to.Ptr(true ),
},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
SupportPlan: to.Ptr(armcontainerservice.KubernetesSupportPlanAKSLongTermSupport),
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUNameBase),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierPremium),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithLongTermSupport ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableEncryptionAtHost : true ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
apiServerAccessProfile : { disableRunCommand : true },
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Base" , tier : "Premium" },
supportPlan : "AKSLongTermSupport" ,
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"sku" : {
"name" : "Base" ,
"tier" : "Premium"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"disableRunCommand" : true
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-ee788a1f.hcp.location1.azmk8s.io" ,
"privateFQDN" : "dnsprefix1-aae7e0f0.5cef6058-b6b5-414d-8cb1-4bd14eb0b15c.privatelink.location1.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"supportPlan" : "AKSLongTermSupport"
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"sku" : {
"name" : "Base" ,
"tier" : "Premium"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"disableRunCommand" : true
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"fqdn" : "dnsprefix1-ee788a1f.hcp.location1.azmk8s.io" ,
"privateFQDN" : "dnsprefix1-aae7e0f0.5cef6058-b6b5-414d-8cb1-4bd14eb0b15c.privatelink.location1.azmk8s.io" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"supportPlan" : "AKSLongTermSupport"
}
}
Create Managed Cluster with Node Public IP Prefix
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"nodePublicIPPrefixID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithNodePublicIPPrefix (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withNodePublicIpPrefixId(
"/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix" )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_node_public_ip_prefix.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"nodePublicIPPrefixID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithNodePublicIpPrefix () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
NodePublicIPPrefixID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix" ),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithNodePublicIPPrefix ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
nodePublicIPPrefixID :
"/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"nodePublicIPPrefixID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodePublicIPPrefixID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with OSSKU
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"osSKU" : "AzureLinux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true,
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080",
"httpsProxy" : "https://myproxy.server.com:8080",
"noProxy" : [
"localhost",
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterHttpProxyConfig;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSSku;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithOSSKU (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withOsSku(OSSku.AZURE_LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" )
.withHttpProxyConfig(
new ManagedClusterHttpProxyConfig()
.withHttpProxy("http://myproxy.server.com:8080" )
.withHttpsProxy("https://myproxy.server.com:8080" )
.withNoProxy(Arrays.asList("localhost" , "127.0.0.1" ))
.withTrustedCa("Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" )),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_ossku.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osSKU" : "AzureLinux" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : ["localhost" , "127.0.0.1" ],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ,
},
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithOssku () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSSKU: to.Ptr(armcontainerservice.OSSKUAzureLinux),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
HTTPProxyConfig: &armcontainerservice.ManagedClusterHTTPProxyConfig{
HTTPProxy: to.Ptr("http://myproxy.server.com:8080" ),
HTTPSProxy: to.Ptr("https://myproxy.server.com:8080" ),
NoProxy: []*string {
to.Ptr("localhost" ),
to.Ptr("127.0.0.1" )},
TrustedCa: to.Ptr("Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ),
},
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithOssku ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osSKU : "AzureLinux" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
httpProxyConfig : {
httpProxy : "http://myproxy.server.com:8080" ,
httpsProxy : "https://myproxy.server.com:8080" ,
noProxy : ["localhost" , "127.0.0.1" ],
trustedCa : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=" ,
},
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"osSKU" : "AzureLinux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : [
"localhost" ,
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"osSKU" : "AzureLinux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"httpProxyConfig" : {
"httpProxy" : "http://myproxy.server.com:8080" ,
"httpsProxy" : "https://myproxy.server.com:8080" ,
"noProxy" : [
"localhost" ,
"127.0.0.1"
],
"trustedCa" : "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U="
}
}
}
Create Managed Cluster with PodIdentity enabled
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true,
"podIdentityProfile" : {
"enabled" : true,
"allowNetworkPluginKubenet" : true
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPodIdentityProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithPodIdentityEnabled (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withPodIdentityProfile(
new ManagedClusterPodIdentityProfile().withEnabled(true ).withAllowNetworkPluginKubenet(true ))
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_pod_identity.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"podIdentityProfile" : {"allowNetworkPluginKubenet" : True , "enabled" : True },
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithPodIdentityEnabled () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
PodIdentityProfile: &armcontainerservice.ManagedClusterPodIdentityProfile{
AllowNetworkPluginKubenet: to.Ptr(true ),
Enabled: to.Ptr(true ),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithPodIdentityEnabled ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
podIdentityProfile : { allowNetworkPluginKubenet : true , enabled : true },
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"podIdentityProfile" : {
"enabled" : true ,
"allowNetworkPluginKubenet" : true
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"podIdentityProfile" : {
"enabled" : true ,
"allowNetworkPluginKubenet" : true
}
}
}
Create Managed Cluster with PPG
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"proximityPlacementGroupID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithPPG (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withProximityPlacementGroupId(
"/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1" )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_ppg.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"proximityPlacementGroupID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithPpg () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
ProximityPlacementGroupID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1" ),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithPpg ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
proximityPlacementGroupID :
"/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"proximityPlacementGroupID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"proximityPlacementGroupID" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with RunCommand disabled
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"apiServerAccessProfile" : {
"disableRunCommand" : true
},
"addonProfiles" : {},
"enableRBAC" : true,
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterApiServerAccessProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithRunCommandDisabled (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableEncryptionAtHost(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withApiServerAccessProfile(new ManagedClusterApiServerAccessProfile().withDisableRunCommand(true )),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_disable_run_command.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableEncryptionAtHost" : True ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"apiServerAccessProfile" : {"disableRunCommand" : True },
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithRunCommandDisabled () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableEncryptionAtHost: to.Ptr(true ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
APIServerAccessProfile: &armcontainerservice.ManagedClusterAPIServerAccessProfile{
DisableRunCommand: to.Ptr(true ),
},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithRunCommandDisabled ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableEncryptionAtHost : true ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
apiServerAccessProfile : { disableRunCommand : true },
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"disableRunCommand" : true
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-ee788a1f.hcp.location1.azmk8s.io" ,
"privateFQDN" : "dnsprefix1-aae7e0f0.5cef6058-b6b5-414d-8cb1-4bd14eb0b15c.privatelink.location1.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"supportPlan" : "KubernetesOfficial"
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"disableRunCommand" : true
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"fqdn" : "dnsprefix1-ee788a1f.hcp.location1.azmk8s.io" ,
"privateFQDN" : "dnsprefix1-aae7e0f0.5cef6058-b6b5-414d-8cb1-4bd14eb0b15c.privatelink.location1.azmk8s.io" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"supportPlan" : "KubernetesOfficial"
}
}
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"securityProfile" : {
"defender" : {
"logAnalyticsWorkspaceResourceId" : "/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME",
"securityMonitoring" : {
"enabled" : true
}
},
"workloadIdentity" : {
"enabled" : true
}
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSecurityProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSecurityProfileDefender;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSecurityProfileDefenderSecurityMonitoring;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSecurityProfileWorkloadIdentity;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithSecurityProfileConfigured (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withSecurityProfile(
new ManagedClusterSecurityProfile()
.withDefender(
new ManagedClusterSecurityProfileDefender()
.withLogAnalyticsWorkspaceResourceId(
"/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME" )
.withSecurityMonitoring(
new ManagedClusterSecurityProfileDefenderSecurityMonitoring()
.withEnabled(true )))
.withWorkloadIdentity(
new ManagedClusterSecurityProfileWorkloadIdentity().withEnabled(true ))),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_security_profile.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"dnsPrefix" : "dnsprefix1" ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"securityProfile" : {
"defender" : {
"logAnalyticsWorkspaceResourceId" : "/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME" ,
"securityMonitoring" : {"enabled" : True },
},
"workloadIdentity" : {"enabled" : True },
},
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithSecurityProfileConfigured () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
DNSPrefix: to.Ptr("dnsprefix1" ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
SecurityProfile: &armcontainerservice.ManagedClusterSecurityProfile{
Defender: &armcontainerservice.ManagedClusterSecurityProfileDefender{
LogAnalyticsWorkspaceResourceID: to.Ptr("/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME" ),
SecurityMonitoring: &armcontainerservice.ManagedClusterSecurityProfileDefenderSecurityMonitoring{
Enabled: to.Ptr(true ),
},
},
WorkloadIdentity: &armcontainerservice.ManagedClusterSecurityProfileWorkloadIdentity{
Enabled: to.Ptr(true ),
},
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithSecurityProfileConfigured ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
dnsPrefix : "dnsprefix1" ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
securityProfile : {
defender : {
logAnalyticsWorkspaceResourceId :
"/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME" ,
securityMonitoring : { enabled : true },
},
workloadIdentity : { enabled : true },
},
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"securityProfile" : {
"defender" : {
"logAnalyticsWorkspaceResourceId" : "/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME" ,
"securityMonitoring" : {
"enabled" : true
}
},
"workloadIdentity" : {
"enabled" : true
}
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"securityProfile" : {
"defender" : {
"logAnalyticsWorkspaceResourceId" : "/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME" ,
"securityMonitoring" : {
"enabled" : true
}
},
"workloadIdentity" : {
"enabled" : true
}
}
}
}
Create Managed Cluster with UltraSSD enabled
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableUltraSSD" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithUltraSSDEnabled (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableUltraSsd(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_enable_ultra_ssd.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"enableUltraSSD" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithUltraSsdEnabled () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
EnableUltraSSD: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithUltraSsdEnabled ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
enableUltraSSD : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableUltraSSD" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableUltraSSD" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Cluster with user-assigned NAT gateway as outbound type
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : false,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "userAssignedNATGateway"
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedClusterWithUserAssignedNATGatewayAsOutboundType (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(false )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.USER_ASSIGNED_NATGATEWAY)
.withLoadBalancerSku(LoadBalancerSku.STANDARD))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_user_assigned_nat_gateway.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : False ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {"loadBalancerSku" : "standard" , "outboundType" : "userAssignedNATGateway" },
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedClusterWithUserAssignedNatGatewayAsOutboundType () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(false ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeUserAssignedNATGateway),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedClusterWithUserAssignedNatGatewayAsOutboundType ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : false ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerSku : "standard" ,
outboundType : "userAssignedNATGateway" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : false ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "userAssignedNATGateway"
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : false ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "userAssignedNATGateway"
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Private Cluster with fqdn subdomain specified
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"fqdnSubdomain" : "domain1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"apiServerAccessProfile" : {
"enablePrivateCluster" : true,
"privateDNSZone" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io"
},
"addonProfiles" : {},
"enableRBAC" : true,
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterApiServerAccessProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedPrivateClusterWithFqdnSubdomainSpecified (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withFqdnSubdomain("domain1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableEncryptionAtHost(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withApiServerAccessProfile(
new ManagedClusterApiServerAccessProfile()
.withEnablePrivateCluster(true )
.withPrivateDnsZone(
"/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io" )),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_private_cluster_fqdn_subdomain.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableEncryptionAtHost" : True ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"apiServerAccessProfile" : {
"enablePrivateCluster" : True ,
"privateDNSZone" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io" ,
},
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"fqdnSubdomain" : "domain1" ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedPrivateClusterWithFqdnSubdomainSpecified () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableEncryptionAtHost: to.Ptr(true ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
APIServerAccessProfile: &armcontainerservice.ManagedClusterAPIServerAccessProfile{
EnablePrivateCluster: to.Ptr(true ),
PrivateDNSZone: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io" ),
},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
FqdnSubdomain: to.Ptr("domain1" ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedPrivateClusterWithFqdnSubdomainSpecified ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableEncryptionAtHost : true ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
apiServerAccessProfile : {
enablePrivateCluster : true ,
privateDNSZone :
"/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io" ,
},
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
enablePodSecurityPolicy : true ,
enableRbac : true ,
fqdnSubdomain : "domain1" ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"fqdnSubdomain" : "domain1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"enablePrivateCluster" : true ,
"privateDNSZone" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"enablePodSecurityPolicy" : true ,
"privateFQDN" : "domain1.privatelink.location1.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"fqdnSubdomain" : "domain1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"enablePrivateCluster" : true ,
"privateDNSZone" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"privateFQDN" : "domain1.privatelink.location1.azmk8s.io" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create Managed Private Cluster with Public FQDN specified
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System",
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"apiServerAccessProfile" : {
"enablePrivateCluster" : true,
"enablePrivateClusterPublicFQDN" : true
},
"addonProfiles" : {},
"enableRBAC" : true,
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterApiServerAccessProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createManagedPrivateClusterWithPublicFQDNSpecified (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withEnableEncryptionAtHost(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withApiServerAccessProfile(
new ManagedClusterApiServerAccessProfile()
.withEnablePrivateCluster(true )
.withEnablePrivateClusterPublicFqdn(true )),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_private_cluster_public_fqdn.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableEncryptionAtHost" : True ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"apiServerAccessProfile" : {"enablePrivateCluster" : True , "enablePrivateClusterPublicFQDN" : True },
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createManagedPrivateClusterWithPublicFqdnSpecified () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableEncryptionAtHost: to.Ptr(true ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
APIServerAccessProfile: &armcontainerservice.ManagedClusterAPIServerAccessProfile{
EnablePrivateCluster: to.Ptr(true ),
EnablePrivateClusterPublicFQDN: to.Ptr(true ),
},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createManagedPrivateClusterWithPublicFqdnSpecified ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableEncryptionAtHost : true ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
apiServerAccessProfile : {
enablePrivateCluster : true ,
enablePrivateClusterPublicFqdn : true ,
},
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"enablePrivateCluster" : true ,
"enablePrivateClusterPublicFQDN" : true ,
"privateDNSZone" : "system"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-ee788a1f.hcp.location1.azmk8s.io" ,
"privateFQDN" : "dnsprefix1-aae7e0f0.5cef6058-b6b5-414d-8cb1-4bd14eb0b15c.privatelink.location1.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"apiServerAccessProfile" : {
"enablePrivateCluster" : true ,
"enablePrivateClusterPublicFQDN" : true ,
"privateDNSZone" : "system"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"fqdn" : "dnsprefix1-ee788a1f.hcp.location1.azmk8s.io" ,
"privateFQDN" : "dnsprefix1-aae7e0f0.5cef6058-b6b5-414d-8cb1-4bd14eb0b15c.privatelink.location1.azmk8s.io" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create/Update AAD Managed Cluster with EnableAzureRBAC
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS1_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"availabilityZones" : [
"1",
"2",
"3"
],
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"aadProfile" : {
"managed" : true,
"enableAzureRBAC" : true
},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAadProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createUpdateAADManagedClusterWithEnableAzureRBAC (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS1_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withAvailabilityZones(Arrays.asList("1" , "2" , "3" ))
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAadProfile(new ManagedClusterAadProfile().withManaged(true ).withEnableAzureRbac(true ))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_update_with_enable_azure_rbac.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"aadProfile" : {"enableAzureRBAC" : True , "managed" : True },
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"availabilityZones" : ["1" , "2" , "3" ],
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS1_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createUpdateAadManagedClusterWithEnableAzureRbac () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AADProfile: &armcontainerservice.ManagedClusterAADProfile{
EnableAzureRBAC: to.Ptr(true ),
Managed: to.Ptr(true ),
},
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string {
to.Ptr("1" ),
to.Ptr("2" ),
to.Ptr("3" )},
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS1_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createOrUpdateAadManagedClusterWithEnableAzureRbac ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
aadProfile : { enableAzureRbac : true , managed : true },
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
availabilityZones : ["1" , "2" , "3" ],
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS1_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"aadProfile" : {
"managed" : true ,
"adminGroupObjectIDs" : null ,
"enableAzureRBAC" : true ,
"tenantID" : "tenantID"
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"aadProfile" : {
"managed" : true ,
"adminGroupObjectIDs" : null ,
"enableAzureRBAC" : true ,
"tenantID" : "tenantID"
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
}
}
Create/Update Managed Cluster
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS1_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"scaleDownMode" : "Deallocate",
"availabilityZones" : [
"1",
"2",
"3"
],
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"upgradeSettings" : {
"overrideSettings" : {
"forceUpgrade" : false,
"until" : "2022-11-01T13:00:00Z"
}
},
"autoScalerProfile" : {
"balance-similar-node-groups" : "true",
"expander" : "priority",
"max-node-provision-time" : "15m",
"new-pod-scale-up-delay" : "1m",
"scale-down-delay-after-add" : "15m",
"scan-interval" : "20s",
"skip-nodes-with-system-pods" : "false"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
},
"identity" : {
"type" : "UserAssigned",
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ClusterUpgradeSettings;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.Expander;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterIdentity;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.ManagedServiceIdentityUserAssignedIdentitiesValue;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import com.azure.resourcemanager.containerservice.models.ResourceIdentityType;
import com.azure.resourcemanager.containerservice.models.ScaleDownMode;
import com.azure.resourcemanager.containerservice.models.UpgradeOverrideSettings;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createUpdateManagedCluster (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withIdentity(
new ManagedClusterIdentity()
.withType(ResourceIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(
mapOf(
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" ,
new ManagedServiceIdentityUserAssignedIdentitiesValue())))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS1_v2" )
.withOsType(OSType.LINUX)
.withScaleDownMode(ScaleDownMode.DEALLOCATE)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withAvailabilityZones(Arrays.asList("1" , "2" , "3" ))
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withUpgradeSettings(
new ClusterUpgradeSettings()
.withOverrideSettings(
new UpgradeOverrideSettings()
.withForceUpgrade(false )
.withUntil(OffsetDateTime.parse("2022-11-01T13:00:00Z" ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withBalanceSimilarNodeGroups("true" )
.withExpander(Expander.PRIORITY)
.withMaxNodeProvisionTime("15m" )
.withNewPodScaleUpDelay("1m" )
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" )
.withSkipNodesWithSystemPods("false" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_update.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
},
},
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"availabilityZones" : ["1" , "2" , "3" ],
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"scaleDownMode" : "Deallocate" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS1_v2" ,
}
],
"autoScalerProfile" : {
"balance-similar-node-groups" : "true" ,
"expander" : "priority" ,
"max-node-provision-time" : "15m" ,
"new-pod-scale-up-delay" : "1m" ,
"scale-down-delay-after-add" : "15m" ,
"scan-interval" : "20s" ,
"skip-nodes-with-system-pods" : "false" ,
},
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"upgradeSettings" : {"overrideSettings" : {"forceUpgrade" : False , "until" : "2022-11-01T13:00:00Z" }},
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createUpdateManagedCluster () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Identity: &armcontainerservice.ManagedClusterIdentity{
Type: to.Ptr(armcontainerservice.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map [string ]*armcontainerservice.ManagedServiceIdentityUserAssignedIdentitiesValue{
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {},
},
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string {
to.Ptr("1" ),
to.Ptr("2" ),
to.Ptr("3" )},
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
ScaleDownMode: to.Ptr(armcontainerservice.ScaleDownModeDeallocate),
VMSize: to.Ptr("Standard_DS1_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
BalanceSimilarNodeGroups: to.Ptr("true" ),
Expander: to.Ptr(armcontainerservice.ExpanderPriority),
MaxNodeProvisionTime: to.Ptr("15m" ),
NewPodScaleUpDelay: to.Ptr("1m" ),
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
SkipNodesWithSystemPods: to.Ptr("false" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
UpgradeSettings: &armcontainerservice.ClusterUpgradeSettings{
OverrideSettings: &armcontainerservice.UpgradeOverrideSettings{
ForceUpgrade: to.Ptr(false ),
Until: to.Ptr(func () time .Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-01T13:00:00Z" ); return t }()),
},
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createOrUpdateManagedCluster ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
availabilityZones : ["1" , "2" , "3" ],
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
scaleDownMode : "Deallocate" ,
vmSize : "Standard_DS1_v2" ,
},
],
autoScalerProfile : {
balanceSimilarNodeGroups : "true" ,
expander : "priority" ,
maxNodeProvisionTime : "15m" ,
newPodScaleUpDelay : "1m" ,
scaleDownDelayAfterAdd : "15m" ,
scanInterval : "20s" ,
skipNodesWithSystemPods : "false" ,
},
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
identity : {
type : "UserAssigned" ,
userAssignedIdentities : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/MicrosoftManagedIdentity/userAssignedIdentities/identity1" :
{},
},
},
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
upgradeSettings : {
overrideSettings : {
forceUpgrade : false ,
until : new Date ("2022-11-01T13:00:00Z" ),
},
},
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"scaleDownMode" : "Deallocate" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"upgradeSettings" : {
"overrideSettings" : {
"forceUpgrade" : false ,
"until" : "2022-11-01T13:00:00Z"
}
},
"autoScalerProfile" : {
"balance-similar-node-groups" : "true" ,
"expander" : "priority" ,
"max-node-provision-time" : "15m" ,
"new-pod-scale-up-delay" : "1m" ,
"scale-down-delay-after-add" : "15m" ,
"scan-interval" : "20s" ,
"skip-nodes-with-system-pods" : "false"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"scaleDownMode" : "Deallocate" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
Create/Update Managed Cluster with Azure Service Mesh
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS2_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"serviceMeshProfile" : {
"mode" : "Istio",
"istio" : {
"components" : {
"ingressGateways" : [
{
"enabled" : true,
"mode" : "Internal"
}
],
"egressGateways" : [
{
"enabled" : true,
"nodeSelector" : {
"istio" : "egress"
}
}
]
},
"certificateAuthority" : {
"plugin" : {
"keyVaultId" : "/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv",
"certObjectName" : "ca-cert",
"keyObjectName" : "ca-key",
"rootCertObjectName" : "root-cert",
"certChainObjectName" : "cert-chain"
}
}
}
},
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"enabled" : true,
"config" : {
"enableSecretRotation" : "true",
"rotationPollInterval" : "2m"
}
}
},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.IstioCertificateAuthority;
import com.azure.resourcemanager.containerservice.models.IstioComponents;
import com.azure.resourcemanager.containerservice.models.IstioEgressGateway;
import com.azure.resourcemanager.containerservice.models.IstioIngressGateway;
import com.azure.resourcemanager.containerservice.models.IstioIngressGatewayMode;
import com.azure.resourcemanager.containerservice.models.IstioPluginCertificateAuthority;
import com.azure.resourcemanager.containerservice.models.IstioServiceMesh;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAddonProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import com.azure.resourcemanager.containerservice.models.ServiceMeshMode;
import com.azure.resourcemanager.containerservice.models.ServiceMeshProfile;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createUpdateManagedClusterWithAzureServiceMesh (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS2_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(
mapOf(
"azureKeyvaultSecretsProvider" ,
new ManagedClusterAddonProfile()
.withEnabled(true )
.withConfig(
mapOf(
"enableSecretRotation" , "fakeTokenPlaceholder" , "rotationPollInterval" , "2m" ))))
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" )
.withServiceMeshProfile(
new ServiceMeshProfile()
.withMode(ServiceMeshMode.ISTIO)
.withIstio(
new IstioServiceMesh()
.withComponents(
new IstioComponents()
.withIngressGateways(
Arrays
.asList(
new IstioIngressGateway()
.withMode(IstioIngressGatewayMode.INTERNAL)
.withEnabled(true )))
.withEgressGateways(
Arrays
.asList(
new IstioEgressGateway()
.withEnabled(true )
.withNodeSelector(mapOf("istio" , "egress" )))))
.withCertificateAuthority(
new IstioCertificateAuthority()
.withPlugin(
new IstioPluginCertificateAuthority()
.withKeyVaultId("fakeTokenPlaceholder" )
.withCertObjectName("ca-cert" )
.withKeyObjectName("fakeTokenPlaceholder" )
.withRootCertObjectName("root-cert" )
.withCertChainObjectName("cert-chain" ))))),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_azure_service_mesh.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"location" : "location1" ,
"properties" : {
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"config" : {"enableSecretRotation" : "true" , "rotationPollInterval" : "2m" },
"enabled" : True ,
}
},
"agentPoolProfiles" : [
{
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS2_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"serviceMeshProfile" : {
"istio" : {
"certificateAuthority" : {
"plugin" : {
"certChainObjectName" : "cert-chain" ,
"certObjectName" : "ca-cert" ,
"keyObjectName" : "ca-key" ,
"keyVaultId" : "/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv" ,
"rootCertObjectName" : "root-cert" ,
}
},
"components" : {
"egressGateways" : [{"enabled" : True , "nodeSelector" : {"istio" : "egress" }}],
"ingressGateways" : [{"enabled" : True , "mode" : "Internal" }],
},
},
"mode" : "Istio" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createUpdateManagedClusterWithAzureServiceMesh () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{
"azureKeyvaultSecretsProvider" : {
Config: map [string ]*string {
"enableSecretRotation" : to.Ptr("true" ),
"rotationPollInterval" : to.Ptr("2m" ),
},
Enabled: to.Ptr(true ),
},
},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServiceMeshProfile: &armcontainerservice.ServiceMeshProfile{
Istio: &armcontainerservice.IstioServiceMesh{
CertificateAuthority: &armcontainerservice.IstioCertificateAuthority{
Plugin: &armcontainerservice.IstioPluginCertificateAuthority{
CertChainObjectName: to.Ptr("cert-chain" ),
CertObjectName: to.Ptr("ca-cert" ),
KeyObjectName: to.Ptr("ca-key" ),
KeyVaultID: to.Ptr("/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv" ),
RootCertObjectName: to.Ptr("root-cert" ),
},
},
Components: &armcontainerservice.IstioComponents{
EgressGateways: []*armcontainerservice.IstioEgressGateway{
{
Enabled: to.Ptr(true ),
NodeSelector: map [string ]*string {
"istio" : to.Ptr("egress" ),
},
}},
IngressGateways: []*armcontainerservice.IstioIngressGateway{
{
Enabled: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.IstioIngressGatewayModeInternal),
}},
},
},
Mode: to.Ptr(armcontainerservice.ServiceMeshModeIstio),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createOrUpdateManagedClusterWithAzureServiceMesh ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {
azureKeyvaultSecretsProvider : {
config : { enableSecretRotation : "true" , rotationPollInterval : "2m" },
enabled : true ,
},
},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS2_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
serviceMeshProfile : {
istio : {
certificateAuthority : {
plugin : {
certChainObjectName : "cert-chain" ,
certObjectName : "ca-cert" ,
keyObjectName : "ca-key" ,
keyVaultId :
"/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv" ,
rootCertObjectName : "root-cert" ,
},
},
components : {
egressGateways : [{ enabled : true , nodeSelector : { istio : "egress" } }],
ingressGateways : [{ enabled : true , mode : "Internal" }],
},
},
mode : "Istio" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"enabled" : true ,
"config" : {
"enableSecretRotation" : "true" ,
"rotationPollInterval" : "2m"
}
}
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"serviceMeshProfile" : {
"mode" : "Istio" ,
"istio" : {
"components" : {
"ingressGateways" : [
{
"enabled" : true ,
"mode" : "Internal"
}
],
"egressGateways" : [
{
"enabled" : true ,
"nodeSelector" : {
"istio" : "egress"
}
}
]
},
"certificateAuthority" : {
"plugin" : {
"keyVaultId" : "/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv" ,
"certObjectName" : "ca-cert" ,
"keyObjectName" : "ca-key" ,
"rootCertObjectName" : "root-cert" ,
"certChainObjectName" : "cert-chain"
}
},
"revisions" : [
"asm-1-17"
]
}
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS2_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"enableNodePublicIP" : true ,
"mode" : "System" ,
"enableEncryptionAtHost" : true
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"addonProfiles" : {
"azureKeyvaultSecretsProvider" : {
"enabled" : true ,
"config" : {
"enableSecretRotation" : "true" ,
"rotationPollInterval" : "2m"
}
}
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
},
"serviceMeshProfile" : {
"mode" : "Istio" ,
"istio" : {
"components" : {
"ingressGateways" : [
{
"enabled" : true ,
"mode" : "Internal"
}
],
"egressGateways" : [
{
"enabled" : true ,
"nodeSelector" : {
"istio" : "egress"
}
}
]
},
"certificateAuthority" : {
"plugin" : {
"keyVaultId" : "/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv" ,
"certObjectName" : "ca-cert" ,
"keyObjectName" : "ca-key" ,
"rootCertObjectName" : "root-cert" ,
"certChainObjectName" : "cert-chain"
}
},
"revisions" : [
"asm-1-17"
]
}
}
}
}
Create/Update Managed Cluster with dual-stack networking
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS1_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"scaleDownMode" : "Deallocate",
"availabilityZones" : [
"1",
"2",
"3"
],
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
},
"ipFamilies" : [
"IPv4",
"IPv6"
]
},
"autoScalerProfile" : {
"balance-similar-node-groups" : "true",
"expander" : "priority",
"max-node-provision-time" : "15m",
"new-pod-scale-up-delay" : "1m",
"scale-down-delay-after-add" : "15m",
"scan-interval" : "20s",
"skip-nodes-with-system-pods" : "false"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
},
"identity" : {
"type" : "UserAssigned",
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.Expander;
import com.azure.resourcemanager.containerservice.models.IpFamily;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterIdentity;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.ManagedServiceIdentityUserAssignedIdentitiesValue;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import com.azure.resourcemanager.containerservice.models.ResourceIdentityType;
import com.azure.resourcemanager.containerservice.models.ScaleDownMode;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createUpdateManagedClusterWithDualStackNetworking (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withIdentity(
new ManagedClusterIdentity()
.withType(ResourceIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(
mapOf(
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" ,
new ManagedServiceIdentityUserAssignedIdentitiesValue())))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS1_v2" )
.withOsType(OSType.LINUX)
.withScaleDownMode(ScaleDownMode.DEALLOCATE)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withAvailabilityZones(Arrays.asList("1" , "2" , "3" ))
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" ))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 )))
.withIpFamilies(Arrays.asList(IpFamily.IPV4, IpFamily.IPV6)))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withBalanceSimilarNodeGroups("true" )
.withExpander(Expander.PRIORITY)
.withMaxNodeProvisionTime("15m" )
.withNewPodScaleUpDelay("1m" )
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" )
.withSkipNodesWithSystemPods("false" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_dual_stack_networking.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
},
},
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"availabilityZones" : ["1" , "2" , "3" ],
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"scaleDownMode" : "Deallocate" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS1_v2" ,
}
],
"autoScalerProfile" : {
"balance-similar-node-groups" : "true" ,
"expander" : "priority" ,
"max-node-provision-time" : "15m" ,
"new-pod-scale-up-delay" : "1m" ,
"scale-down-delay-after-add" : "15m" ,
"scan-interval" : "20s" ,
"skip-nodes-with-system-pods" : "false" ,
},
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"ipFamilies" : ["IPv4" , "IPv6" ],
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {"adminPassword" : "replacePassword1234$" , "adminUsername" : "azureuser" },
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createUpdateManagedClusterWithDualStackNetworking () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Identity: &armcontainerservice.ManagedClusterIdentity{
Type: to.Ptr(armcontainerservice.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map [string ]*armcontainerservice.ManagedServiceIdentityUserAssignedIdentitiesValue{
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {},
},
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string {
to.Ptr("1" ),
to.Ptr("2" ),
to.Ptr("3" )},
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
ScaleDownMode: to.Ptr(armcontainerservice.ScaleDownModeDeallocate),
VMSize: to.Ptr("Standard_DS1_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
BalanceSimilarNodeGroups: to.Ptr("true" ),
Expander: to.Ptr(armcontainerservice.ExpanderPriority),
MaxNodeProvisionTime: to.Ptr("15m" ),
NewPodScaleUpDelay: to.Ptr("1m" ),
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
SkipNodesWithSystemPods: to.Ptr("false" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
IPFamilies: []*armcontainerservice.IPFamily{
to.Ptr(armcontainerservice.IPFamilyIPv4),
to.Ptr(armcontainerservice.IPFamilyIPv6)},
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createOrUpdateManagedClusterWithDualStackNetworking ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
availabilityZones : ["1" , "2" , "3" ],
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
scaleDownMode : "Deallocate" ,
vmSize : "Standard_DS1_v2" ,
},
],
autoScalerProfile : {
balanceSimilarNodeGroups : "true" ,
expander : "priority" ,
maxNodeProvisionTime : "15m" ,
newPodScaleUpDelay : "1m" ,
scaleDownDelayAfterAdd : "15m" ,
scanInterval : "20s" ,
skipNodesWithSystemPods : "false" ,
},
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
identity : {
type : "UserAssigned" ,
userAssignedIdentities : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/MicrosoftManagedIdentity/userAssignedIdentities/identity1" :
{},
},
},
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
ipFamilies : ["IPv4" , "IPv6" ],
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.22.1" ,
"currentKubernetesVersion" : "1.22.1" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.22.1" ,
"currentOrchestratorVersion" : "1.22.1" ,
"type" : "VirtualMachineScaleSets" ,
"scaleDownMode" : "Deallocate" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16" ,
"fd11:1234::/64"
],
"serviceCidrs" : [
"10.0.0.0/16" ,
"fd00:1234::/108"
],
"ipFamilies" : [
"IPv4" ,
"IPv6"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2 ,
"countIPv6" : 1
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip3-ipv6"
}
]
}
},
"autoScalerProfile" : {
"balance-similar-node-groups" : "true" ,
"expander" : "priority" ,
"max-node-provision-time" : "15m" ,
"new-pod-scale-up-delay" : "1m" ,
"scale-down-delay-after-add" : "15m" ,
"scan-interval" : "20s" ,
"skip-nodes-with-system-pods" : "false"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.22.1" ,
"currentKubernetesVersion" : "1.22.1" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.22.1" ,
"currentOrchestratorVersion" : "1.22.1" ,
"type" : "VirtualMachineScaleSets" ,
"scaleDownMode" : "Deallocate" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16" ,
"fd11:1234::/64"
],
"serviceCidrs" : [
"10.0.0.0/16" ,
"fd00:1234::/108"
],
"ipFamilies" : [
"IPv4" ,
"IPv6"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2 ,
"countIPv6" : 1
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip3-ipv6"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
Create/Update Managed Cluster with EnableAHUB
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS1_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"availabilityZones" : [
"1",
"2",
"3"
],
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$",
"licenseType" : "Windows_Server"
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
},
"identity" : {
"type" : "UserAssigned",
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LicenseType;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterIdentity;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.ManagedServiceIdentityUserAssignedIdentitiesValue;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import com.azure.resourcemanager.containerservice.models.ResourceIdentityType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createUpdateManagedClusterWithEnableAHUB (com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withIdentity(
new ManagedClusterIdentity()
.withType(ResourceIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(
mapOf(
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" ,
new ManagedServiceIdentityUserAssignedIdentitiesValue())))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS1_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withAvailabilityZones(Arrays.asList("1" , "2" , "3" ))
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" )
.withLicenseType(LicenseType.WINDOWS_SERVER))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_update_with_ahub.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
},
},
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"availabilityZones" : ["1" , "2" , "3" ],
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS1_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {
"adminPassword" : "replacePassword1234$" ,
"adminUsername" : "azureuser" ,
"licenseType" : "Windows_Server" ,
},
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createUpdateManagedClusterWithEnableAhub () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Identity: &armcontainerservice.ManagedClusterIdentity{
Type: to.Ptr(armcontainerservice.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map [string ]*armcontainerservice.ManagedServiceIdentityUserAssignedIdentitiesValue{
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {},
},
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string {
to.Ptr("1" ),
to.Ptr("2" ),
to.Ptr("3" )},
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS1_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
LicenseType: to.Ptr(armcontainerservice.LicenseTypeWindowsServer),
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createOrUpdateManagedClusterWithEnableAhub ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
availabilityZones : ["1" , "2" , "3" ],
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS1_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
identity : {
type : "UserAssigned" ,
userAssignedIdentities : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/MicrosoftManagedIdentity/userAssignedIdentities/identity1" :
{},
},
},
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
licenseType : "Windows_Server" ,
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser" ,
"licenseType" : "Windows_Server"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser" ,
"licenseType" : "Windows_Server"
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
Create/Update Managed Cluster with Windows gMSA enabled
Sample request
PUT https://management.azure.com/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1?api-version=2023-08-01
{
"location" : "location1",
"tags" : {
"tier" : "production",
"archv2" : ""
},
"sku" : {
"name" : "Basic",
"tier" : "Free"
},
"properties" : {
"kubernetesVersion" : "",
"dnsPrefix" : "dnsprefix1",
"agentPoolProfiles" : [
{
"name" : "nodepool1",
"count" : 3,
"vmSize" : "Standard_DS1_v2",
"osType" : "Linux",
"type" : "VirtualMachineScaleSets",
"availabilityZones" : [
"1",
"2",
"3"
],
"enableNodePublicIP" : true,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser",
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"networkProfile" : {
"loadBalancerSku" : "standard",
"outboundType" : "loadBalancer",
"loadBalancerProfile" : {
"managedOutboundIPs" : {
"count" : 2
}
}
},
"autoScalerProfile" : {
"scan-interval" : "20s",
"scale-down-delay-after-add" : "15m"
},
"windowsProfile" : {
"adminUsername" : "azureuser",
"adminPassword" : "replacePassword1234$",
"gmsaProfile" : {
"enabled" : true
}
},
"servicePrincipalProfile" : {
"clientId" : "clientid",
"secret" : "secret"
},
"addonProfiles" : {},
"enableRBAC" : true,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
"enablePodSecurityPolicy" : true
},
"identity" : {
"type" : "UserAssigned",
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.AgentPoolType;
import com.azure.resourcemanager.containerservice.models.ContainerServiceLinuxProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshConfiguration;
import com.azure.resourcemanager.containerservice.models.ContainerServiceSshPublicKey;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterIdentity;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfileManagedOutboundIPs;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSku;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuName;
import com.azure.resourcemanager.containerservice.models.ManagedClusterSkuTier;
import com.azure.resourcemanager.containerservice.models.ManagedClusterWindowsProfile;
import com.azure.resourcemanager.containerservice.models.ManagedServiceIdentityUserAssignedIdentitiesValue;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.OutboundType;
import com.azure.resourcemanager.containerservice.models.ResourceIdentityType;
import com.azure.resourcemanager.containerservice.models.WindowsGmsaProfile;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public final class Main {
public static void createUpdateManagedClusterWithWindowsGMSAEnabled (
com.azure.resourcemanager.AzureResourceManager azure) {
azure
.kubernetesClusters()
.manager()
.serviceClient()
.getManagedClusters()
.createOrUpdate(
"rg1" ,
"clustername1" ,
new ManagedClusterInner()
.withLocation("location1" )
.withTags(mapOf("archv2" , "" , "tier" , "production" ))
.withSku(
new ManagedClusterSku()
.withName(ManagedClusterSkuName.fromString("Basic" ))
.withTier(ManagedClusterSkuTier.FREE))
.withIdentity(
new ManagedClusterIdentity()
.withType(ResourceIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(
mapOf(
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" ,
new ManagedServiceIdentityUserAssignedIdentitiesValue())))
.withKubernetesVersion("" )
.withDnsPrefix("dnsprefix1" )
.withAgentPoolProfiles(
Arrays
.asList(
new ManagedClusterAgentPoolProfile()
.withCount(3 )
.withVmSize("Standard_DS1_v2" )
.withOsType(OSType.LINUX)
.withType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withMode(AgentPoolMode.SYSTEM)
.withAvailabilityZones(Arrays.asList("1" , "2" , "3" ))
.withEnableNodePublicIp(true )
.withName("nodepool1" )))
.withLinuxProfile(
new ContainerServiceLinuxProfile()
.withAdminUsername("azureuser" )
.withSsh(
new ContainerServiceSshConfiguration()
.withPublicKeys(
Arrays
.asList(
new ContainerServiceSshPublicKey()
.withKeyData("fakeTokenPlaceholder" )))))
.withWindowsProfile(
new ManagedClusterWindowsProfile()
.withAdminUsername("azureuser" )
.withAdminPassword("fakeTokenPlaceholder" )
.withGmsaProfile(new WindowsGmsaProfile().withEnabled(true )))
.withServicePrincipalProfile(
new ManagedClusterServicePrincipalProfile()
.withClientId("clientid" )
.withSecret("fakeTokenPlaceholder" ))
.withAddonProfiles(mapOf())
.withEnableRbac(true )
.withEnablePodSecurityPolicy(true )
.withNetworkProfile(
new ContainerServiceNetworkProfile()
.withOutboundType(OutboundType.LOAD_BALANCER)
.withLoadBalancerSku(LoadBalancerSku.STANDARD)
.withLoadBalancerProfile(
new ManagedClusterLoadBalancerProfile()
.withManagedOutboundIPs(
new ManagedClusterLoadBalancerProfileManagedOutboundIPs().withCount(2 ))))
.withAutoScalerProfile(
new ManagedClusterPropertiesAutoScalerProfile()
.withScanInterval("20s" )
.withScaleDownDelayAfterAdd("15m" ))
.withDiskEncryptionSetId(
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
com.azure.core.util.Context.NONE);
}
@SuppressWarnings ("unchecked" )
private static <T> Map<String, T> mapOf (Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0 ; i < inputs.length; i += 2 ) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1 ];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python managed_clusters_create_update_windows_gmsa.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main () :
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="subid1" ,
)
response = client.managed_clusters.begin_create_or_update(
resource_group_name="rg1" ,
resource_name="clustername1" ,
parameters={
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {}
},
},
"location" : "location1" ,
"properties" : {
"addonProfiles" : {},
"agentPoolProfiles" : [
{
"availabilityZones" : ["1" , "2" , "3" ],
"count" : 3 ,
"enableNodePublicIP" : True ,
"mode" : "System" ,
"name" : "nodepool1" ,
"osType" : "Linux" ,
"type" : "VirtualMachineScaleSets" ,
"vmSize" : "Standard_DS1_v2" ,
}
],
"autoScalerProfile" : {"scale-down-delay-after-add" : "15m" , "scan-interval" : "20s" },
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"dnsPrefix" : "dnsprefix1" ,
"enablePodSecurityPolicy" : True ,
"enableRBAC" : True ,
"kubernetesVersion" : "" ,
"linuxProfile" : {"adminUsername" : "azureuser" , "ssh" : {"publicKeys" : [{"keyData" : "keydata" }]}},
"networkProfile" : {
"loadBalancerProfile" : {"managedOutboundIPs" : {"count" : 2 }},
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
},
"servicePrincipalProfile" : {"clientId" : "clientid" , "secret" : "secret" },
"windowsProfile" : {
"adminPassword" : "replacePassword1234$" ,
"adminUsername" : "azureuser" ,
"gmsaProfile" : {"enabled" : True },
},
},
"sku" : {"name" : "Basic" , "tier" : "Free" },
"tags" : {"archv2" : "" , "tier" : "production" },
},
).result()
print(response)
if __name__ == "__main__" :
main()
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
)
func ExampleManagedClustersClient_BeginCreateOrUpdate_createUpdateManagedClusterWithWindowsGMsaEnabled () {
cred, err := azidentity.NewDefaultAzureCredential(nil )
if err != nil {
log.Fatalf("failed to obtain a credential: %v" , err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>" , cred, nil )
if err != nil {
log.Fatalf("failed to create client: %v" , err)
}
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, "rg1" , "clustername1" , armcontainerservice.ManagedCluster{
Location: to.Ptr("location1" ),
Tags: map [string ]*string {
"archv2" : to.Ptr("" ),
"tier" : to.Ptr("production" ),
},
Identity: &armcontainerservice.ManagedClusterIdentity{
Type: to.Ptr(armcontainerservice.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map [string ]*armcontainerservice.ManagedServiceIdentityUserAssignedIdentitiesValue{
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {},
},
},
Properties: &armcontainerservice.ManagedClusterProperties{
AddonProfiles: map [string ]*armcontainerservice.ManagedClusterAddonProfile{},
AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{
{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string {
to.Ptr("1" ),
to.Ptr("2" ),
to.Ptr("3" )},
Count: to.Ptr[int32 ](3 ),
EnableNodePublicIP: to.Ptr(true ),
Mode: to.Ptr(armcontainerservice.AgentPoolModeSystem),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS1_v2" ),
Name: to.Ptr("nodepool1" ),
}},
AutoScalerProfile: &armcontainerservice.ManagedClusterPropertiesAutoScalerProfile{
ScaleDownDelayAfterAdd: to.Ptr("15m" ),
ScanInterval: to.Ptr("20s" ),
},
DiskEncryptionSetID: to.Ptr("/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ),
DNSPrefix: to.Ptr("dnsprefix1" ),
EnablePodSecurityPolicy: to.Ptr(true ),
EnableRBAC: to.Ptr(true ),
KubernetesVersion: to.Ptr("" ),
LinuxProfile: &armcontainerservice.LinuxProfile{
AdminUsername: to.Ptr("azureuser" ),
SSH: &armcontainerservice.SSHConfiguration{
PublicKeys: []*armcontainerservice.SSHPublicKey{
{
KeyData: to.Ptr("keydata" ),
}},
},
},
NetworkProfile: &armcontainerservice.NetworkProfile{
LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{
ManagedOutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{
Count: to.Ptr[int32 ](2 ),
},
},
LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard),
OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer),
},
ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{
ClientID: to.Ptr("clientid" ),
Secret: to.Ptr("secret" ),
},
WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{
AdminPassword: to.Ptr("replacePassword1234$" ),
AdminUsername: to.Ptr("azureuser" ),
GmsaProfile: &armcontainerservice.WindowsGmsaProfile{
Enabled: to.Ptr(true ),
},
},
},
SKU: &armcontainerservice.ManagedClusterSKU{
Name: to.Ptr(armcontainerservice.ManagedClusterSKUName("Basic" )),
Tier: to.Ptr(armcontainerservice.ManagedClusterSKUTierFree),
},
}, nil )
if err != nil {
log.Fatalf("failed to finish the request: %v" , err)
}
res, err := poller.PollUntilDone(ctx, nil )
if err != nil {
log.Fatalf("failed to pull the result: %v" , err)
}
_ = res
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require ("@azure/arm-containerservice" );
const { DefaultAzureCredential } = require ("@azure/identity" );
async function createOrUpdateManagedClusterWithWindowsGMsaEnabled ( ) {
const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID" ] || "subid1" ;
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP" ] || "rg1" ;
const resourceName = "clustername1" ;
const parameters = {
addonProfiles : {},
agentPoolProfiles : [
{
name : "nodepool1" ,
type : "VirtualMachineScaleSets" ,
availabilityZones : ["1" , "2" , "3" ],
count : 3 ,
enableNodePublicIP : true ,
mode : "System" ,
osType : "Linux" ,
vmSize : "Standard_DS1_v2" ,
},
],
autoScalerProfile : { scaleDownDelayAfterAdd : "15m" , scanInterval : "20s" },
diskEncryptionSetID :
"/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
dnsPrefix : "dnsprefix1" ,
enablePodSecurityPolicy : true ,
enableRbac : true ,
identity : {
type : "UserAssigned" ,
userAssignedIdentities : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/MicrosoftManagedIdentity/userAssignedIdentities/identity1" :
{},
},
},
kubernetesVersion : "" ,
linuxProfile : {
adminUsername : "azureuser" ,
ssh : { publicKeys : [{ keyData : "keydata" }] },
},
location : "location1" ,
networkProfile : {
loadBalancerProfile : { managedOutboundIPs : { count : 2 } },
loadBalancerSku : "standard" ,
outboundType : "loadBalancer" ,
},
servicePrincipalProfile : { clientId : "clientid" , secret : "secret" },
sku : { name : "Basic" , tier : "Free" },
tags : { archv2 : "" , tier : "production" },
windowsProfile : {
adminPassword : "replacePassword1234$" ,
adminUsername : "azureuser" ,
gmsaProfile : { enabled : true },
},
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.managedClusters.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
parameters
);
console .log(result);
}
To use the Azure SDK library in your project, see this documentation . To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Succeeded" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Succeeded" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System" ,
"nodeImageVersion" : "AKSUbuntu:1604:2020.03.11"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser" ,
"gmsaProfile" : {
"enabled" : true
}
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"fqdn" : "dnsprefix1-abcd1234.hcp.eastus.azmk8s.io" ,
"networkProfile" : {
"loadBalancerSku" : "basic" ,
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
{
"id" : "/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1" ,
"location" : "location1" ,
"name" : "clustername1" ,
"tags" : {
"archv2" : "" ,
"tier" : "production"
},
"type" : "Microsoft.ContainerService/ManagedClusters" ,
"properties" : {
"provisioningState" : "Creating" ,
"maxAgentPools" : 1 ,
"kubernetesVersion" : "1.9.6" ,
"currentKubernetesVersion" : "1.9.6" ,
"dnsPrefix" : "dnsprefix1" ,
"agentPoolProfiles" : [
{
"name" : "nodepool1" ,
"count" : 3 ,
"vmSize" : "Standard_DS1_v2" ,
"maxPods" : 110 ,
"osType" : "Linux" ,
"provisioningState" : "Creating" ,
"orchestratorVersion" : "1.9.6" ,
"currentOrchestratorVersion" : "1.9.6" ,
"type" : "VirtualMachineScaleSets" ,
"availabilityZones" : [
"1" ,
"2" ,
"3"
],
"enableNodePublicIP" : true ,
"mode" : "System"
}
],
"linuxProfile" : {
"adminUsername" : "azureuser" ,
"ssh" : {
"publicKeys" : [
{
"keyData" : "keydata"
}
]
}
},
"windowsProfile" : {
"adminUsername" : "azureuser" ,
"gmsaProfile" : {
"enabled" : true
}
},
"servicePrincipalProfile" : {
"clientId" : "clientid"
},
"nodeResourceGroup" : "MC_rg1_clustername1_location1" ,
"enableRBAC" : true ,
"diskEncryptionSetID" : "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des" ,
"enablePodSecurityPolicy" : true ,
"networkProfile" : {
"networkPlugin" : "kubenet" ,
"podCidr" : "10.244.0.0/16" ,
"serviceCidr" : "10.0.0.0/16" ,
"dnsServiceIP" : "10.0.0.10" ,
"loadBalancerSku" : "standard" ,
"outboundType" : "loadBalancer" ,
"podCidrs" : [
"10.244.0.0/16"
],
"serviceCidrs" : [
"10.0.0.0/16"
],
"ipFamilies" : [
"IPv4"
],
"loadBalancerProfile" : {
"allocatedOutboundPorts" : 2000 ,
"idleTimeoutInMinutes" : 10 ,
"managedOutboundIPs" : {
"count" : 2
},
"effectiveOutboundIPs" : [
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip1"
},
{
"id" : "/subscriptions/subid1/resourceGroups/MC_rg1/providers/Microsoft.Network/publicIPAddresses/mgdoutboundip2"
}
]
}
},
"autoScalerProfile" : {
"scan-interval" : "20s" ,
"scale-down-delay-after-add" : "15m"
}
},
"identity" : {
"type" : "UserAssigned" ,
"userAssignedIdentities" : {
"/subscriptions/subid1/resourceGroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1" : {
"principalId" : "principalId1" ,
"clientId" : "clientId1"
}
}
}
}
Expand table
Enumeration
The mode of an agent pool.
Expand table
Value
Description
System
System agent pools are primarily for hosting critical system pods such as CoreDNS and metrics-server. System agent pools osType must be Linux. System agent pools VM SKU must have at least 2vCPUs and 4GB of memory.
User
User agent pools are primarily for hosting your application pods.
Enumeration
The type of Agent Pool.
Expand table
Value
Description
AvailabilitySet
Use of this is strongly discouraged.
VirtualMachineScaleSets
Create an Agent Pool backed by a Virtual Machine Scale Set.
Object
Settings for upgrading an agentpool
Expand table
Name
Type
Description
drainTimeoutInMinutes
integer
The drain timeout for a node
The amount of time (in minutes) to wait on eviction of pods and graceful termination per node. This eviction wait time honors waiting on pod disruption budgets. If this time is exceeded, the upgrade fails. If not specified, the default is 30 minutes.
maxSurge
string
The maximum number or percentage of nodes that are surged during upgrade.
This can either be set to an integer (e.g. '5') or a percentage (e.g. '50%'). If a percentage is specified, it is the percentage of the total agent pool size at the time of the upgrade. For percentages, fractional nodes are rounded up. If not specified, the default is 1. For more information, including best practices, see: https://docs.microsoft.com/azure/aks/upgrade-cluster#customize-node-surge-upgrade
Object
Parameters to be applied to the cluster-autoscaler when enabled
Expand table
Name
Type
Description
balance-similar-node-groups
string
Detects similar node pools and balances the number of nodes between them.
Valid values are 'true' and 'false'
expander
expander
The expander to use when scaling up
If not specified, the default is 'random'. See expanders for more information.
max-empty-bulk-delete
string
The maximum number of empty nodes that can be deleted at the same time. This must be a positive integer.
The default is 10.
max-graceful-termination-sec
string
The maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node.
The default is 600.
max-node-provision-time
string
The maximum time the autoscaler waits for a node to be provisioned.
The default is '15m'. Values must be an integer followed by an 'm'. No unit of time other than minutes (m) is supported.
max-total-unready-percentage
string
The maximum percentage of unready nodes in the cluster. After this percentage is exceeded, cluster autoscaler halts operations.
The default is 45. The maximum is 100 and the minimum is 0.
new-pod-scale-up-delay
string
Ignore unscheduled pods before they're a certain age.
For scenarios like burst/batch scale where you don't want CA to act before the kubernetes scheduler could schedule all the pods, you can tell CA to ignore unscheduled pods before they're a certain age. The default is '0s'. Values must be an integer followed by a unit ('s' for seconds, 'm' for minutes, 'h' for hours, etc).
ok-total-unready-count
string
The number of allowed unready nodes, irrespective of max-total-unready-percentage.
This must be an integer. The default is 3.
scale-down-delay-after-add
string
How long after scale up that scale down evaluation resumes
The default is '10m'. Values must be an integer followed by an 'm'. No unit of time other than minutes (m) is supported.
scale-down-delay-after-delete
string
How long after node deletion that scale down evaluation resumes.
The default is the scan-interval. Values must be an integer followed by an 'm'. No unit of time other than minutes (m) is supported.
scale-down-delay-after-failure
string
How long after scale down failure that scale down evaluation resumes.
The default is '3m'. Values must be an integer followed by an 'm'. No unit of time other than minutes (m) is supported.
scale-down-unneeded-time
string
How long a node should be unneeded before it is eligible for scale down.
The default is '10m'. Values must be an integer followed by an 'm'. No unit of time other than minutes (m) is supported.
scale-down-unready-time
string
How long an unready node should be unneeded before it is eligible for scale down
The default is '20m'. Values must be an integer followed by an 'm'. No unit of time other than minutes (m) is supported.
scale-down-utilization-threshold
string
Node utilization level, defined as sum of requested resources divided by capacity, below which a node can be considered for scale down.
The default is '0.5'.
scan-interval
string
How often cluster is reevaluated for scale up or down.
The default is '10'. Values must be an integer number of seconds.
skip-nodes-with-local-storage
string
If cluster autoscaler will skip deleting nodes with pods with local storage, for example, EmptyDir or HostPath.
The default is true.
skip-nodes-with-system-pods
string
If cluster autoscaler will skip deleting nodes with pods from kube-system (except for DaemonSet or mirror pods)
The default is true.
Object
Azure Key Vault key management service settings for the security profile.
Expand table
Name
Type
Default value
Description
enabled
boolean
Whether to enable Azure Key Vault key management service. The default is false.
keyId
string
Identifier of Azure Key Vault key. See key identifier format for more details. When Azure Key Vault key management service is enabled, this field is required and must be a valid key identifier. When Azure Key Vault key management service is disabled, leave the field empty.
keyVaultNetworkAccess
KeyVaultNetworkAccessTypes
Public
Network access of the key vault
Network access of key vault. The possible values are Public
and Private
. Public
means the key vault allows public access from all networks. Private
means the key vault disables public access and enables private link. The default value is Public
.
keyVaultResourceId
string
Resource ID of key vault. When keyVaultNetworkAccess is Private
, this field is required and must be a valid resource ID. When keyVaultNetworkAccess is Public
, leave the field empty.
Object
An error response from the Container service.
Expand table
Object
An error response from the Container service.
Expand table
Name
Type
Description
code
string
An identifier for the error. Codes are invariant and are intended to be consumed programmatically.
details
CloudErrorBody []
A list of additional details about the error.
message
string
A message describing the error, intended to be suitable for display in a user interface.
target
string
The target of the particular error. For example, the name of the property in error.
Object
Settings for upgrading a cluster.
Expand table
Enumeration
Tells whether the cluster is Running or Stopped
Expand table
Value
Description
Running
The cluster is running.
Stopped
The cluster is stopped.
ContainerServiceLinuxProfile
Object
Profile for Linux VMs in the container service cluster.
Expand table
Name
Type
Description
adminUsername
string
The administrator username to use for Linux VMs.
ssh
ContainerServiceSshConfiguration
The SSH configuration for Linux-based VMs running on Azure.
ContainerServiceNetworkProfile
Object
Profile of network configuration.
Expand table
Name
Type
Default value
Description
dnsServiceIP
string
10.0.0.10
An IP address assigned to the Kubernetes DNS service. It must be within the Kubernetes service address range specified in serviceCidr.
ipFamilies
ipFamily []
The IP families used to specify IP versions available to the cluster.
IP families are used to determine single-stack or dual-stack clusters. For single-stack, the expected value is IPv4. For dual-stack, the expected values are IPv4 and IPv6.
loadBalancerProfile
ManagedClusterLoadBalancerProfile
Profile of the cluster load balancer.
loadBalancerSku
loadBalancerSku
The load balancer sku for the managed cluster.
The default is 'standard'. See Azure Load Balancer SKUs for more information about the differences between load balancer SKUs.
natGatewayProfile
ManagedClusterNATGatewayProfile
Profile of the cluster NAT gateway.
networkDataplane
networkDataplane
Network dataplane used in the Kubernetes cluster.
networkMode
networkMode
The network mode Azure CNI is configured with.
This cannot be specified if networkPlugin is anything other than 'azure'.
networkPlugin
NetworkPlugin
kubenet
Network plugin used for building the Kubernetes network.
networkPluginMode
NetworkPluginMode
The mode the network plugin should use.
networkPolicy
NetworkPolicy
Network policy used for building the Kubernetes network.
outboundType
outboundType
loadBalancer
The outbound (egress) routing method.
This can only be set at cluster creation time and cannot be changed later. For more information see egress outbound type .
podCidr
string
10.244.0.0/16
A CIDR notation IP range from which to assign pod IPs when kubenet is used.
podCidrs
string[]
The CIDR notation IP ranges from which to assign pod IPs.
One IPv4 CIDR is expected for single-stack networking. Two CIDRs, one for each IP family (IPv4/IPv6), is expected for dual-stack networking.
serviceCidr
string
10.0.0.0/16
A CIDR notation IP range from which to assign service cluster IPs. It must not overlap with any Subnet IP ranges.
serviceCidrs
string[]
The CIDR notation IP ranges from which to assign service cluster IPs.
One IPv4 CIDR is expected for single-stack networking. Two CIDRs, one for each IP family (IPv4/IPv6), is expected for dual-stack networking. They must not overlap with any Subnet IP ranges.
ContainerServiceSshConfiguration
Object
SSH configuration for Linux-based VMs running on Azure.
Expand table
Name
Type
Description
publicKeys
ContainerServiceSshPublicKey []
The list of SSH public keys used to authenticate with Linux-based VMs. A maximum of 1 key may be specified.
ContainerServiceSshPublicKey
Object
Contains information about SSH certificate public key data.
Expand table
Name
Type
Description
keyData
string
Certificate public key used to authenticate with VMs through SSH. The certificate must be in PEM format with or without headers.
Enumeration
The type of identity that created the resource.
Expand table
Value
Description
Application
Key
ManagedIdentity
User
Object
Data used when creating a target resource from a source resource.
Expand table
Name
Type
Description
sourceResourceId
string
This is the ARM ID of the source object to be used to create the target object.
Object
Delegated resource properties - internal use only.
Expand table
Name
Type
Description
location
string
The source resource location - internal use only.
referralResource
string
The delegation id of the referral delegation (optional) - internal use only.
resourceId
string
The ARM resource id of the delegated resource - internal use only.
tenantId
string
The tenant id of the delegated resource - internal use only.
Enumeration
The expander to use when scaling up
Expand table
Value
Description
least-waste
Selects the node group that will have the least idle CPU (if tied, unused memory) after scale-up. This is useful when you have different classes of nodes, for example, high CPU or high memory nodes, and only want to expand those when there are pending pods that need a lot of those resources.
most-pods
Selects the node group that would be able to schedule the most pods when scaling up. This is useful when you are using nodeSelector to make sure certain pods land on certain nodes. Note that this won't cause the autoscaler to select bigger nodes vs. smaller, as it can add multiple smaller nodes at once.
priority
Selects the node group that has the highest priority assigned by the user. It's configuration is described in more details here .
random
Used when you don't have a particular need for the node groups to scale differently.
Object
The complex type of the extended location.
Expand table
Name
Type
Description
name
string
The name of the extended location.
type
ExtendedLocationTypes
The type of the extended location.
Enumeration
The type of the extended location.
Expand table
Value
Description
EdgeZone
Enumeration
GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.
Expand table
Value
Description
MIG1g
MIG2g
MIG3g
MIG4g
MIG7g
Object
Identity for the resource.
Expand table
Name
Type
Description
principalId
string
The principal ID of resource identity.
tenantId
string
The tenant ID of resource.
type
ResourceIdentityType
The identity type.
Enumeration
The IP families used to specify IP versions available to the cluster.
Expand table
Value
Description
IPv4
IPv6
IstioCertificateAuthority
Object
Istio Service Mesh Certificate Authority (CA) configuration. For now, we only support plugin certificates as described here https://aka.ms/asm-plugin-ca
Expand table
Object
Istio components configuration.
Expand table
Object
Istio egress gateway configuration.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable the egress gateway.
nodeSelector
object
NodeSelector for scheduling the egress gateway.
Object
Istio ingress gateway configuration. For now, we support up to one external ingress gateway named aks-istio-ingressgateway-external
and one internal ingress gateway named aks-istio-ingressgateway-internal
.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable the ingress gateway.
mode
IstioIngressGatewayMode
Mode of an ingress gateway.
Enumeration
Mode of an ingress gateway.
Expand table
Value
Description
External
The ingress gateway is assigned a public IP address and is publicly accessible.
Internal
The ingress gateway is assigned an internal IP address and cannot is accessed publicly.
IstioPluginCertificateAuthority
Object
Plugin certificates information for Service Mesh.
Expand table
Name
Type
Description
certChainObjectName
string
Certificate chain object name in Azure Key Vault.
certObjectName
string
Intermediate certificate object name in Azure Key Vault.
keyObjectName
string
Intermediate certificate private key object name in Azure Key Vault.
keyVaultId
string
The resource ID of the Key Vault.
rootCertObjectName
string
Root certificate object name in Azure Key Vault.
Object
Istio service mesh configuration.
Expand table
KeyVaultNetworkAccessTypes
Enumeration
Network access of the key vault
Expand table
Value
Description
Private
Public
Object
Kubelet configurations of agent nodes.
Expand table
Name
Type
Description
allowedUnsafeSysctls
string[]
Allowed list of unsafe sysctls or unsafe sysctl patterns (ending in *
).
containerLogMaxFiles
integer
The maximum number of container log files that can be present for a container. The number must be ≥ 2.
containerLogMaxSizeMB
integer
The maximum size (e.g. 10Mi) of container log file before it is rotated.
cpuCfsQuota
boolean
If CPU CFS quota enforcement is enabled for containers that specify CPU limits.
The default is true.
cpuCfsQuotaPeriod
string
The CPU CFS quota period value.
The default is '100ms.' Valid values are a sequence of decimal numbers with an optional fraction and a unit suffix. For example: '300ms', '2h45m'. Supported units are 'ns', 'us', 'ms', 's', 'm', and 'h'.
cpuManagerPolicy
string
The CPU Manager policy to use.
The default is 'none'. See Kubernetes CPU management policies for more information. Allowed values are 'none' and 'static'.
failSwapOn
boolean
If set to true it will make the Kubelet fail to start if swap is enabled on the node.
imageGcHighThreshold
integer
The percent of disk usage after which image garbage collection is always run.
To disable image garbage collection, set to 100. The default is 85%
imageGcLowThreshold
integer
The percent of disk usage before which image garbage collection is never run.
This cannot be set higher than imageGcHighThreshold. The default is 80%
podMaxPids
integer
The maximum number of processes per pod.
topologyManagerPolicy
string
The Topology Manager policy to use.
For more information see Kubernetes Topology Manager . The default is 'none'. Allowed values are 'none', 'best-effort', 'restricted', and 'single-numa-node'.
Enumeration
Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage.
Expand table
Value
Description
OS
Kubelet will use the OS disk for its data.
Temporary
Kubelet will use the temporary disk for its data.
Enumeration
Different support tiers for AKS managed clusters
Expand table
Value
Description
AKSLongTermSupport
Support for the version extended past the KubernetesOfficial support of 1 year. AKS continues to patch CVEs for another 1 year, for a total of 2 years of support.
KubernetesOfficial
Support for the version is the same as for the open source Kubernetes offering. Official Kubernetes open source community support versions for 1 year after release.
Enumeration
The license type to use for Windows VMs. See Azure Hybrid User Benefits for more details.
Expand table
Value
Description
None
No additional licensing is applied.
Windows_Server
Enables Azure Hybrid User Benefits for Windows VMs.
Object
OS configurations of Linux agent nodes.
Expand table
Name
Type
Description
swapFileSizeMB
integer
The size in MB of a swap file that will be created on each node.
sysctls
SysctlConfig
Sysctl settings for Linux agent nodes.
transparentHugePageDefrag
string
Whether the kernel should make aggressive use of memory compaction to make more hugepages available.
Valid values are 'always', 'defer', 'defer+madvise', 'madvise' and 'never'. The default is 'madvise'. For more information see Transparent Hugepages .
transparentHugePageEnabled
string
Whether transparent hugepages are enabled.
Valid values are 'always', 'madvise', and 'never'. The default is 'always'. For more information see Transparent Hugepages .
Enumeration
The load balancer sku for the managed cluster.
Expand table
Value
Description
basic
Use a basic Load Balancer with limited functionality.
standard
Use a a standard Load Balancer. This is the recommended Load Balancer SKU. For more information about on working with the load balancer in the managed cluster, see the standard Load Balancer article.
Object
Managed cluster.
Expand table
Name
Type
Description
extendedLocation
ExtendedLocation
The extended location of the Virtual Machine.
id
string
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
identity
ManagedClusterIdentity
The identity of the managed cluster, if configured.
location
string
The geo-location where the resource lives
name
string
The name of the resource
properties.aadProfile
ManagedClusterAADProfile
AADProfile specifies attributes for Azure Active Directory integration.
The Azure Active Directory configuration.
properties.addonProfiles
<string,
ManagedClusterAddonProfile >
The profile of managed cluster add-on.
properties.agentPoolProfiles
ManagedClusterAgentPoolProfile []
The agent pool properties.
properties.apiServerAccessProfile
ManagedClusterAPIServerAccessProfile
The access profile for managed cluster API server.
properties.autoScalerProfile
AutoScalerProfile
Parameters to be applied to the cluster-autoscaler when enabled
properties.autoUpgradeProfile
ManagedClusterAutoUpgradeProfile
The auto upgrade configuration.
properties.azureMonitorProfile
ManagedClusterAzureMonitorProfile
Azure Monitor addon profiles for monitoring the managed cluster.
properties.azurePortalFQDN
string
The special FQDN used by the Azure Portal to access the Managed Cluster. This FQDN is for use only by the Azure Portal and should not be used by other clients.
The Azure Portal requires certain Cross-Origin Resource Sharing (CORS) headers to be sent in some responses, which Kubernetes APIServer doesn't handle by default. This special FQDN supports CORS, allowing the Azure Portal to function properly.
properties.currentKubernetesVersion
string
The version of Kubernetes the Managed Cluster is running.
If kubernetesVersion was a fully specified version <major.minor.patch>, this field will be exactly equal to it. If kubernetesVersion was <major.minor>, this field will contain the full <major.minor.patch> version being used.
properties.disableLocalAccounts
boolean
If local accounts should be disabled on the Managed Cluster.
If set to true, getting static credentials will be disabled for this cluster. This must only be used on Managed Clusters that are AAD enabled. For more details see disable local accounts .
properties.diskEncryptionSetID
string
The Resource ID of the disk encryption set to use for enabling encryption at rest.
This is of the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{encryptionSetName}'
properties.dnsPrefix
string
The DNS prefix of the Managed Cluster.
This cannot be updated once the Managed Cluster has been created.
properties.enablePodSecurityPolicy
boolean
(DEPRECATED) Whether to enable Kubernetes pod security policy (preview). PodSecurityPolicy was deprecated in Kubernetes v1.21, and removed from Kubernetes in v1.25. Learn more at https://aka.ms/k8s/psp and https://aka.ms/aks/psp .
properties.enableRBAC
boolean
Whether to enable Kubernetes Role-Based Access Control.
properties.fqdn
string
The FQDN of the master pool.
properties.fqdnSubdomain
string
The FQDN subdomain of the private cluster with custom private dns zone.
This cannot be updated once the Managed Cluster has been created.
properties.httpProxyConfig
ManagedClusterHTTPProxyConfig
Configurations for provisioning the cluster with HTTP proxy servers.
properties.identityProfile
<string,
UserAssignedIdentity >
Identities associated with the cluster.
properties.kubernetesVersion
string
The version of Kubernetes specified by the user.
Both patch version <major.minor.patch> (e.g. 1.20.13) and <major.minor> (e.g. 1.20) are supported. When <major.minor> is specified, the latest supported GA patch version is chosen automatically. Updating the cluster with the same <major.minor> once it has been created (e.g. 1.14.x -> 1.14) will not trigger an upgrade, even if a newer patch version is available. When you upgrade a supported AKS cluster, Kubernetes minor versions cannot be skipped. All upgrades must be performed sequentially by major version number. For example, upgrades between 1.14.x -> 1.15.x or 1.15.x -> 1.16.x are allowed, however 1.14.x -> 1.16.x is not allowed. See upgrading an AKS cluster for more details.
properties.linuxProfile
ContainerServiceLinuxProfile
The profile for Linux VMs in the Managed Cluster.
properties.maxAgentPools
integer
The max number of agent pools for the managed cluster.
properties.networkProfile
ContainerServiceNetworkProfile
The network configuration profile.
properties.nodeResourceGroup
string
The name of the resource group containing agent pool nodes.
properties.oidcIssuerProfile
ManagedClusterOIDCIssuerProfile
The OIDC issuer profile of the Managed Cluster.
properties.podIdentityProfile
ManagedClusterPodIdentityProfile
The pod identity profile of the Managed Cluster.
See use AAD pod identity for more details on AAD pod identity integration.
properties.powerState
PowerState
The Power State of the cluster.
properties.privateFQDN
string
The FQDN of private cluster.
properties.privateLinkResources
PrivateLinkResource []
Private link resources associated with the cluster.
properties.provisioningState
string
The current provisioning state.
properties.publicNetworkAccess
PublicNetworkAccess
PublicNetworkAccess of the managedCluster
Allow or deny public network access for AKS
properties.resourceUID
string
The resourceUID uniquely identifies ManagedClusters that reuse ARM ResourceIds (i.e: create, delete, create sequence)
properties.securityProfile
ManagedClusterSecurityProfile
Security profile for the managed cluster.
properties.serviceMeshProfile
ServiceMeshProfile
Service mesh profile for a managed cluster.
properties.servicePrincipalProfile
ManagedClusterServicePrincipalProfile
Information about a service principal identity for the cluster to use for manipulating Azure APIs.
properties.storageProfile
ManagedClusterStorageProfile
Storage profile for the managed cluster.
properties.supportPlan
KubernetesSupportPlan
The support plan for the Managed Cluster. If unspecified, the default is 'KubernetesOfficial'.
properties.upgradeSettings
ClusterUpgradeSettings
Settings for upgrading a cluster.
properties.windowsProfile
ManagedClusterWindowsProfile
The profile for Windows VMs in the Managed Cluster.
properties.workloadAutoScalerProfile
ManagedClusterWorkloadAutoScalerProfile
Workload Auto-scaler profile for the managed cluster.
sku
ManagedClusterSKU
The managed cluster SKU.
systemData
systemData
Azure Resource Manager metadata containing createdBy and modifiedBy information.
tags
object
Resource tags.
type
string
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
Object
AADProfile specifies attributes for Azure Active Directory integration.
Expand table
Name
Type
Description
adminGroupObjectIDs
string[]
The list of AAD group object IDs that will have admin role of the cluster.
clientAppID
string
(DEPRECATED) The client AAD application ID. Learn more at https://aka.ms/aks/aad-legacy .
enableAzureRBAC
boolean
Whether to enable Azure RBAC for Kubernetes authorization.
managed
boolean
Whether to enable managed AAD.
serverAppID
string
(DEPRECATED) The server AAD application ID. Learn more at https://aka.ms/aks/aad-legacy .
serverAppSecret
string
(DEPRECATED) The server AAD application secret. Learn more at https://aka.ms/aks/aad-legacy .
tenantID
string
The AAD tenant ID to use for authentication. If not specified, will use the tenant of the deployment subscription.
ManagedClusterAddonProfile
Object
A Kubernetes add-on profile for a managed cluster.
Expand table
Name
Type
Description
config
object
Key-value pairs for configuring an add-on.
enabled
boolean
Whether the add-on is enabled or not.
identity
Identity
Information of user assigned identity used by this add-on.
ManagedClusterAgentPoolProfile
Object
Profile for the container service agent pool.
Expand table
Name
Type
Default value
Description
availabilityZones
string[]
The list of Availability zones to use for nodes. This can only be specified if the AgentPoolType property is 'VirtualMachineScaleSets'.
count
integer
Number of agents (VMs) to host docker containers. Allowed values must be in the range of 0 to 1000 (inclusive) for user pools and in the range of 1 to 1000 (inclusive) for system pools. The default value is 1.
creationData
CreationData
CreationData to be used to specify the source Snapshot ID if the node pool will be created/upgraded using a snapshot.
currentOrchestratorVersion
string
The version of Kubernetes the Agent Pool is running.
If orchestratorVersion is a fully specified version <major.minor.patch>, this field will be exactly equal to it. If orchestratorVersion is <major.minor>, this field will contain the full <major.minor.patch> version being used.
enableAutoScaling
boolean
Whether to enable auto-scaler
enableEncryptionAtHost
boolean
Whether to enable host based OS and data drive encryption.
This is only supported on certain VM sizes and in certain Azure regions. For more information, see: https://docs.microsoft.com/azure/aks/enable-host-encryption
enableFIPS
boolean
Whether to use a FIPS-enabled OS.
See Add a FIPS-enabled node pool for more details.
enableNodePublicIP
boolean
Whether each node is allocated its own public IP.
Some scenarios may require nodes in a node pool to receive their own dedicated public IP addresses. A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. For more information see assigning a public IP per node . The default is false.
enableUltraSSD
boolean
Whether to enable UltraSSD
gpuInstanceProfile
GPUInstanceProfile
GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.
hostGroupID
string
The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from, used only in creation scenario and not allowed to changed once set.
This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}. For more information see Azure dedicated hosts .
kubeletConfig
KubeletConfig
Kubelet configurations of agent nodes.
The Kubelet configuration on the agent pool nodes.
kubeletDiskType
KubeletDiskType
Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage.
linuxOSConfig
LinuxOSConfig
OS configurations of Linux agent nodes.
The OS configuration of Linux agent nodes.
maxCount
integer
The maximum number of nodes for auto-scaling
maxPods
integer
The maximum number of pods that can run on a node.
minCount
integer
The minimum number of nodes for auto-scaling
mode
AgentPoolMode
The mode of an agent pool.
A cluster must have at least one 'System' Agent Pool at all times. For additional information on agent pool restrictions and best practices, see: https://docs.microsoft.com/azure/aks/use-system-pools
name
string
Unique name of the agent pool profile in the context of the subscription and resource group.
Windows agent pool names must be 6 characters or less.
nodeImageVersion
string
The version of node image
nodeLabels
object
The node labels to be persisted across all nodes in agent pool.
nodePublicIPPrefixID
string
The public IP prefix ID which VM nodes should use IPs from.
This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPPrefixes/{publicIPPrefixName}
nodeTaints
string[]
The taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule.
orchestratorVersion
string
The version of Kubernetes specified by the user.
Both patch version <major.minor.patch> (e.g. 1.20.13) and <major.minor> (e.g. 1.20) are supported. When <major.minor> is specified, the latest supported GA patch version is chosen automatically. Updating the cluster with the same <major.minor> once it has been created (e.g. 1.14.x -> 1.14) will not trigger an upgrade, even if a newer patch version is available. As a best practice, you should upgrade all node pools in an AKS cluster to the same Kubernetes version. The node pool version must have the same major version as the control plane. The node pool minor version must be within two minor versions of the control plane version. The node pool version cannot be greater than the control plane version. For more information see upgrading a node pool .
osDiskSizeGB
integer
OS Disk Size in GB to be used to specify the disk size for every machine in the master/agent pool. If you specify 0, it will apply the default osDisk size according to the vmSize specified.
osDiskType
OSDiskType
The OS disk type to be used for machines in the agent pool.
The default is 'Ephemeral' if the VM supports it and has a cache disk larger than the requested OSDiskSizeGB. Otherwise, defaults to 'Managed'. May not be changed after creation. For more information see Ephemeral OS .
osSKU
OSSKU
Specifies the OS SKU used by the agent pool. The default is Ubuntu if OSType is Linux. The default is Windows2019 when Kubernetes <= 1.24 or Windows2022 when Kubernetes >= 1.25 if OSType is Windows.
osType
OSType
Linux
The operating system type. The default is Linux.
podSubnetID
string
The ID of the subnet which pods will join when launched.
If omitted, pod IPs are statically assigned on the node subnet (see vnetSubnetID for more details). This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
powerState
PowerState
Whether the Agent Pool is running or stopped.
When an Agent Pool is first created it is initially Running. The Agent Pool can be stopped by setting this field to Stopped. A stopped Agent Pool stops all of its VMs and does not accrue billing charges. An Agent Pool can only be stopped if it is Running and provisioning state is Succeeded
provisioningState
string
The current deployment or provisioning state.
proximityPlacementGroupID
string
The ID for Proximity Placement Group.
scaleDownMode
ScaleDownMode
The scale down mode to use when scaling the Agent Pool.
This also effects the cluster autoscaler behavior. If not specified, it defaults to Delete.
scaleSetEvictionPolicy
ScaleSetEvictionPolicy
Delete
The Virtual Machine Scale Set eviction policy to use.
This cannot be specified unless the scaleSetPriority is 'Spot'. If not specified, the default is 'Delete'.
scaleSetPriority
ScaleSetPriority
Regular
The Virtual Machine Scale Set priority. If not specified, the default is 'Regular'.
spotMaxPrice
number
-1
The max price (in US Dollars) you are willing to pay for spot instances. Possible values are any decimal value greater than zero or -1 which indicates default price to be up-to on-demand.
Possible values are any decimal value greater than zero or -1 which indicates the willingness to pay any on-demand price. For more details on spot pricing, see spot VMs pricing
tags
object
The tags to be persisted on the agent pool virtual machine scale set.
type
AgentPoolType
The type of Agent Pool.
upgradeSettings
AgentPoolUpgradeSettings
Settings for upgrading the agentpool
vmSize
string
The size of the agent pool VMs.
VM size availability varies by region. If a node contains insufficient compute resources (memory, cpu, etc) pods might fail to run correctly. For more details on restricted VM sizes, see: https://docs.microsoft.com/azure/aks/quotas-skus-regions
vnetSubnetID
string
The ID of the subnet which agent pool nodes and optionally pods will join on startup.
If this is not specified, a VNET and subnet will be generated and used. If no podSubnetID is specified, this applies to nodes and pods, otherwise it applies to just nodes. This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
workloadRuntime
WorkloadRuntime
Determines the type of workload a node can run.
ManagedClusterAPIServerAccessProfile
Object
Access profile for managed cluster API server.
Expand table
Name
Type
Description
authorizedIPRanges
string[]
The IP ranges authorized to access the Kubernetes API server.
IP ranges are specified in CIDR format, e.g. 137.117.106.88/29. This feature is not compatible with clusters that use Public IP Per Node, or clusters that are using a Basic Load Balancer. For more information see API server authorized IP ranges .
disableRunCommand
boolean
Whether to disable run command for the cluster or not.
enablePrivateCluster
boolean
Whether to create the cluster as a private cluster or not.
For more details, see Creating a private AKS cluster .
enablePrivateClusterPublicFQDN
boolean
Whether to create additional public FQDN for private cluster or not.
privateDNSZone
string
The private DNS zone mode for the cluster.
The default is System. For more details see configure private DNS zone . Allowed values are 'system' and 'none'.
ManagedClusterAutoUpgradeProfile
Object
Auto upgrade profile for a managed cluster.
Expand table
ManagedClusterAzureMonitorProfile
Object
Azure Monitor addon profiles for monitoring the managed cluster.
Expand table
Name
Type
Description
metrics
ManagedClusterAzureMonitorProfileMetrics
Metrics profile for the Azure Monitor managed service for Prometheus addon. Collect out-of-the-box Kubernetes infrastructure metrics to send to an Azure Monitor Workspace and configure additional scraping for custom targets. See aka.ms/AzureManagedPrometheus for an overview.
ManagedClusterAzureMonitorProfileKubeStateMetrics
Object
Kube State Metrics profile for the Azure Managed Prometheus addon. These optional settings are for the kube-state-metrics pod that is deployed with the addon. See aka.ms/AzureManagedPrometheus-optional-parameters for details.
Expand table
Name
Type
Description
metricAnnotationsAllowList
string
Comma-separated list of Kubernetes annotation keys that will be used in the resource's labels metric (Example: 'namespaces=[kubernetes.io/team,...],pods=[kubernetes.io/team],...'). By default the metric contains only resource name and namespace labels.
metricLabelsAllowlist
string
Comma-separated list of additional Kubernetes label keys that will be used in the resource's labels metric (Example: 'namespaces=[k8s-label-1,k8s-label-n,...],pods=[app],...'). By default the metric contains only resource name and namespace labels.
ManagedClusterAzureMonitorProfileMetrics
Object
Metrics profile for the Azure Monitor managed service for Prometheus addon. Collect out-of-the-box Kubernetes infrastructure metrics to send to an Azure Monitor Workspace and configure additional scraping for custom targets. See aka.ms/AzureManagedPrometheus for an overview.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable or disable the Azure Managed Prometheus addon for Prometheus monitoring. See aka.ms/AzureManagedPrometheus-aks-enable for details on enabling and disabling.
kubeStateMetrics
ManagedClusterAzureMonitorProfileKubeStateMetrics
Kube State Metrics profile for the Azure Managed Prometheus addon. These optional settings are for the kube-state-metrics pod that is deployed with the addon. See aka.ms/AzureManagedPrometheus-optional-parameters for details.
ManagedClusterHTTPProxyConfig
Object
Cluster HTTP proxy configuration.
Expand table
Name
Type
Description
httpProxy
string
The HTTP proxy server endpoint to use.
httpsProxy
string
The HTTPS proxy server endpoint to use.
noProxy
string[]
The endpoints that should not go through proxy.
trustedCa
string
Alternative CA cert to use for connecting to proxy servers.
Object
Identity for the managed cluster.
Expand table
Name
Type
Description
delegatedResources
<string,
DelegatedResource >
The delegated identity resources assigned to this managed cluster. This can only be set by another Azure Resource Provider, and managed cluster only accept one delegated identity resource. Internal use only.
principalId
string
The principal id of the system assigned identity which is used by master components.
tenantId
string
The tenant id of the system assigned identity which is used by master components.
type
ResourceIdentityType
The type of identity used for the managed cluster.
For more information see use managed identities in AKS .
userAssignedIdentities
UserAssignedIdentities
The user identity associated with the managed cluster. This identity will be used in control plane. Only one user assigned identity is allowed.
The keys must be ARM resource IDs in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
ManagedClusterLoadBalancerProfile
Object
Profile of the managed cluster load balancer.
Expand table
Name
Type
Default value
Description
allocatedOutboundPorts
integer
0
The desired number of allocated SNAT ports per VM. Allowed values are in the range of 0 to 64000 (inclusive). The default value is 0 which results in Azure dynamically allocating ports.
effectiveOutboundIPs
ResourceReference []
The effective outbound IP resources of the cluster load balancer.
enableMultipleStandardLoadBalancers
boolean
Enable multiple standard load balancers per AKS cluster or not.
idleTimeoutInMinutes
integer
30
Desired outbound flow idle timeout in minutes. Allowed values are in the range of 4 to 120 (inclusive). The default value is 30 minutes.
managedOutboundIPs
ManagedOutboundIPs
Desired managed outbound IPs for the cluster load balancer.
outboundIPPrefixes
OutboundIPPrefixes
Desired outbound IP Prefix resources for the cluster load balancer.
outboundIPs
OutboundIPs
Desired outbound IP resources for the cluster load balancer.
ManagedClusterManagedOutboundIPProfile
Object
Profile of the managed outbound IP resources of the managed cluster.
Expand table
Name
Type
Default value
Description
count
integer
1
The desired number of outbound IPs created/managed by Azure. Allowed values must be in the range of 1 to 16 (inclusive). The default value is 1.
ManagedClusterNATGatewayProfile
Object
Profile of the managed cluster NAT gateway.
Expand table
Name
Type
Default value
Description
effectiveOutboundIPs
ResourceReference []
The effective outbound IP resources of the cluster NAT gateway.
idleTimeoutInMinutes
integer
4
Desired outbound flow idle timeout in minutes. Allowed values are in the range of 4 to 120 (inclusive). The default value is 4 minutes.
managedOutboundIPProfile
ManagedClusterManagedOutboundIPProfile
Profile of the managed outbound IP resources of the cluster NAT gateway.
ManagedClusterOIDCIssuerProfile
Object
The OIDC issuer profile of the Managed Cluster.
Expand table
Name
Type
Description
enabled
boolean
Whether the OIDC issuer is enabled.
issuerURL
string
The OIDC issuer url of the Managed Cluster.
ManagedClusterPodIdentity
Object
Details about the pod identity assigned to the Managed Cluster.
Expand table
Name
Type
Description
bindingSelector
string
The binding selector to use for the AzureIdentityBinding resource.
identity
UserAssignedIdentity
The user assigned identity details.
name
string
The name of the pod identity.
namespace
string
The namespace of the pod identity.
provisioningInfo
ProvisioningInfo
provisioningState
ManagedClusterPodIdentityProvisioningState
The current provisioning state of the pod identity.
ManagedClusterPodIdentityException
Object
A pod identity exception, which allows pods with certain labels to access the Azure Instance Metadata Service (IMDS) endpoint without being intercepted by the node-managed identity (NMI) server.
Expand table
Name
Type
Description
name
string
The name of the pod identity exception.
namespace
string
The namespace of the pod identity exception.
podLabels
object
The pod labels to match.
ManagedClusterPodIdentityProfile
Object
The pod identity profile of the Managed Cluster.
Expand table
Name
Type
Description
allowNetworkPluginKubenet
boolean
Whether pod identity is allowed to run on clusters with Kubenet networking.
Running in Kubenet is disabled by default due to the security related nature of AAD Pod Identity and the risks of IP spoofing. See using Kubenet network plugin with AAD Pod Identity for more information.
enabled
boolean
Whether the pod identity addon is enabled.
userAssignedIdentities
ManagedClusterPodIdentity []
The pod identities to use in the cluster.
userAssignedIdentityExceptions
ManagedClusterPodIdentityException []
The pod identity exceptions to allow.
ManagedClusterPodIdentityProvisioningError
Object
An error response from the pod identity provisioning.
Expand table
ManagedClusterPodIdentityProvisioningErrorBody
Object
An error response from the pod identity provisioning.
Expand table
Name
Type
Description
code
string
An identifier for the error. Codes are invariant and are intended to be consumed programmatically.
details
ManagedClusterPodIdentityProvisioningErrorBody []
A list of additional details about the error.
message
string
A message describing the error, intended to be suitable for display in a user interface.
target
string
The target of the particular error. For example, the name of the property in error.
ManagedClusterPodIdentityProvisioningState
Enumeration
The current provisioning state of the pod identity.
Expand table
Value
Description
Assigned
Canceled
Deleting
Failed
Succeeded
Updating
ManagedClusterSecurityProfile
Object
Security profile for the container service cluster.
Expand table
ManagedClusterSecurityProfileDefender
Object
Microsoft Defender settings for the security profile.
Expand table
Name
Type
Description
logAnalyticsWorkspaceResourceId
string
Resource ID of the Log Analytics workspace to be associated with Microsoft Defender. When Microsoft Defender is enabled, this field is required and must be a valid workspace resource ID. When Microsoft Defender is disabled, leave the field empty.
securityMonitoring
ManagedClusterSecurityProfileDefenderSecurityMonitoring
Microsoft Defender threat detection for Cloud settings for the security profile.
ManagedClusterSecurityProfileDefenderSecurityMonitoring
Object
Microsoft Defender settings for the security profile threat detection.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable Defender threat detection
ManagedClusterSecurityProfileImageCleaner
Object
Image Cleaner removes unused images from nodes, freeing up disk space and helping to reduce attack surface area. Here are settings for the security profile.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable Image Cleaner on AKS cluster.
intervalHours
integer
Image Cleaner scanning interval in hours.
ManagedClusterSecurityProfileWorkloadIdentity
Object
Workload identity settings for the security profile.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable workload identity.
ManagedClusterServicePrincipalProfile
Object
Information about a service principal identity for the cluster to use for manipulating Azure APIs.
Expand table
Name
Type
Description
clientId
string
The ID for the service principal.
secret
string
The secret password associated with the service principal in plain text.
Object
The SKU of a Managed Cluster.
Expand table
Enumeration
The name of a managed cluster SKU.
Expand table
Value
Description
Base
Base option for the AKS control plane.
Enumeration
The tier of a managed cluster SKU.
Expand table
Value
Description
Free
The cluster management is free, but charged for VM, storage, and networking usage. Best for experimenting, learning, simple testing, or workloads with fewer than 10 nodes. Not recommended for production use cases.
Premium
Cluster has premium capabilities in addition to all of the capabilities included in 'Standard'. Premium enables selection of LongTermSupport (aka.ms/aks/lts) for certain Kubernetes versions.
Standard
Recommended for mission-critical and production workloads. Includes Kubernetes control plane autoscaling, workload-intensive testing, and up to 5,000 nodes per cluster. Guarantees 99.95% availability of the Kubernetes API server endpoint for clusters that use Availability Zones and 99.9% of availability for clusters that don't use Availability Zones.
ManagedClusterStorageProfile
Object
Storage profile for the container service cluster.
Expand table
ManagedClusterStorageProfileBlobCSIDriver
Object
AzureBlob CSI Driver settings for the storage profile.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable AzureBlob CSI Driver. The default value is false.
ManagedClusterStorageProfileDiskCSIDriver
Object
AzureDisk CSI Driver settings for the storage profile.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable AzureDisk CSI Driver. The default value is true.
ManagedClusterStorageProfileFileCSIDriver
Object
AzureFile CSI Driver settings for the storage profile.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable AzureFile CSI Driver. The default value is true.
ManagedClusterStorageProfileSnapshotController
Object
Snapshot Controller settings for the storage profile.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable Snapshot Controller. The default value is true.
ManagedClusterWindowsProfile
Object
Profile for Windows VMs in the managed cluster.
Expand table
Name
Type
Description
adminPassword
string
Specifies the password of the administrator account. Minimum-length: 8 characters Max-length: 123 characters Complexity requirements: 3 out of 4 conditions below need to be fulfilled Has lower characters Has upper characters Has a digit Has a special character (Regex match [\W_]) Disallowed values: "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!"
adminUsername
string
Specifies the name of the administrator account. Restriction: Cannot end in "." Disallowed values: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". Minimum-length: 1 character Max-length: 20 characters
enableCSIProxy
boolean
Whether to enable CSI proxy.
For more details on CSI proxy, see the CSI proxy GitHub repo .
gmsaProfile
WindowsGmsaProfile
The Windows gMSA Profile in the Managed Cluster.
licenseType
licenseType
The license type to use for Windows VMs. See Azure Hybrid User Benefits for more details.
ManagedClusterWorkloadAutoScalerProfile
Object
Workload Auto-scaler profile for the managed cluster.
Expand table
ManagedClusterWorkloadAutoScalerProfileKeda
Object
KEDA (Kubernetes Event-driven Autoscaling) settings for the workload auto-scaler profile.
Expand table
Name
Type
Description
enabled
boolean
Whether to enable KEDA.
ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler
Object
VPA (Vertical Pod Autoscaler) settings for the workload auto-scaler profile.
Expand table
Name
Type
Default value
Description
enabled
boolean
False
Whether to enable VPA. Default value is false.
Object
Desired managed outbound IPs for the cluster load balancer.
Expand table
Name
Type
Default value
Description
count
integer
1
The desired number of IPv4 outbound IPs created/managed by Azure for the cluster load balancer. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 1.
countIPv6
integer
0
The desired number of IPv6 outbound IPs created/managed by Azure for the cluster load balancer. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 0 for single-stack and 1 for dual-stack.
Enumeration
Network dataplane used in the Kubernetes cluster.
Expand table
Value
Description
azure
Use Azure network dataplane.
cilium
Use Cilium network dataplane. See Azure CNI Powered by Cilium for more information.
Enumeration
The network mode Azure CNI is configured with.
Expand table
Value
Description
bridge
This is no longer supported
transparent
No bridge is created. Intra-VM Pod to Pod communication is through IP routes created by Azure CNI. See Transparent Mode for more information.
Enumeration
Network plugin used for building the Kubernetes network.
Expand table
Enumeration
The mode the network plugin should use.
Expand table
Value
Description
overlay
Used with networkPlugin=azure, pods are given IPs from the PodCIDR address space but use Azure Routing Domains rather than Kubenet's method of route tables. For more information visit https://aka.ms/aks/azure-cni-overlay .
Enumeration
Network policy used for building the Kubernetes network.
Expand table
Enumeration
Node OS Upgrade Channel
Expand table
Value
Description
NodeImage
AKS will update the nodes with a newly patched VHD containing security fixes and bugfixes on a weekly cadence. With the VHD update machines will be rolling reimaged to that VHD following maintenance windows and surge settings. No extra VHD cost is incurred when choosing this option as AKS hosts the images.
None
No attempt to update your machines OS will be made either by OS or by rolling VHDs. This means you are responsible for your security updates
Unmanaged
OS updates will be applied automatically through the OS built-in patching infrastructure. Newly scaled in machines will be unpatched initially and will be patched at some point by the OS's infrastructure. Behavior of this option depends on the OS in question. Ubuntu and Mariner apply security patches through unattended upgrade roughly once a day around 06:00 UTC. Windows does not apply security patches automatically and so for them this option is equivalent to None till further notice
Enumeration
The OS disk type to be used for machines in the agent pool.
Expand table
Value
Description
Ephemeral
Ephemeral OS disks are stored only on the host machine, just like a temporary disk. This provides lower read/write latency, along with faster node scaling and cluster upgrades.
Managed
Azure replicates the operating system disk for a virtual machine to Azure storage to avoid data loss should the VM need to be relocated to another host. Since containers aren't designed to have local state persisted, this behavior offers limited value while providing some drawbacks, including slower node provisioning and higher read/write latency.
Enumeration
Specifies the OS SKU used by the agent pool. The default is Ubuntu if OSType is Linux. The default is Windows2019 when Kubernetes <= 1.24 or Windows2022 when Kubernetes >= 1.25 if OSType is Windows.
Expand table
Value
Description
AzureLinux
Use AzureLinux as the OS for node images. Azure Linux is a container-optimized Linux distro built by Microsoft, visit https://aka.ms/azurelinux for more information.
CBLMariner
Deprecated OSSKU. Microsoft recommends that new deployments choose 'AzureLinux' instead.
Ubuntu
Use Ubuntu as the OS for node images.
Windows2019
Use Windows2019 as the OS for node images. Unsupported for system node pools. Windows2019 only supports Windows2019 containers; it cannot run Windows2022 containers and vice versa.
Windows2022
Use Windows2022 as the OS for node images. Unsupported for system node pools. Windows2022 only supports Windows2022 containers; it cannot run Windows2019 containers and vice versa.
Enumeration
The operating system type. The default is Linux.
Expand table
Value
Description
Linux
Use Linux.
Windows
Use Windows.
Object
Desired outbound IP Prefix resources for the cluster load balancer.
Expand table
Name
Type
Description
publicIPPrefixes
ResourceReference []
A list of public IP prefix resources.
Object
Desired outbound IP resources for the cluster load balancer.
Expand table
Enumeration
The outbound (egress) routing method.
Expand table
Value
Description
loadBalancer
The load balancer is used for egress through an AKS assigned public IP. This supports Kubernetes services of type 'loadBalancer'. For more information see outbound type loadbalancer .
managedNATGateway
The AKS-managed NAT gateway is used for egress.
userAssignedNATGateway
The user-assigned NAT gateway associated to the cluster subnet is used for egress. This is an advanced scenario and requires proper network configuration.
userDefinedRouting
Egress paths must be defined by the user. This is an advanced scenario and requires proper network configuration. For more information see outbound type userDefinedRouting .
Object
Describes the Power State of the cluster
Expand table
Name
Type
Description
code
code
Tells whether the cluster is Running or Stopped
Object
A private link resource
Expand table
Name
Type
Description
groupId
string
The group ID of the resource.
id
string
The ID of the private link resource.
name
string
The name of the private link resource.
privateLinkServiceID
string
The private link service ID of the resource, this field is exposed only to NRP internally.
requiredMembers
string[]
The RequiredMembers of the resource
type
string
The resource type.
Object
Expand table
Enumeration
PublicNetworkAccess of the managedCluster
Expand table
Value
Description
Disabled
Enabled
Enumeration
The type of identity used for the managed cluster.
Expand table
Value
Description
None
Do not use a managed identity for the Managed Cluster, service principal will be used instead.
SystemAssigned
Use an implicitly created system assigned managed identity to manage cluster resources. Master components in the control plane such as kube-controller-manager will use the system assigned managed identity to manipulate Azure resources.
UserAssigned
Use a user-specified identity to manage cluster resources. Master components in the control plane such as kube-controller-manager will use the specified user assigned managed identity to manipulate Azure resources.
Object
A reference to an Azure resource.
Expand table
Name
Type
Description
id
string
The fully qualified Azure resource id.
Enumeration
Describes how VMs are added to or removed from Agent Pools. See billing states .
Expand table
Value
Description
Deallocate
Attempt to start deallocated instances (if they exist) during scale up and deallocate instances during scale down.
Delete
Create new instances during scale up and remove instances during scale down.
Enumeration
The Virtual Machine Scale Set eviction policy.
Expand table
Value
Description
Deallocate
Nodes in the underlying Scale Set of the node pool are set to the stopped-deallocated state upon eviction. Nodes in the stopped-deallocated state count against your compute quota and can cause issues with cluster scaling or upgrading.
Delete
Nodes in the underlying Scale Set of the node pool are deleted when they're evicted.
Enumeration
The Virtual Machine Scale Set priority.
Expand table
Value
Description
Regular
Regular VMs will be used.
Spot
Spot priority VMs will be used. There is no SLA for spot nodes. See spot on AKS for more information.
Enumeration
Mode of the service mesh.
Expand table
Value
Description
Disabled
Mesh is disabled.
Istio
Istio deployed as an AKS addon.
Object
Service mesh profile for a managed cluster.
Expand table
Object
Sysctl settings for Linux agent nodes.
Expand table
Name
Type
Description
fsAioMaxNr
integer
Sysctl setting fs.aio-max-nr.
fsFileMax
integer
Sysctl setting fs.file-max.
fsInotifyMaxUserWatches
integer
Sysctl setting fs.inotify.max_user_watches.
fsNrOpen
integer
Sysctl setting fs.nr_open.
kernelThreadsMax
integer
Sysctl setting kernel.threads-max.
netCoreNetdevMaxBacklog
integer
Sysctl setting net.core.netdev_max_backlog.
netCoreOptmemMax
integer
Sysctl setting net.core.optmem_max.
netCoreRmemDefault
integer
Sysctl setting net.core.rmem_default.
netCoreRmemMax
integer
Sysctl setting net.core.rmem_max.
netCoreSomaxconn
integer
Sysctl setting net.core.somaxconn.
netCoreWmemDefault
integer
Sysctl setting net.core.wmem_default.
netCoreWmemMax
integer
Sysctl setting net.core.wmem_max.
netIpv4IpLocalPortRange
string
Sysctl setting net.ipv4.ip_local_port_range.
netIpv4NeighDefaultGcThresh1
integer
Sysctl setting net.ipv4.neigh.default.gc_thresh1.
netIpv4NeighDefaultGcThresh2
integer
Sysctl setting net.ipv4.neigh.default.gc_thresh2.
netIpv4NeighDefaultGcThresh3
integer
Sysctl setting net.ipv4.neigh.default.gc_thresh3.
netIpv4TcpFinTimeout
integer
Sysctl setting net.ipv4.tcp_fin_timeout.
netIpv4TcpKeepaliveProbes
integer
Sysctl setting net.ipv4.tcp_keepalive_probes.
netIpv4TcpKeepaliveTime
integer
Sysctl setting net.ipv4.tcp_keepalive_time.
netIpv4TcpMaxSynBacklog
integer
Sysctl setting net.ipv4.tcp_max_syn_backlog.
netIpv4TcpMaxTwBuckets
integer
Sysctl setting net.ipv4.tcp_max_tw_buckets.
netIpv4TcpTwReuse
boolean
Sysctl setting net.ipv4.tcp_tw_reuse.
netIpv4TcpkeepaliveIntvl
integer
Sysctl setting net.ipv4.tcp_keepalive_intvl.
netNetfilterNfConntrackBuckets
integer
Sysctl setting net.netfilter.nf_conntrack_buckets.
netNetfilterNfConntrackMax
integer
Sysctl setting net.netfilter.nf_conntrack_max.
vmMaxMapCount
integer
Sysctl setting vm.max_map_count.
vmSwappiness
integer
Sysctl setting vm.swappiness.
vmVfsCachePressure
integer
Sysctl setting vm.vfs_cache_pressure.
Object
Metadata pertaining to creation and last modification of the resource.
Expand table
Name
Type
Description
createdAt
string
The timestamp of resource creation (UTC).
createdBy
string
The identity that created the resource.
createdByType
createdByType
The type of identity that created the resource.
lastModifiedAt
string
The timestamp of resource last modification (UTC)
lastModifiedBy
string
The identity that last modified the resource.
lastModifiedByType
createdByType
The type of identity that last modified the resource.
Enumeration
The upgrade channel for auto upgrade. The default is 'none'.
Expand table
Value
Description
node-image
Automatically upgrade the node image to the latest version available. Consider using nodeOSUpgradeChannel instead as that allows you to configure node OS patching separate from Kubernetes version patching
none
Disables auto-upgrades and keeps the cluster at its current version of Kubernetes.
patch
Automatically upgrade the cluster to the latest supported patch version when it becomes available while keeping the minor version the same. For example, if a cluster is running version 1.17.7 and versions 1.17.9, 1.18.4, 1.18.6, and 1.19.1 are available, your cluster is upgraded to 1.17.9.
rapid
Automatically upgrade the cluster to the latest supported patch release on the latest supported minor version. In cases where the cluster is at a version of Kubernetes that is at an N-2 minor version where N is the latest supported minor version, the cluster first upgrades to the latest supported patch version on N-1 minor version. For example, if a cluster is running version 1.17.7 and versions 1.17.9, 1.18.4, 1.18.6, and 1.19.1 are available, your cluster first is upgraded to 1.18.6, then is upgraded to 1.19.1.
stable
Automatically upgrade the cluster to the latest supported patch release on minor version N-1, where N is the latest supported minor version. For example, if a cluster is running version 1.17.7 and versions 1.17.9, 1.18.4, 1.18.6, and 1.19.1 are available, your cluster is upgraded to 1.18.6.
Object
Settings for overrides when upgrading a cluster.
Expand table
Name
Type
Description
forceUpgrade
boolean
Whether to force upgrade the cluster. Note that this option instructs upgrade operation to bypass upgrade protections such as checking for deprecated API usage. Enable this option only with caution.
until
string
Until when the overrides are effective. Note that this only matches the start time of an upgrade, and the effectiveness won't change once an upgrade starts even if the until
expires as upgrade proceeds. This field is not set by default. It must be set for the overrides to take effect.
Object
The user identity associated with the managed cluster. This identity will be used in control plane. Only one user assigned identity is allowed.
Expand table
Object
Details about a user assigned identity.
Expand table
Name
Type
Description
clientId
string
The client ID of the user assigned identity.
objectId
string
The object ID of the user assigned identity.
resourceId
string
The resource ID of the user assigned identity.
Object
Windows gMSA Profile in the managed cluster.
Expand table
Name
Type
Description
dnsServer
string
Specifies the DNS server for Windows gMSA. Set it to empty if you have configured the DNS server in the vnet which is used to create the managed cluster.
enabled
boolean
Whether to enable Windows gMSA.
Specifies whether to enable Windows gMSA in the managed cluster.
rootDomainName
string
Specifies the root domain name for Windows gMSA. Set it to empty if you have configured the DNS server in the vnet which is used to create the managed cluster.
Enumeration
Determines the type of workload a node can run.
Expand table
Value
Description
OCIContainer
Nodes will use Kubelet to run standard OCI container workloads.
WasmWasi
Nodes will use Krustlet to run WASM workloads using the WASI provider (Preview).