Giter Club home page Giter Club logo

terraform-oci-oke-quickstart's Introduction

Terraform Oracle Container Engine for Kubernetes (OKE) Quickstart Module


Warning

$${\color{red}This \space is \space a \space pre-release \space version \space of \space the \space module, \space some \space features}$$ $${\color{red}have \space not \space been \space migrated \space from \space MuShop's}$$ $${\color{red}OKE \space Cluster \space deployment \space yet.}$$

Stack Release Stack Build AquaSec TFSec Terraform Stack License Stack Downloads GitHub issues

This module handles opinionated Oracle Container Engine for Kubernetes (OKE) cluster creation on Oracle Cloud Infrastructure (OCI). This module is designed to be used with the OCI Resource Manager to deploy a cluster in a single step. The module can also be used with the OCI Terraform Provider to deploy a cluster using local or CloudShell Terraform cli.

Note: This project is an alternative to easily create an OKE cluster without the need to use external workarounds and do not need to create compute bastions or jump servers, even if deploying using private endpoints. This is a NO(null_resource ,remote_exec, operator instance, bastion_or_jump_server, out_of_tf_state_sh_scripts) project

Sub modules are provided to create a cluster with a single node pool, or a cluster with multiple node pools. Enables Cluster Autoscaler, OCI Vault(KMS) for customer-managed encryption keys for secrets, block volumes. The module also provides a sub module to create a cluster with a single node pool and a private endpoint to Oracle Resource Manager (ORM).

This repo also includes the modules for deploying the following cluster components on the OKE cluster:

Component Description
Kubernetes Cluster Autoscaler This module deploys the Kubernetes Cluster Autoscaler on the OKE cluster.
Metrics Server This module deploys the Metrics Server on the OKE cluster.
Kubernetes Ingress Nginx Controller This module deploys the Nginx Ingress Controller on the OKE cluster.
Prometheus This module deploys the Prometheus monitoring system on the OKE cluster.
Grafana This module deploys the Grafana monitoring system on the OKE cluster.
Cert Manager This module deploys the Cert Manager on the OKE cluster.

Usage

There are multiple examples included in the examples folder but simple usage is as follows:

module "oke-quickstart" {
  source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.8.0"

  # Oracle Cloud Infrastructure Tenancy and Compartment OCID
  tenancy_ocid     = var.tenancy_ocid
  compartment_ocid = var.compartment_ocid
  region           = var.region

  # Note: Just few arguments are showing here to simplify the basic example. All other arguments are using default values.
  # App Name to identify deployment. Used for naming resources.
  app_name = "Basic"

  # Freeform Tags + Defined Tags. Tags are applied to all resources.
  tag_values = { "freeformTags" = { "Environment" = "Development", "DeploymentType" = "basic" }, "definedTags" = {} }

  # OKE Cluster arguments
  #   cluster_cni_type = "FLANNEL_OVERLAY" # Use "OCI_VCN_IP_NATIVE" for VCN Native PODs Network

  # OKE Node Pool 1 arguments
  #   node_pool_cni_type_1           = "FLANNEL_OVERLAY" # Use "OCI_VCN_IP_NATIVE" for VCN Native PODs Network
  node_pool_autoscaler_enabled_1     = true
  node_pool_initial_num_worker_nodes_1             = 3                                                                         # Minimum number of nodes in the node pool
  node_pool_max_num_worker_nodes_1 = 10                                                                      # Maximum number of nodes in the node pool
  node_pool_instance_shape_1     = { "instanceShape" = "VM.Standard.E4.Flex", "ocpus" = 2, "memory" = 64 } # If not using a Flex shape, ocpus and memory are ignored

  # VCN for OKE arguments
  vcn_cidr_blocks = "10.20.0.0/16"
}

Deploy Using Oracle Resource Manager

NOTE: If you aren't already signed in, when prompted, enter the tenancy and user credentials. Review and accept the terms and conditions.

  1. Click to deploy the stack

    Deploy to Oracle Cloud

  2. Select the region and compartment where you want to deploy the stack.

  3. Follow the on-screen prompts and instructions to create the stack.

  4. After creating the stack, click Terraform Actions, and select Plan.

  5. Wait for the job to be completed, and review the plan.

  6. To make any changes, return to the Stack Details page, click Edit Stack, and make the required changes. Then, run the Plan action again.

  7. If no further changes are necessary, return to the Stack Details page, click Terraform Actions, and select Apply.

Deploy Using the Terraform CLI

Prerequisites

Create a terraform.tfvars file and populate with the required variables or override existing variables.

Note: An example tfvars file is included for reference. Using this file is the preferred way to run the stack from the CLI, because of the large number of variables to manage.

To use this file just copy the example tfvars file and save it in the outermost directory. Next, rename the file to terraform.tfvars. You can override the example values set in this file.

Clone the Module

Clone the source code from suing the following command:

git clone github.com/oracle-quickstart/terraform-oci-oke-quickstart
cd terraform-oci-oke-quickstart

Running Terraform

After specifying the required variables you can run the stack using the following commands:

terraform init
terraform plan
terraform apply
terraform destroy -refresh=false

Terraform Variables

A complete listing of the Terraform variables used in this stack are referenced here.

What's a Terraform Module?

A Terraform Module refers to a self-contained packages of Terraform configurations that are managed as a group. This repo is a Terraform Module and contains many "submodules" which can be composed together to create useful infrastructure patterns.

Which projects use this Module?

MuShop LogoMuShop Logo - Dark Mode oci-cloudnative (MuShop) This project is a reference implementation of a cloud native microservices application on Oracle Cloud Infrastructure (OCI). It is a polyglot multi-tiered application that demonstrates how to build and deploy a cloud native application on OCI using Kubernetes, Docker, Istio and other open source technologies.
oci-micronaut (MuShop) This project is a fork of the original MuShop implementation which used different technologies for each individual Microservice applicationµ and is designed as a demonstration of how to use Micronaut to build applications for Oracle Cloud.
Unreal LogoUnreal Logo - Dark Mode oke-unreal-pixel-streaming This project deploys a Kubernetes cluster on Oracle Cloud Infrastructure (OCI) and deploys the Unreal Pixel Streaming demo application on the cluster.
Sysdig LogoSysdig Logo - Dark Mode oke-sysdig This project deploy a Sysdig Secure agent on an OKE cluster.
Snyk LogoSnyk Logo - Dark Mode oke-snyk This project deploy a Snyk agent on an OKE cluster.

Several other projects, samples, demos, and customers quickstarts also uses this module or used as base.

How is this Terraform Module versioned?

This Terraform Module follows the principles of Semantic Versioning. You can find each new release, along with the changelog, in the Releases Page.

During initial development, the major version will be 0 (e.g., 0.x.y), which indicates the code does not yet have a stable API. Once we hit 1.0.0, we will make every effort to maintain a backwards compatible API and use the MAJOR, MINOR, and PATCH versions on each release to indicate any incompatibilities.

Questions

If you have an issue or a question, please take a look at our FAQs or open an issue.

Contributing

This project welcomes contributions from the community. Before submitting a pull request, see CONTRIBUTING for details.

License

Copyright (c) 2021, 2022 Oracle and/or its affiliates. Released under the Universal Permissive License (UPL), Version 1.0. See LICENSE for more details.

terraform-oci-oke-quickstart's People

Contributors

junior avatar thpham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

terraform-oci-oke-quickstart's Issues

Re run the stack after some changes

I am using the stack and have deployed it.
now I made some changes, like deploying ingress, but now they say that the entire stack will be replaced starting with the vcn.

how can I make my cluster stack less destructible?

Allow to restrict to an specific IP when public access is enabled in Kubernetes API

With defaults will create a security list which allows to any IP to access to the API, which is ok, however I would like to define an specific CIDR or a unique IP with access to this resource.

Why? Because It's an step between convenience and security, it's more secure that let internet abroad to access and will not require setup a more complicated setup with bastion.

Sourcing grafana dashboard variables

I can't seem to figure out how to source the "compartment_id" and "region_deployment" variables of the "oci-compute" and "oci-oke" grafana dashboards with my values from within terraform.

When applying the grafana.tf the values for these values are shown as "${VAR_COMPARTMENT_ID}" and "${VAR_REGION_DEPLOYMENT}" in the grafana GUI for the dashboards - which looks like some kind of planned variable expansion didn't take place.

I've tried to add these env variables for the grafan pods, but the values still show up as ""${VAR_COMPARTMENT_ID}" and "${VAR_REGION_DEPLOYMENT}":

VAR_REGION_DEPLOYMENT: "eu-frankfurt-1"
VAR_COMPARTMENT_ID: "/k8s"
GF_VAR_REGION_DEPLOYMENT: "eu-frankfurt-1"
GF_VAR_COMPARTMENT_ID: "/k8s"

stack creation fails in resource manager

I get the error "Error: missing provider provider["registry.terraform.io/oracle/oci"].home_region"

full logs:

Getting providers from registry and/or custom terraform providers
Initializing modules...
Initializing provider plugins...

  • Finding latest version of hashicorp/cloudinit...
  • Finding hashicorp/local versions matching "~> 2.0"...
  • Finding hashicorp/random versions matching "~> 3.0"...
  • Finding oracle/oci versions matching "~> 4.0, < 5.0.0"...
  • Finding hashicorp/kubernetes versions matching "~> 2.0"...
  • Finding hashicorp/helm versions matching "~> 2.0"...
  • Finding hashicorp/tls versions matching "~> 4.0"...
  • Installing hashicorp/cloudinit v2.3.4...
  • Installed hashicorp/cloudinit v2.3.4 (signed by HashiCorp)
  • Installing hashicorp/local v2.5.1...
  • Installed hashicorp/local v2.5.1 (signed by HashiCorp)
  • Installing hashicorp/random v3.6.2...
  • Installed hashicorp/random v3.6.2 (signed by HashiCorp)
  • Installing oracle/oci v4.123.0...
  • Installed oracle/oci v4.123.0 (signed by a HashiCorp partner, key ID 1533A49284137CEB)
  • Installing hashicorp/kubernetes v2.31.0...
  • Installed hashicorp/kubernetes v2.31.0 (signed by HashiCorp)
  • Installing hashicorp/helm v2.14.0...
  • Installed hashicorp/helm v2.14.0 (signed by HashiCorp)
  • Installing hashicorp/tls v4.0.5...
  • Installed hashicorp/tls v4.0.5 (signed by HashiCorp)
    Partner and community providers are signed by their developers.
    If you'd like to know more about provider signing, you can read about it here:
    https://www.terraform.io/docs/cli/plugins/signing.html
    Terraform has created a lock file .terraform.lock.hcl to record the provider
    selections it made above. Include this file in your version control repository
    so that Terraform can guarantee to make the same selections by default when
    you run "terraform init" in the future.
    Terraform has been successfully initialized!
    You may now begin working with Terraform. Try running "terraform plan" to see
    any changes that are required for your infrastructure. All Terraform commands
    should now work.
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.
    Error: missing provider provider["registry.terraform.io/oracle/oci"].home_region

checkable object status report for unexpected checkable object module.oke.var.cni_type

did a terraform destroy -refresh=false and got a crash here

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!



checkable object status report for unexpected checkable object module.oke.var.cni_type

goroutine 3519 [running]:

runtime/debug.Stack()

	/opt/hostedtoolcache/go/1.21.1/x64/src/runtime/debug/stack.go:24 +0x5e

runtime/debug.PrintStack()

	/opt/hostedtoolcache/go/1.21.1/x64/src/runtime/debug/stack.go:16 +0x13

github.com/hashicorp/terraform/internal/logging.PanicHandler()

	/home/runner/work/terraform/terraform/internal/logging/panic.go:58 +0x13b

panic({0x2b94ec0?, 0xc0008eaf50?})

	/opt/hostedtoolcache/go/1.21.1/x64/src/runtime/panic.go:920 +0x270

github.com/hashicorp/terraform/internal/checks.(*State).reportCheckResult(0xc001113770, {0x390a1d0, 0xc006cbfe30}, 0xc00027d400?, 0x0, 0x50)

	/home/runner/work/terraform/terraform/internal/checks/state_report.go:106 +0x345

github.com/hashicorp/terraform/internal/checks.(*State).ReportCheckResult(0x2fcdc40?, {0x390a1d0?, 0xc006cbfe30?}, 0xc000a5f6a8?, 0x1?, 0x1?)

	/home/runner/work/terraform/terraform/internal/checks/state_report.go:71 +0xc5

github.com/hashicorp/terraform/internal/terraform.evalVariableValidations({{0xc00207f240, 0x1, 0x1}, {{}, {0xc000f9cb70, 0x8}}}, 0xc000e3bba0, {0x3905a08, 0xc000640960}, {0x3922940, ...})

	/home/runner/work/terraform/terraform/internal/terraform/eval_variable.go:252 +0xb52

github.com/hashicorp/terraform/internal/terraform.(*nodeModuleVariable).Execute(0xc000960960, {0x3922940, 0xc000d7e9a0}, 0x5)

	/home/runner/work/terraform/terraform/internal/terraform/node_module_variable.go:198 +0x3f1

github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0076677a0, {0x3922940, 0xc000d7e9a0}, {0x7fa747d30000, 0xc000960960})

	/home/runner/work/terraform/terraform/internal/terraform/graph_walk_context.go:143 +0xbe

github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x2f09cc0, 0xc000960960})

	/home/runner/work/terraform/terraform/internal/terraform/graph.go:78 +0x375

github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc000960a20, {0x2f09cc0, 0xc000960960}, 0xc0067a5dc0)

	/home/runner/work/terraform/terraform/internal/dag/walk.go:384 +0x2e5

created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update in goroutine 3175

	/home/runner/work/terraform/terraform/internal/dag/walk.go:307 +0xde8


any ideas?

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.