// 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{NodePoolCyclingDetails: &containerengine.NodePoolCyclingDetails{CycleModes: []containerengine.CycleModeEnum{containerengine.CycleModeBootVolumeReplace,
containerengine.CycleModeInstanceReplace},
IsNodeCyclingEnabled: common.Bool(true),
MaximumSurge: common.String("EXAMPLE-maximumSurge-Value"),
MaximumUnavailable: common.String("EXAMPLE-maximumUnavailable-Value")},
NodeShapeConfig: &containerengine.CreateNodeShapeConfigDetails{MemoryInGBs: common.Float32(8468.37),
Ocpus: common.Float32(8609.708)},
SubnetIds: []string{"EXAMPLE--Value"},
NodeMetadata: map[string]string{"EXAMPLE_KEY_qDduR": "EXAMPLE_VALUE_vsxEWFc6QvpnT9IKmT9C"},
QuantityPerSubnet: common.Int(922),
SshPublicKey: common.String("EXAMPLE-sshPublicKey-Value"),
InitialNodeLabels: []containerengine.KeyValue{containerengine.KeyValue{Key: common.String("EXAMPLE-key-Value"),
Value: common.String("EXAMPLE-value-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"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_nJEIy": map[string]interface{}{"EXAMPLE_KEY_Hd2Jp": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_aqyUK": "EXAMPLE_VALUE_qwgcwsfPe4ZR0BqdcFzT"},
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(175),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_juIC1": map[string]interface{}{"EXAMPLE_KEY_A5ppw": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_vNBYn": "EXAMPLE_VALUE_41fPE7QdhOWjGA0yHnEA"},
IsPvEncryptionInTransitEnabled: common.Bool(true),
KmsKeyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value"),
NodePoolPodNetworkOptionDetails: containerengine.OciVcnIpNativeNodePoolPodNetworkOptionDetails{MaxPodsPerNode: common.Int(54),
PodNsgIds: []string{"EXAMPLE--Value"},
PodSubnetIds: []string{"EXAMPLE--Value"}},
NsgIds: []string{"EXAMPLE--Value"}},
NodeSourceDetails: containerengine.NodeSourceViaImageDetails{BootVolumeSizeInGBs: common.Int64(448),
ImageId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value")},
ClusterId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-clusterId-Value"),
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
NodeShape: common.String("EXAMPLE-nodeShape-Value")},
OpcRequestId: common.String("OVSM404K9NGO30GNR9NU<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)
}