Giter Site home page Giter Site logo

terraform-oci-cloudbricks-oke-nodepool's Introduction

OCI Cloud Bricks: Oracle Container (Kubernetes) Engine (OKE) - Node Pool

License: UPL Quality gate

Introduction

The following cloud brick enables you to create a decoupled Oracle Kubernetes Engine Nodepool associated to a particular OKE Cluster

Reference Architecure

The following is the reference architecture associated to this brick.

Reference Architecture

In this case you can take advantage of the decoupled nature of this module and provision as many nodepools as required. You later on can use node affinity to have different types of workload based nodepools (such as GPU enabled ones)

Prerequisites

  • Pre existent OKE Cluster

Sample tfvar file

If Flex shape is in use

########## FLEX SHAPE IN USE ##########
########## SAMPLE TFVAR FILE ##########
########## PROVIDER SPECIFIC VARIABLES ##########
region           = "foo-region-1"
tenancy_ocid     = "ocid1.tenancy.oc1..abcdefg"
user_ocid        = "ocid1.user.oc1..aaaaaaabcdefg"
fingerprint      = "fo:oo:ba:ar:ba:ar"
private_key_path = "/absolute/path/to/api/key/your_api_key.pem"
########## PROVIDER SPECIFIC VARIABLES ##########

########## ARTIFACT SPECIFIC VARIABLES ##########
ssh_public_key                      = "/path/to/public/ssh/key/pub_key"
ssh_private_key                     = "/path/to/public/ssh/key/priv_key"
ssh_public_is_path                  = true
ssh_private_is_path                 = true
oke_cluster_compartment_name        = "MY_ARTIFACT_COMPARTMENT"
oke_network_compartment_name        = "MY_NETWORK_COMPARTMENT"
oke_availability_domain_map         = { "ad1" : "aBCD:foo-REGION-1-AD-1", "ad2" : "aBCD:foo-REGION-1-AD-2" , "ad2" : "aBCD:foo-REGION-1-AD-3" }
oke_cluster_name                    = "my_k8_cluster"
oke_nodepool_network_subnet_name    = "node_pool_subnet"
k8s_version                         = "K8_Version"
node_pool_name                      = "my_node_pool"
node_pool_shape                     = "VM.Standard.E4.Flex"
is_flex_shape                       = true
nodepool_shape_config_ocpus         = 1
nodepool_shape_config_memory_in_gbs = 16
number_of_nodes                     = 3
k8s_label_map                    = { "SampleLabel1" : "SomeText", "SampleLabel1" : "AnotherText" }
########## ARTIFACT SPECIFIC VARIABLES ##########
########## SAMPLE TFVAR FILE ##########
########## FLEX SHAPE IN USE ##########

If Flex shape is not in use

########## FLEX SHAPE NOT IN USE ##########
########## SAMPLE TFVAR FILE ##########
########## PROVIDER SPECIFIC VARIABLES ##########
region           = "foo-region-1"
tenancy_ocid     = "ocid1.tenancy.oc1..abcdefg"
user_ocid        = "ocid1.user.oc1..aaaaaaabcdefg"
fingerprint      = "fo:oo:ba:ar:ba:ar"
private_key_path = "/absolute/path/to/api/key/your_api_key.pem"
########## PROVIDER SPECIFIC VARIABLES ##########

########## ARTIFACT SPECIFIC VARIABLES ##########
ssh_public_key                   = "/path/to/public/ssh/key/pub_key"
ssh_private_key                  = "/path/to/public/ssh/key/priv_key"
ssh_public_is_path               = true
ssh_private_is_path              = true
oke_cluster_compartment_name     = "MY_ARTIFACT_COMPARTMENT"
oke_network_compartment_name     = "MY_NETWORK_COMPARTMENT"
oke_availability_domain_map      = { "ad1" : "aBCD:foo-REGION-1-AD-1", "ad2" : "aBCD:foo-REGION-1-AD-2" , "ad2" : "aBCD:foo-REGION-1-AD-3" }
oke_cluster_name                 = "my_k8_cluster"
oke_nodepool_network_subnet_name = "node_pool_subnet"
k8s_version                      = "K8_Version"
node_pool_name                   = "my_node_pool"
node_pool_shape                  = "VM.Standard2.1"
number_of_nodes                  = 5
k8s_label_map                    = { "SampleLabel1" : "SomeText", "SampleLabel1" : "AnotherText" }
########## ARTIFACT SPECIFIC VARIABLES ##########
########## SAMPLE TFVAR FILE ##########
########## FLEX SHAPE NOT IN USE ##########

Variable specific considerations

  • You can couple as many nodepools as required
  • Variables ssh_public_is_path and ssh_private_is_path should always be set to true if the keys are using a full or relative path. If you hard code this as variable, then turn them to false
  • Variable oke_cluster_name should be the display name of corresponding cluster. If using a modular coupled approach, this name can be obtained from OKE module output
  • Variable oke_nodepool_network_subnet_name should be the subnet where the nodepool will be created. If the nodepool is required to be kept private, then subnet must be private too
  • Variable k8s_version should be passed on following standard v1.xx.yy. For currently supported versions, please refer to the following link
  • If using flex shapes, consider using the correct tfvars file definition
  • Always prefer using nodepool size in odd number

Sample provider

The following is the base provider definition to be used with this module

terraform {
  required_version = ">= 0.13.5"
}
provider "oci" {
  region       = var.region
  tenancy_ocid = var.tenancy_ocid
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  disable_auto_retries = "true"
}

