Oracle Cloud Infrastructure- OKE and Terraform

#Kubernetes  

Provisioning Kubernetes cluster using terraform. In this article, I am going describe the requirements to provision a Kubernetes cluster on OCI using terraform and deploying an application on Kubernetes cluster

Oracle Cloud Infrastructure

The next-generation cloud is designed to run any application, faster and more securely, for less. Try Oracle Cloud for free

Container Engine for Kubernetes (OKE)

Oracle Cloud Infrastructure Container Engine for Kubernetes is a fully-managed, scalable, and highly available service that you can use to deploy your containerized applications to the cloud. Use Container Engine for Kubernetes (OKE) when your development team wants to reliably build, deploy, and manage cloud-native applications

Terraform

Terraform is an infrastructure as code (IaC) tool that allows you to build, change, and version infrastructure safely and efficiently. This includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.

PART 1

1_q2TMpq9CHBwyxicQ4p2osw.png

OCI Terraform Module https://github.com/oracle-terraform-modules/terraform-oci-oke

Install Terraform

For creating a OKE cluster what you need

  • A VCN, an Internet Gateway, a NAT gateway for private worker node deployment
  • worker subnets( public/private)with a set of security rules
  • load balancer subnets with its security rules

Step 1: Clone the terraform from git and cd terraform-oci-oke folder

Step 2: cp terraform.tfvars.example terraform.tfvars

1_y9TX9DckAL7av_DNZLIwTQ.png

Step 3: Finish Prerequisites or Check my Video(coming soon..)

Create a provider.tf file in root add 2 providers

Provider 1 -home regions

Provider 2- the current region where you want to provision your cluster.

provider "oci" {
  fingerprint      = var.api_fingerprint
  private_key_path = var.api_private_key_path
  region           = var.region
  tenancy_ocid     = var.tenancy_id
  user_ocid        = var.user_id
}

provider "oci" {
  fingerprint      = var.api_fingerprint
  private_key_path = var.api_private_key_path
  region           = var.home_region
  tenancy_ocid     = var.tenancy_id
  user_ocid        = var.user_id
  alias            = "home"
}

step 4: Run terraform init command in the root folder

1_3Top2g_0j2rP4_qK2eZJMw.png

Step 4: Modify terraform.tfvars and add the fields copied in the prerequisites

For example:

1_wdaZMXE-GiP1Dn8MV5jE8w.png

Step 5: Run terraform plan command in the root folder to check any actions are required.

Step 6: Run terraform apply command in the root folder. This would create your OKE Cluster

Start blogging about your favorite technologies and get more readers

Join other developers and claim your FAUN account now!

11

Authority

260

Total Hits

Discussed tools
Kubernetes