Giter Club home page Giter Club logo

terraform-oci-k8s's Introduction

Terraform Kubernetes on Oracle Cloud Infrastructure (OKE)

This repository contains the Terraform module for creating a simple but ready-to-use Kubernetes Cluster on Oracle Container Engine for Kubernetes (OKE).

It uses the latest available Kubernetes version available in the Oracle Cloud Infrastructure region and creates a kubeconfig file at completion.

Link to my comprehensive blog post (beginner friendly):

https://napo.io/posts/terraform-kubernetes-multi-cloud-ack-aks-dok-eks-gke-oke/#oracle-cloud-infrastructure

Oracle Logo

Requirements

You need an Oracle Cloud account.

Features

  • Always uses latest Kubernetes version available at Oracle Cloud
  • kubeconfig file generation
  • Creates separate node pool for worker nodes
  • Allows SSH access from workstation IPv4 address only

Notes

  • export KUBECONFIG=./kubeconfig_oci in repo root dir to use the generated kubeconfig file
  • The enable_oracle variable is used in the hajowieland/terraform-kubernetes-multi-cloud module
  • It can take a few minutes after Terraform finishes until the Kubernetes nodes are available!

Defaults

See tables at the end for a comprehensive list of inputs and outputs.

  • Default region: eu-frankfurt-1 (Frankfurt, Germany)
  • Default worker node type: VM.Standard2.1 (1x vCPU, 15.0GB memory)
  • Default worker node pool size: 2 (per subnet, by default we only use one subnet)

Terraform Inputs

Name Description Type Default Required
enable_oracle Enable / Disable Oracle Cloud k8s bool true yes
random_cluster_suffix Random 6 byte hex suffix for cluster name string true
oci_region Oracle Cloud region string eu-frankfurt-1 true
oci_user_ocid Oracle Cloud User OCID string yes
oci_tenancy_ocid Oracle Cloud Tenancy OCID string yes
oci_private_key_path Path to your OCI private key string ~/.oci/oci_api_key.pem yes
oci_public_key_path Path to your OCI public key string ~/.oci/oci_api_key_public.pem yes
oci_fingerprint OCI public key fingerprint string yes
lbs Count of 8-bit numbers of LoadBalancer base_cidr_block number 10 yes
oci_cidr_block OCI VCN CIDR block string 10.0.0.0/16 yes
oci_subnets Count of 8-bit numbers of subnets base_cidr_block number 2 yes
oci_policy_statements OCI Policy Statements in policy language list(string) "Allow service OKE to manage all-resources in tenancy" yes
oci_cluster_name Oracle Cloud OKE Kubernetes cluster name string k8soci yes
oci_node_pool_name Oracle Cloud OKE Kubernetes node pool name string k8s-nodepool-oci yes
oci_cluster_add_ons_kubernetes_dashboard Enable the Kubernetes Dashboard bool false yes
oci_cluster_add_ons_tiller Enable Tiller for helm bool false yes
oke_node_pool_size OKE Kubernetes worker node pool quantity per subnet number 2 yes
oci_node_pool_node_shape OCI Kubernetse node pool Shape string VM.Standard2.1 yes
oci_subnet_prohibit_public_ip_on_vnic OCI VCN subnet prohibits assigning public IPs or not bool true yes
oci_node_pool_ssh_public_key SSH public key to add to each node in the node pool string ~/.ssh/id_rsa.pub yes
oci_node_pool_node_image_name OCI Kubernetes node pool image name string Oracle-Linux-7.6 yes

Outputs

Name Description
kubernetes_version Latest available Kubernetes version on Oracle Cloud
kubeconfig_path_oci generated kubeconfig file name

terraform-oci-k8s's People

Contributors

hajowieland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-oci-k8s's Issues

Error on first run

context

$ terraform --version
Terraform v0.12.13
+ provider.http v1.1.1
+ provider.local v1.4.0
+ provider.oci v3.54.0
+ provider.random v2.2.1

wat

I've cloned the repo as-is, removed the authentication part (using defaults from ~/.oci/config), and on first run got this:

Run 1

Error: Service error:RelatedResourceNotAuthorizedOrNotFound. Unable to retrieve information for VCN or you are not authorized to access it.. http status code: 400. Opc request id: 434c20c2ad18d324bd9df6dd0a228157/D6BFD615BE4E4B3DA0B98828180AAE02/FB68F2090AF94936BC7A108F2945454D

  on main.tf line 297, in resource "oci_containerengine_cluster" "oke":
 297: resource "oci_containerengine_cluster" "oke" {

Run 2

Same result

Run 3

$ terraform apply --target oci_containerengine_cluster.oke
that worked:

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Outputs:
kubernetes_version = v1.13.5

Run 4

Completed the setup

$ terraform apply --auto-approve
...

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Outputs:

kubeconfig_path_oci = ./kubeconfig_oci
kubernetes_version = v1.13.5

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.