Note:

Deploy a Kubernetes Cluster with Terraform using Oracle Cloud Infrastructure Kubernetes Engine

Introduction

Deploying Kubernetes with Terraform on Oracle Cloud Infrastructure Kubernetes Engine (OCI Kubernetes Engine or OKE) offers a streamlined and scalable approach to managing containerized applications in the cloud. OKE, an Oracle Cloud Infrastructure managed Kubernetes service, simplifies the deployment, management, and scaling of Kubernetes clusters.

By using Terraform, an Infrastructure as Code (IaC) tool, you can automate the provisioning and configuration of OKE clusters, ensuring consistency and efficiency. This combination allows for repeatable deployments, infrastructure versioning, and easy updates, making it ideal for cloud-native and DevOps-focused teams looking to leverage Oracle Cloud Infrastructure ecosystem.

In this tutorial, we are going to deploy a very specific Kubernetes architecture on OCI OKE using Terraform.

image

We are going to deploy the following components:

image

Objectives

Prerequisites

Task 1: Clone the Repository with the Terraform Scripts

Task 2: Run Terraform Apply and Create one OKE Cluster with the Necessary Resources (VCN, Subnets and so on)

Task 3: Confirm Terraform Deployment in the OCI Console

Navigate to the OCI Console and confirm the following Terraform deployments.

  1. OCI Kubernetes Engine Cluster

    • Go to the OCI Console.

      1. Navigate to Developer Services and click Kubernetes Clusters (OKE).
      2. Click the oke Kubernetes cluster created in Task 2.

      image

    • Scroll down.

      image

      1. Click Node pools.
      2. Click the np1 node pool.

      image

    • Scroll down.

      image

    • Note that there is one worker node in the np1 node pool.

      image

    • Go to the previous page and click the np2 node pool.

      image

    • Scroll down.

      image

    • Note that there are three worker nodes in the np2 node pool.

      image

  2. Instances

    • Go to the OCI Console.

      1. Navigate to Compute and click Instances.
      2. Review the four worker nodes of the Kubernetes cluster.
      3. Review the operator of the Kubernetes cluster.
      4. Review the bastion host belongs of the Kubernetes cluster.

      image

  3. Virtual Cloud Network

    • Go to the OCI Console, navigate to NetworkingVirtual cloud networks and click the oke VCN.

      image

    • Click Subnets and you can see all the seven subnets, of the Kubernetes cluster.

      image

    • The following image illustrates what we have created so far with the Terraform script.

      image

Task 4: Use Bastion and Operator to Check the Connectivity

In the output you will find some commands to connect to your Kubernetes environment when the Terraform deployment is completed.

Task 5: Delete the Kubernetes Cluster using Terraform

Next Steps

Deploying Kubernetes cluster on OCI Kubernetes Engine using Terraform provides an efficient, automated, and scalable solution for managing containerized applications in the cloud.

By leveraging Terraform’s IaC capabilities, you ensure that your Kubernetes clusters are deployed consistently and can be easily maintained or updated over time.

This integration streamlines the process, allowing for better version control, automated scaling, and a repeatable infrastructure setup. Whether you are managing a single cluster or scaling across environments, this approach empowers teams to manage their Kubernetes workloads with reliability and ease in Oracle Cloud Infrastructure.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.