provider "oci" {
  alias        = "home"
  region       = data.oci_identity_region_subscriptions.home_region_subscriptions.region_subscriptions[0].region_name
  tenancy_ocid = var.tenancy_ocid  
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  disable_auto_retries = "true"
}

Variable documentation

Requirements

Name Version
terraform >= 0.13.5

Providers

Name Version
oci 4.36.0
oci.home 4.36.0
random 3.1.0

Modules

No modules.

Resources

Name Type
oci_containerengine_node_pool.oke_node_pool resource
oci_identity_tag.release resource
oci_identity_tag_namespace.devrel resource
random_id.tag resource
oci_containerengine_clusters.OKECLUSTERS data source
oci_core_images.OL79 data source
oci_core_subnets.NODEPOOLSUBNET data source
oci_core_vcns.VCN data source
oci_identity_compartments.COMPARTMENTS data source
oci_identity_compartments.NWCOMPARTMENTS data source
oci_identity_region_subscriptions.home_region_subscriptions data source

Inputs

Name Description Type Default Required
fingerprint API Key Fingerprint for user_ocid derived from public API Key imported in OCI User config any n/a yes
is_flex_shape Boolean that describes if the shape is flex or not bool false no
k8s_label_map Define the list of Kubernetes Labels to apply in nodepool map(any) n/a yes
k8s_version Declares K8 Version any n/a yes
node_metadata A list of key/value pairs to add to each underlying Oracle Cloud Infrastructure nodepool in the node pool on launch. map(any) {} no
node_pool_name Node Pool Name for K8 Cluster any n/a yes
node_pool_shape Shape to be used in node pool members any n/a yes
nodepool_shape_config_memory_in_gbs (Updatable) The total amount of memory available to the nodepool, in gigabytes. string "" no
nodepool_shape_config_ocpus (Updatable) The total number of OCPUs available to the nodepool. string "" no
number_of_nodes Number of Nodes inside Node Pool any n/a yes
oke_availability_domain_map The name of the availability domain in which this node is placed map(any) n/a yes
oke_cluster_compartment_id Defines the compartment OCID where the OKE cluster was created string "" no
oke_cluster_compartment_name Defines the compartment name where the OKE cluster was created string "" no
oke_cluster_name OKE cluster display name any n/a yes
oke_network_compartment_name Defines the compartment where the Network is currently located any n/a yes
oke_nodepool_compartment_id Defines the compartment OCID where the OKE nodepool is created string "" no
oke_nodepool_compartment_name Defines the compartment name where the OKE nodepool is created string "" no
oke_nodepool_network_subnet_name Defines the specific Subnet to be used for this resource any n/a yes
private_key_path Private Key Absolute path location where terraform is executed any n/a yes
region Target region where artifacts are going to be created any n/a yes
source_type The source type of this option. IMAGE means the OCID is of an image string "IMAGE" no
ssh_private_is_path Describes if SSH Private Key is located on file or inside code bool false no
ssh_private_key Private key to log into machine any n/a yes
ssh_public_is_path Describes if SSH Public Key is located on file or inside code bool false no
ssh_public_key Defines SSH Public Key to be used in order to remotely connect to compute nodepool string n/a yes
tenancy_ocid OCID of tenancy any n/a yes
user_ocid User OCID in tenancy. Currently hardcoded to user [email protected] any n/a yes

Outputs

Name Description
node_details Node Pool Member Details
node_pool Node pool details
oke_nodepools Node Pools configured inside OKE

Contributing

This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.

License

Copyright (c) 2021 Oracle and/or its affiliates.

Licensed under the Universal Permissive License (UPL), Version 1.0.

See LICENSE for more details.

terraform-oci-cloudbricks-oke-nodepool's People

Contributors

djukickosta avatar dralquinta avatar timclegg avatar ttscoff avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

terraform-oci-cloudbricks-oke-nodepool's Issues

Nodepool creation will fail when using Ampere Shapes

When using arm flex shapes the lookup of the datasource will always return Intel based shapes, but not ARM compatible

See this:

 + node_source_details {
          + boot_volume_size_in_gbs = (known after apply)
          + image_id                = "ocid1.image.oc1.sa-saopaulo-1.aaaaaaaa35s6u7lmfmqtttsb3fmciugki34nigwc7ipov6tntra3sgd5k2xa"
          + source_type             = "IMAGE"
        }

      + timeouts {
          + create = "30m"
          + delete = "30m"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
module.kubernetes_pool.oci_containerengine_node_pool.oke_node_pool: Creating...
╷
│ Error: 400-InvalidParameter 
│ Provider version: 4.51.0, released on 2021-11-03.  
│ Service: Containerengine Node Pool 
│ Error Message: Invalid nodeShape: Node shape and image are not compatible. 
│ OPC request ID: ebe6d188393b7a183f9c9a43c2fe3eb1/B11A7F7BCFEEF7E247CC04F0794B34BC/68952F5AEBAB5EC2C7C1E716E5C0A13B 
│ Suggestion: Please Update the parameter(s) in the Terraform config as per error message Invalid nodeShape: Node shape and image are not compatible.
│ 
│ 
│   with module.kubernetes_pool.oci_containerengine_node_pool.oke_node_pool,
│   on .terraform/modules/kubernetes_pool/nodepool.tf line 8, in resource "oci_containerengine_node_pool" "oke_node_pool":
│    8: resource "oci_containerengine_node_pool" "oke_node_pool" {
│ 

OCID: ocid1.image.oc1.sa-saopaulo-1.aaaaaaaa35s6u7lmfmqtttsb3fmciugki34nigwc7ipov6tntra3sgd5k2xa. is for : Oracle-Linux-7.9-2021.10.20-0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.