// 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).
package main
import (
"context"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/containerengine"
"github.com/oracle/oci-go-sdk/v65/example/helpers"
)
func ExampleCreateNodePool() {
// 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.
client, err := containerengine.NewContainerEngineClientWithConfigurationProvider(common.DefaultConfigProvider())
helpers.FatalIfError(err)
// Create a request and dependent object(s).
req := containerengine.CreateNodePoolRequest{CreateNodePoolDetails: containerengine.CreateNodePoolDetails{FreeformTags: map[string]string{"EXAMPLE_KEY_v0MW0": "EXAMPLE_VALUE_8fQJDT0EnQ7qscZEPNV1"},
InitialNodeLabels: []containerengine.KeyValue{containerengine.KeyValue{Key: common.String("EXAMPLE-key-Value"),
Value: common.String("EXAMPLE-value-Value")}},
NodePoolCyclingDetails: &containerengine.NodePoolCyclingDetails{IsNodeCyclingEnabled: common.Bool(false),
MaximumSurge: common.String("EXAMPLE-maximumSurge-Value"),
MaximumUnavailable: common.String("EXAMPLE-maximumUnavailable-Value"),
CycleModes: []containerengine.CycleModeEnum{containerengine.CycleModeBootVolumeReplace,
containerengine.CycleModeInstanceReplace}},
SshPublicKey: common.String("EXAMPLE-sshPublicKey-Value"),
ClusterId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-clusterId-Value"),
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
NodeConfigDetails: &containerengine.CreateNodePoolNodeConfigDetails{PlacementConfigs: []containerengine.NodePoolPlacementConfigDetails{containerengine.NodePoolPlacementConfigDetails{FaultDomains: []string{"EXAMPLE--Value"},
PreemptibleNodeConfig: &containerengine.PreemptibleNodeConfigDetails{PreemptionAction: containerengine.TerminatePreemptionAction{IsPreserveBootVolume: common.Bool(true)}},
SubnetId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"),
AvailabilityDomain: common.String("EXAMPLE-availabilityDomain-Value"),
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value")}},
Size: common.Int(890),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_t0mlV": map[string]interface{}{"EXAMPLE_KEY_1acys": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_Uv1Pl": "EXAMPLE_VALUE_ByT9rRLef4b6rAbDjbaa"},
IsPvEncryptionInTransitEnabled: common.Bool(true),
KmsKeyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value"),
NodePoolPodNetworkOptionDetails: containerengine.OciVcnIpNativeNodePoolPodNetworkOptionDetails{MaxPodsPerNode: common.Int(13),
PodNsgIds: []string{"EXAMPLE--Value"},
PodSubnetIds: []string{"EXAMPLE--Value"}},
NsgIds: []string{"EXAMPLE--Value"}},
NodeShapeConfig: &containerengine.CreateNodeShapeConfigDetails{MemoryInGBs: common.Float32(3630.029),
Ocpus: common.Float32(9110.172)},
QuantityPerSubnet: common.Int(420),
NodeShape: common.String("EXAMPLE-nodeShape-Value"),
KubernetesVersion: common.String("EXAMPLE-kubernetesVersion-Value"),
Name: common.String("EXAMPLE-name-Value"),
NodeEvictionNodePoolSettings: &containerengine.NodeEvictionNodePoolSettings{EvictionGraceDuration: common.String("EXAMPLE-evictionGraceDuration-Value"),
IsForceActionAfterGraceDuration: common.Bool(false),
IsForceDeleteAfterGraceDuration: common.Bool(true)},
NodeImageName: common.String("EXAMPLE-nodeImageName-Value"),
NodeMetadata: map[string]string{"EXAMPLE_KEY_hDeGl": "EXAMPLE_VALUE_ojtzRSThf5NfCsfI3FW8"},
SubnetIds: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_erhsh": map[string]interface{}{"EXAMPLE_KEY_9b2vz": "EXAMPLE--Value"}},
NodeSourceDetails: containerengine.NodeSourceViaImageDetails{ImageId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value"),
BootVolumeSizeInGBs: common.Int64(396)}},
OpcRequestId: common.String("XLQD6I0V306YN8H6AMT4<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}
// Send the request using the service client
resp, err := client.CreateNodePool(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}