public async Task <ManagedClusterInner> CreateClusterAsync( IResourceGroup resourceGroup, string aksClusterName, ManagedClusterInner clusterDefinition, CancellationToken cancellationToken = default ) { try { Log.Information($"Creating Azure AKS cluster: {aksClusterName} ..."); var cluster = await _containerServiceManagementClient .ManagedClusters .CreateOrUpdateAsync( resourceGroup.Name, aksClusterName, clusterDefinition, cancellationToken ); Log.Information($"Created Azure AKS cluster: {aksClusterName}"); return(cluster); } catch (Exception ex) { Log.Error(ex, $"Failed to create Azure AKS cluster: {aksClusterName}"); throw; } }
///GENMHASH:871354AC57E9E37DD419453445BD56FF:8BF85C2711AE52862B285B2BDAB6D0A0 protected override IKubernetesCluster WrapModel(ManagedClusterInner inner) { if (inner == null) { return(null); } return(new KubernetesClusterImpl(inner.Name, inner, this.Manager)); }
///GENMHASH:DEDF5AE2F1ABB9DF6AD962840B38A58B:0F98D2133F32D8FB212E9B9A457FA932 internal KubernetesClusterImpl(string name, ManagedClusterInner innerObject, IContainerServiceManager manager) : base(name, innerObject, manager) { //$ super(name, innerObject, manager); if (this.Inner.AgentPoolProfiles == null) { this.Inner.AgentPoolProfiles = new List <ContainerServiceAgentPoolProfile>(); } this.useLatestVersion = false; }
///GENMHASH:DEDF5AE2F1ABB9DF6AD962840B38A58B:0F98D2133F32D8FB212E9B9A457FA932 internal KubernetesClusterImpl(string name, ManagedClusterInner innerObject, IContainerServiceManager manager) : base(name, innerObject, manager) { //$ super(name, innerObject, manager); if (this.Inner.AgentPoolProfiles == null) { this.Inner.AgentPoolProfiles = new List <ManagedClusterAgentPoolProfile>(); } this.adminKubeConfigContent = null; this.userKubeConfigContent = null; }
//public async Task<bool> CheckNameAvailabilityAsync( // string aksClusterName, // CancellationToken cancellationToken = default //) { // throw new NotImplementedException(); //} public ManagedClusterInner GetClusterDefinition( IResourceGroup resourceGroup, Application aksApplication, string aksApplicationRbacSecret, string aksClusterName, X509Certificate2 sshCertificate, SubnetInner virtualNetworkSubnet, Workspace operationalInsightsWorkspace, IDictionary <string, string> tags = null ) { tags ??= new Dictionary <string, string>(); var aksDnsPrefix = aksClusterName + "-dns"; var aksClusterX509CertificateOpenSshPublicKey = X509CertificateHelper.GetOpenSSHPublicKey(sshCertificate); var managedClusterDefinition = new ManagedClusterInner( //nodeResourceGroup: aksResourceGroupName // This is not propagated yet. ) { Location = resourceGroup.RegionName, Tags = tags, //ProvisioningState = null, KubernetesVersion = KUBERNETES_VERSION, DnsPrefix = aksDnsPrefix, //Fqdn = null, AgentPoolProfiles = new List <ManagedClusterAgentPoolProfile> { new ManagedClusterAgentPoolProfile { Name = "agentpool", Count = 2, VmSize = ContainerServiceVMSizeTypes.StandardDS2V2, OsDiskSizeGB = 100, OsType = OSType.Linux, VnetSubnetID = virtualNetworkSubnet.Id } }, LinuxProfile = new ContainerServiceLinuxProfile { AdminUsername = "******", Ssh = new ContainerServiceSshConfiguration { PublicKeys = new List <ContainerServiceSshPublicKey> { new ContainerServiceSshPublicKey { KeyData = aksClusterX509CertificateOpenSshPublicKey } } } }, ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile { ClientId = aksApplication.AppId, Secret = aksApplicationRbacSecret }, AddonProfiles = new Dictionary <string, ManagedClusterAddonProfile> { { "omsagent", new ManagedClusterAddonProfile { Enabled = true, Config = new Dictionary <string, string> { { "logAnalyticsWorkspaceResourceID", operationalInsightsWorkspace.Id } } } }, { "httpApplicationRouting", new ManagedClusterAddonProfile { Enabled = false } } }, //NodeResourceGroup = aksResourceGroupName, // This is not propagated yet. EnableRBAC = true, NetworkProfile = new ContainerServiceNetworkProfile { NetworkPlugin = NetworkPlugin.Azure, //PodCidr = "10.244.0.0/16", ServiceCidr = NETWORK_PROFILE_SERVICE_CIDR, DnsServiceIP = NETWORK_PROFILE_DNS_SERVICE_IP, DockerBridgeCidr = NETWORK_PROFILE_DOCKER_BRIDGE_CIDR } }; managedClusterDefinition.Validate(); return(managedClusterDefinition); }
/// <summary> /// Creates or updates a managed cluster. /// </summary> /// <remarks> /// Creates or updates a managed cluster with the specified configuration for /// agents and Kubernetes version. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='resourceName'> /// The name of the managed cluster resource. /// </param> /// <param name='parameters'> /// Parameters supplied to the Create or Update a Managed Cluster operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ManagedClusterInner> BeginCreateOrUpdateAsync(this IManagedClustersOperations operations, string resourceGroupName, string resourceName, ManagedClusterInner parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, resourceName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }