// 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 ExampleCreateCluster() {
// 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.CreateClusterRequest{CreateClusterDetails: containerengine.CreateClusterDetails{ClusterPodNetworkOptions: []containerengine.ClusterPodNetworkOptionDetails{containerengine.FlannelOverlayClusterPodNetworkOptionDetails{}},
EndpointConfig: &containerengine.CreateClusterEndpointConfigDetails{IsPublicIpEnabled: common.Bool(true),
NsgIds: []string{"EXAMPLE--Value"},
SubnetId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value")},
ImagePolicyConfig: &containerengine.CreateImagePolicyConfigDetails{IsPolicyEnabled: common.Bool(true),
KeyDetails: []containerengine.KeyDetails{containerengine.KeyDetails{KmsKeyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value")}}},
Name: common.String("EXAMPLE-name-Value"),
VcnId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-vcnId-Value"),
Options: &containerengine.ClusterCreateOptions{KubernetesNetworkConfig: &containerengine.KubernetesNetworkConfig{PodsCidr: common.String("EXAMPLE-podsCidr-Value"),
ServicesCidr: common.String("EXAMPLE-servicesCidr-Value")},
PersistentVolumeConfig: &containerengine.PersistentVolumeConfigDetails{FreeformTags: map[string]string{"EXAMPLE_KEY_tZvWv": "EXAMPLE_VALUE_tgYkQQaRy0GMgNyhbc9J"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_wJkK6": map[string]interface{}{"EXAMPLE_KEY_62x91": "EXAMPLE--Value"}}},
ServiceLbConfig: &containerengine.ServiceLbConfigDetails{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_tE6nN": map[string]interface{}{"EXAMPLE_KEY_odMtk": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_Qalg1": "EXAMPLE_VALUE_Ig4gT1F6k6J6x4U0RiBq"}},
ServiceLbSubnetIds: []string{"EXAMPLE--Value"},
AddOns: &containerengine.AddOnOptions{IsKubernetesDashboardEnabled: common.Bool(false),
IsTillerEnabled: common.Bool(false)},
AdmissionControllerOptions: &containerengine.AdmissionControllerOptions{IsPodSecurityPolicyEnabled: common.Bool(true)}},
Type: containerengine.ClusterTypeBasicCluster,
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_HHsFl": map[string]interface{}{"EXAMPLE_KEY_UdgiJ": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_uuRD2": "EXAMPLE_VALUE_wmka4JnxHOBBvBs23P10"},
KmsKeyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value"),
KubernetesVersion: common.String("EXAMPLE-kubernetesVersion-Value")},
OpcRequestId: common.String("XKDJOXQ3O6NNF4Y9BRMS<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}
// Send the request using the service client
resp, err := client.CreateCluster(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}