// This is an automatically generated code sample.
// To make this code sample work in your Oracle Cloud tenancy,
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
// boolean, number, and enum parameters with values not fitting your use case).
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.ContainerengineService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Containerengine
{
public class CreateNodePoolExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createNodePoolDetails = new Oci.ContainerengineService.Models.CreateNodePoolDetails
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
ClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-clusterId-Value",
Name = "EXAMPLE-name-Value",
KubernetesVersion = "EXAMPLE-kubernetesVersion-Value",
NodeMetadata = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_2XeTA",
"EXAMPLE_VALUE_zwp3Ut3g6IpuCsoxpV0O"
}
},
NodeImageName = "EXAMPLE-nodeImageName-Value",
NodeSourceDetails = new Oci.ContainerengineService.Models.NodeSourceViaImageDetails
{
ImageId = "ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
BootVolumeSizeInGBs = 941
},
NodeShape = "EXAMPLE-nodeShape-Value",
NodeShapeConfig = new Oci.ContainerengineService.Models.CreateNodeShapeConfigDetails
{
Ocpus = (float)8517.353,
MemoryInGBs = (float)4286.6606
},
InitialNodeLabels = new List<Oci.ContainerengineService.Models.KeyValue>
{
new Oci.ContainerengineService.Models.KeyValue
{
Key = "EXAMPLE-key-Value",
Value = "EXAMPLE-value-Value"
}
},
SshPublicKey = "EXAMPLE-sshPublicKey-Value",
QuantityPerSubnet = 113,
SubnetIds = new List<string>
{
"EXAMPLE--Value"
},
NodeConfigDetails = new Oci.ContainerengineService.Models.CreateNodePoolNodeConfigDetails
{
Size = 862,
NsgIds = new List<string>
{
"EXAMPLE--Value"
},
KmsKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
IsPvEncryptionInTransitEnabled = false,
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_gzjzr",
"EXAMPLE_VALUE_ZkgL0Imxq46aJO0cmEsD"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_np9Ee",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_mtpXK",
"EXAMPLE--Value"
}
}
}
},
PlacementConfigs = new List<Oci.ContainerengineService.Models.NodePoolPlacementConfigDetails>
{
new Oci.ContainerengineService.Models.NodePoolPlacementConfigDetails
{
AvailabilityDomain = "EXAMPLE-availabilityDomain-Value",
SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
CapacityReservationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
PreemptibleNodeConfig = new Oci.ContainerengineService.Models.PreemptibleNodeConfigDetails
{
PreemptionAction = new Oci.ContainerengineService.Models.TerminatePreemptionAction
{
IsPreserveBootVolume = false
}
},
FaultDomains = new List<string>
{
"EXAMPLE--Value"
}
}
},
NodePoolPodNetworkOptionDetails = new Oci.ContainerengineService.Models.FlannelOverlayNodePoolPodNetworkOptionDetails
{
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_IF0pu",
"EXAMPLE_VALUE_5dG48dmjQsjD9J7ULqtt"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_fmO4P",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_S7PMO",
"EXAMPLE--Value"
}
}
}
},
NodeEvictionNodePoolSettings = new Oci.ContainerengineService.Models.NodeEvictionNodePoolSettings
{
EvictionGraceDuration = "EXAMPLE-evictionGraceDuration-Value",
IsForceDeleteAfterGraceDuration = true,
IsForceActionAfterGraceDuration = true
},
NodePoolCyclingDetails = new Oci.ContainerengineService.Models.NodePoolCyclingDetails
{
MaximumUnavailable = "EXAMPLE-maximumUnavailable-Value",
MaximumSurge = "EXAMPLE-maximumSurge-Value",
IsNodeCyclingEnabled = false,
CycleModes = new List<Oci.ContainerengineService.Models.CycleMode>
{
Oci.ContainerengineService.Models.CycleMode.BootVolumeReplace,
Oci.ContainerengineService.Models.CycleMode.InstanceReplace
}
},
SecondaryVnics = new List<Oci.ContainerengineService.Models.NodePoolSecondaryVnicDetails>
{
new Oci.ContainerengineService.Models.NodePoolSecondaryVnicDetails
{
CreateVnicDetails = new Oci.ContainerengineService.Models.CreateVnicDetails
{
DisplayName = "EXAMPLE-displayName-Value",
AssignIpv6Ip = false,
AssignPublicIp = false,
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_qfTZ9",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_uH29n",
"EXAMPLE--Value"
}
}
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_WUQWv",
"EXAMPLE_VALUE_n3CjKfPcO51BitCdPCZn"
}
},
IpCount = 13,
ApplicationResources = new List<string>
{
"EXAMPLE--Value"
},
Ipv6AddressIpv6SubnetCidrPairDetails = new List<Oci.ContainerengineService.Models.Ipv6AddressIpv6SubnetCidrPairDetails>
{
new Oci.ContainerengineService.Models.Ipv6AddressIpv6SubnetCidrPairDetails
{
Ipv6Address = "EXAMPLE-ipv6Address-Value",
Ipv6SubnetCidr = "EXAMPLE-ipv6SubnetCidr-Value"
}
},
NsgIds = new List<string>
{
"EXAMPLE--Value"
},
SkipSourceDestCheck = true,
SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
},
DisplayName = "EXAMPLE-displayName-Value",
NicIndex = 7
}
},
NetworkLaunchType = Oci.ContainerengineService.Models.NetworkLaunchType.Paravirtualized,
};
var createNodePoolRequest = new Oci.ContainerengineService.Requests.CreateNodePoolRequest
{
CreateNodePoolDetails = createNodePoolDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "CNGZRUUSE3TTJBNX59LV<unique_ID>"
};
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
try
{
// Create a service client and send the request.
using (var client = new ContainerEngineClient(provider, new ClientConfiguration()))
{
var response = await client.CreateNodePool(createNodePoolRequest);
// Retrieve value from the response.
var versionValue = response.httpResponseMessage.Version;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateNodePool Failed with {e.Message}");
throw e;
}
}
}
}