コード例 #1
0
def create_node_pool(container_engine_client, module):
    create_node_pool_details = CreateNodePoolDetails()
    for attribute in create_node_pool_details.attribute_map.keys():
        if attribute in module.params:
            setattr(create_node_pool_details, attribute,
                    module.params[attribute])

    node_labels = module.params["initial_node_labels"]
    if node_labels:
        initial_node_labels = []
        for d in node_labels:
            keyvalue = KeyValue()
            if d.get("key", None) and d.get("value", None):
                keyvalue.key = d.get("key")
                keyvalue.value = d.get("value")
                initial_node_labels.append(keyvalue)
        create_node_pool_details.initial_node_labels = initial_node_labels
    # Note: `wait` is "True" by default for `oci_node_pool`, unlike other resources because a node pool is only useful
    # if atleast one node in the node pool reaches ACTIVE state (Installation of Helm components are delayed until a
    # node is available).
    result = oci_ce_utils.create_and_wait(
        resource_type="node_pool",
        create_fn=container_engine_client.create_node_pool,
        kwargs_create={"create_node_pool_details": create_node_pool_details},
        client=container_engine_client,
        get_fn=container_engine_client.get_node_pool,
        get_param="node_pool_id",
        module=module,
    )
    return result
コード例 #2
0
def create_node_pool(container_engine_client, module):
    create_node_pool_details = CreateNodePoolDetails()
    for attribute in create_node_pool_details.attribute_map.keys():
        if attribute in module.params:
            setattr(create_node_pool_details, attribute,
                    module.params[attribute])

    node_labels = module.params['initial_node_labels']
    if node_labels:
        initial_node_labels = []
        for d in node_labels:
            keyvalue = KeyValue()
            if d.get("key", None) and d.get("value", None):
                keyvalue.key = d.get("key")
                keyvalue.value = d.get("value")
                initial_node_labels.append(keyvalue)
        create_node_pool_details.initial_node_labels = initial_node_labels

    result = oci_ce_utils.create_and_wait(
        resource_type="node_pool",
        create_fn=container_engine_client.create_node_pool,
        kwargs_create={"create_node_pool_details": create_node_pool_details},
        client=container_engine_client,
        get_fn=container_engine_client.get_node_pool,
        get_param="node_pool_id",
        module=module)
    return result
コード例 #3
0
def create_cluster(container_engine_client, module):
    create_cluster_details = CreateClusterDetails()
    for attribute in create_cluster_details.attribute_map.keys():
        if attribute in module.params:
            setattr(create_cluster_details, attribute, module.params[attribute])

    options = module.params['options']
    if options:
        cluster_create_options = ClusterCreateOptions()
        cluster_create_options.service_lb_subnet_ids = options['service_lb_subnet_ids']
        if options.get('add_ons', None):
            add_ons = AddOnOptions()
            add_ons.is_kubernetes_dashboard_enabled = options['add_ons']['is_kubernetes_dashboard_enabled']
            add_ons.is_tiller_enabled = options['add_ons']['is_tiller_enabled']
            cluster_create_options.add_ons = add_ons
        if options.get('kubernetes_network_config', None):
            kubernetes_network_config = KubernetesNetworkConfig()
            kubernetes_network_config.pods_cidr = options['kubernetes_network_config']['pods_cidr']
            kubernetes_network_config.services_cidr = options['kubernetes_network_config']['services_cidr']
            cluster_create_options.kubernetes_network_config = kubernetes_network_config
        create_cluster_details.options = cluster_create_options

    result = oci_ce_utils.create_and_wait(resource_type="cluster",
                                          create_fn=container_engine_client.create_cluster,
                                          kwargs_create={"create_cluster_details": create_cluster_details},
                                          client=container_engine_client,
                                          get_fn=container_engine_client.get_cluster,
                                          get_param="cluster_id",
                                          module=module
                                          )
    return result