public ContainerServiceAgentPoolImpl DefineAgentPool(string name) { ContainerServiceAgentPoolProfile innerPoolProfile = new ContainerServiceAgentPoolProfile(); innerPoolProfile.Name = name; return(new ContainerServiceAgentPoolImpl(innerPoolProfile, this)); }
protected ContainerService CreateDefaultContainerServiceInput(string rgName, string masterDnsPrefix, string agentPoolDnsPrefix) { var publicKeys = new ContainerServiceSshPublicKey(DefaultSshPublicKey); var agentPoolProfiles = new ContainerServiceAgentPoolProfile(DefaultAgentPoolProfileName, 1, DefaultVmSize, agentPoolDnsPrefix) { }; return(new ContainerService(m_location) { Tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" } }, AgentPoolProfiles = new[] { agentPoolProfiles }, // Todo: DiagnosticsProfile will be available in GA //DiagnosticsProfile = new ContainerServiceDiagnosticsProfile //{ // VmDiagnostics = new ContainerServiceVMDiagnostics // { // Enabled = true // } //}, LinuxProfile = new ContainerServiceLinuxProfile(DefaultLinuxAdminUsername, new ContainerServiceSshConfiguration(new[] { publicKeys }) { }), MasterProfile = new ContainerServiceMasterProfile(masterDnsPrefix) { }, OrchestratorProfile = new ContainerServiceOrchestratorProfile(ContainerServiceOrchestratorTypes.Dcos) { } }); }
///GENMHASH:6A72E02437FDFE34B555349311EFC1FF:1242B313FA0B285B3216EBAAC61FA3DD public KubernetesClusterAgentPoolImpl DefineAgentPool(string name) { ContainerServiceAgentPoolProfile innerPoolProfile = new ContainerServiceAgentPoolProfile() { Name = name }; return(new KubernetesClusterAgentPoolImpl(innerPoolProfile, this)); }
protected ManagedCluster BuildNewCluster() { if (!string.IsNullOrEmpty(ResourceGroupName) && string.IsNullOrEmpty(Location)) { var rg = RmClient.ResourceGroups.Get(ResourceGroupName); Location = rg.Location; WriteVerbose(string.Format(Resources.UsingLocationFromTheResourceGroup, Location, ResourceGroupName)); } if (string.IsNullOrEmpty(DnsNamePrefix)) { DnsNamePrefix = DefaultDnsPrefix(); } WriteVerbose(string.Format(Resources.UsingDnsNamePrefix, DnsNamePrefix)); SshKeyValue = GetSshKey(SshKeyValue); var defaultAgentPoolProfile = new ContainerServiceAgentPoolProfile( "default", NodeVmSize, NodeCount, NodeOsDiskSize, DnsNamePrefix); var pubKey = new List <ContainerServiceSshPublicKey> { new ContainerServiceSshPublicKey(SshKeyValue) }; var linuxProfile = new ContainerServiceLinuxProfile(AdminUserName, new ContainerServiceSshConfiguration(pubKey)); var acsServicePrincipal = EnsureServicePrincipal(ClientIdAndSecret?.UserName, ClientIdAndSecret?.Password?.ToString()); var spProfile = new ContainerServiceServicePrincipalProfile( acsServicePrincipal.SpId, acsServicePrincipal.ClientSecret); WriteVerbose(string.Format(Resources.DeployingYourManagedKubeCluster, AcsSpFilePath)); var managedCluster = new ManagedCluster( Location, name: Name, tags: TagsConversionHelper.CreateTagDictionary(Tag, true), dnsPrefix: DnsNamePrefix, kubernetesVersion: KubernetesVersion, agentPoolProfiles: new List <ContainerServiceAgentPoolProfile> { defaultAgentPoolProfile }, linuxProfile: linuxProfile, servicePrincipalProfile: spProfile); return(managedCluster); }
protected ContainerService CreateDefaultContainerServiceInput(string rgName, string masterDnsPrefix, string agentPoolDnsPrefix) { var publicKeys = new ContainerServiceSshPublicKey { KeyData = DefaultSshPublicKey }; var agentPoolProfiles = new ContainerServiceAgentPoolProfile { DnsPrefix = agentPoolDnsPrefix, Name = DefaultAgentPoolProfileName, VmSize = DefaultVmSize, Count = 1 // This should be added because of AutoRest bug. }; return(new ContainerService { Location = m_location, Tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" } }, AgentPoolProfiles = new [] { agentPoolProfiles }, // Todo: DiagnosticsProfile will be available in GA //DiagnosticsProfile = new ContainerServiceDiagnosticsProfile //{ // VmDiagnostics = new ContainerServiceVMDiagnostics // { // Enabled = true // } //}, LinuxProfile = new ContainerServiceLinuxProfile { AdminUsername = DefaultLinuxAdminUsername, Ssh = new ContainerServiceSshConfiguration { PublicKeys = new [] { publicKeys } } }, MasterProfile = new ContainerServiceMasterProfile { DnsPrefix = masterDnsPrefix }, OrchestratorProfile = new ContainerServiceOrchestratorProfile { OrchestratorType = ContainerServiceOrchestratorTypes.DCOS } }); }
private void Run() { // AgentPoolProfiles if (this.ContainerService.AgentPoolProfiles == null) { this.ContainerService.AgentPoolProfiles = new List <ContainerServiceAgentPoolProfile>(); } var vAgentPoolProfiles = new ContainerServiceAgentPoolProfile(); vAgentPoolProfiles.Name = this.MyInvocation.BoundParameters.ContainsKey("Name") ? this.Name : null; vAgentPoolProfiles.Count = this.Count; vAgentPoolProfiles.VmSize = this.MyInvocation.BoundParameters.ContainsKey("VmSize") ? this.VmSize : null; vAgentPoolProfiles.DnsPrefix = this.MyInvocation.BoundParameters.ContainsKey("DnsPrefix") ? this.DnsPrefix : null; this.ContainerService.AgentPoolProfiles.Add(vAgentPoolProfiles); WriteObject(this.ContainerService); }
private void Run() { // AgentPoolProfiles if (this.ContainerService.AgentPoolProfiles == null) { this.ContainerService.AgentPoolProfiles = new List <ContainerServiceAgentPoolProfile>(); } var vAgentPoolProfiles = new ContainerServiceAgentPoolProfile(); vAgentPoolProfiles.Name = this.IsParameterBound(c => c.Name) ? this.Name : null; vAgentPoolProfiles.Count = this.Count; vAgentPoolProfiles.VmSize = this.IsParameterBound(c => c.VmSize) ? this.VmSize : null; vAgentPoolProfiles.DnsPrefix = this.IsParameterBound(c => c.DnsPrefix) ? this.DnsPrefix : null; this.ContainerService.AgentPoolProfiles.Add(vAgentPoolProfiles); WriteObject(this.ContainerService); }
protected ManagedCluster BuildNewCluster() { if (!string.IsNullOrEmpty(ResourceGroupName) && string.IsNullOrEmpty(Location)) { var rg = RmClient.ResourceGroups.Get(ResourceGroupName); Location = rg.Location; var validLocations = RmClient.Providers.Get("Microsoft.ContainerService").ResourceTypes.ToList().Find(x => x.ResourceType.Equals("managedClusters")).Locations; validLocations = validLocations.Select(l => l.Replace(" ", string.Empty).Replace("-", string.Empty).ToLower()).ToList(); // If the ResourceGroup location name is not valid, use "East US" if (!validLocations.Contains(rg.Location)) { // Add check in case East US is removed from the list of valid locations if (validLocations.Contains("eastus")) { Location = "eastus"; } else { Location = validLocations[0]; } WriteVerbose(string.Format(Resources.UsingDefaultLocation, Location)); } else { WriteVerbose(string.Format(Resources.UsingLocationFromTheResourceGroup, Location, ResourceGroupName)); } } if (string.IsNullOrEmpty(DnsNamePrefix)) { DnsNamePrefix = DefaultDnsPrefix(); } WriteVerbose(string.Format(Resources.UsingDnsNamePrefix, DnsNamePrefix)); SshKeyValue = GetSshKey(SshKeyValue); var defaultAgentPoolProfile = new ContainerServiceAgentPoolProfile( "default", NodeVmSize, NodeCount, NodeOsDiskSize, DnsNamePrefix); var pubKey = new List <ContainerServiceSshPublicKey> { new ContainerServiceSshPublicKey(SshKeyValue) }; var linuxProfile = new ContainerServiceLinuxProfile(AdminUserName, new ContainerServiceSshConfiguration(pubKey)); var acsServicePrincipal = EnsureServicePrincipal(ClientIdAndSecret?.UserName, ClientIdAndSecret?.Password?.ToString()); var spProfile = new ContainerServiceServicePrincipalProfile( acsServicePrincipal.SpId, acsServicePrincipal.ClientSecret); WriteVerbose(string.Format(Resources.DeployingYourManagedKubeCluster, AcsSpFilePath)); var managedCluster = new ManagedCluster( Location, name: Name, tags: TagsConversionHelper.CreateTagDictionary(Tag, true), dnsPrefix: DnsNamePrefix, kubernetesVersion: KubernetesVersion, agentPoolProfiles: new List <ContainerServiceAgentPoolProfile> { defaultAgentPoolProfile }, linuxProfile: linuxProfile, servicePrincipalProfile: spProfile); return(managedCluster); }
///GENMHASH:7A49B979D1157C2A0B68E0EFC009B2BE:75C8B95CEE5BD5CC0585593F400260CA internal ContainerServiceAgentPoolImpl(ContainerServiceAgentPoolProfile inner, ContainerServiceImpl parent) : base(inner, parent) { var subnetId = (inner != null) ? this.Inner.VnetSubnetID : null; this.subnetName = ResourceUtils.NameFromResourceId(subnetId); }
///GENMHASH:98DFA3F9E5796918208C02E358977FEC:C0847EA0CDA78F6D91EFD239C70F0FA7 internal KubernetesClusterAgentPoolImpl(ContainerServiceAgentPoolProfile inner, KubernetesClusterImpl parent) : base(inner, parent) { }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ManagedCluster cluster = null; switch (ParameterSetName) { case IdParameterSet: { var resource = new ResourceIdentifier(Id); ResourceGroupName = resource.ResourceGroupName; Name = resource.ResourceName; break; } case InputObjectParameterSet: { WriteVerbose(Resources.UsingClusterFromPipeline); cluster = PSMapper.Instance.Map <ManagedCluster>(InputObject); var resource = new ResourceIdentifier(cluster.Id); ResourceGroupName = resource.ResourceGroupName; Name = resource.ResourceName; break; } } var msg = $"{Name} in {ResourceGroupName}"; if (ShouldProcess(msg, Resources.UpdateOrCreateAManagedKubernetesCluster)) { RunCmdLet(() => { if (Exists()) { if (cluster == null) { cluster = Client.ManagedClusters.Get(ResourceGroupName, Name); } if (MyInvocation.BoundParameters.ContainsKey("Location")) { throw new CmdletInvocationException(Resources.LocationCannotBeUpdateForExistingCluster); } if (MyInvocation.BoundParameters.ContainsKey("DnsNamePrefix")) { WriteVerbose(Resources.UpdatingDnsNamePrefix); cluster.DnsPrefix = DnsNamePrefix; } if (MyInvocation.BoundParameters.ContainsKey("SshKeyValue")) { WriteVerbose(Resources.UpdatingSshKeyValue); cluster.LinuxProfile.Ssh.PublicKeys = new List <ContainerServiceSshPublicKey> { new ContainerServiceSshPublicKey(GetSshKey(SshKeyValue)) }; } if (ParameterSetName == SpParamSet) { WriteVerbose(Resources.UpdatingServicePrincipal); var acsServicePrincipal = EnsureServicePrincipal(ClientIdAndSecret.UserName, ClientIdAndSecret.Password.ToString()); var spProfile = new ContainerServiceServicePrincipalProfile( acsServicePrincipal.SpId, acsServicePrincipal.ClientSecret); cluster.ServicePrincipalProfile = spProfile; } if (MyInvocation.BoundParameters.ContainsKey("AdminUserName")) { WriteVerbose(Resources.UpdatingAdminUsername); cluster.LinuxProfile.AdminUsername = AdminUserName; } ContainerServiceAgentPoolProfile defaultAgentPoolProfile; if (cluster.AgentPoolProfiles.Any(x => x.Name == "default")) { defaultAgentPoolProfile = cluster.AgentPoolProfiles.First(x => x.Name == "default"); } else { defaultAgentPoolProfile = new ContainerServiceAgentPoolProfile( "default", NodeVmSize, NodeCount, NodeOsDiskSize, DnsNamePrefix ?? DefaultDnsPrefix()); cluster.AgentPoolProfiles.Add(defaultAgentPoolProfile); } if (MyInvocation.BoundParameters.ContainsKey("NodeVmSize")) { WriteVerbose(Resources.UpdatingNodeVmSize); defaultAgentPoolProfile.VmSize = NodeVmSize; } if (MyInvocation.BoundParameters.ContainsKey("NodeCount")) { WriteVerbose(Resources.UpdatingNodeCount); defaultAgentPoolProfile.Count = NodeCount; } if (MyInvocation.BoundParameters.ContainsKey("NodeOsDiskSize")) { WriteVerbose(Resources.UpdatingNodeOsDiskSize); defaultAgentPoolProfile.OsDiskSizeGB = NodeOsDiskSize; } if (MyInvocation.BoundParameters.ContainsKey("KubernetesVersion")) { WriteVerbose(Resources.UpdatingKubernetesVersion); cluster.KubernetesVersion = KubernetesVersion; } if (MyInvocation.BoundParameters.ContainsKey("Tag")) { WriteVerbose(Resources.UpdatingTags); cluster.Tags = TagsConversionHelper.CreateTagDictionary(Tag, true); } WriteVerbose(Resources.UpdatingYourManagedKubernetesCluster); } else { WriteVerbose(Resources.PreparingForDeploymentOfYourNewManagedKubernetesCluster); cluster = BuildNewCluster(); } var kubeCluster = Client.ManagedClusters.CreateOrUpdate(ResourceGroupName, Name, cluster); WriteObject(PSMapper.Instance.Map <PSKubernetesCluster>(kubeCluster)); }); } }
internal ContainerServiceAgentPoolImpl(ContainerServiceAgentPoolProfile inner, ContainerServiceImpl parent) : base(inner, parent) { }