Git Product home page Git Product logo

hajowieland / terraform-kubernetes-multi-cloud Goto Github PK

View Code? Open in Web Editor NEW
49.0 4.0 23.0 174 KB

Terraform to create Kubernetes clusters on multiple public cloud platforms (Aliyun, AWS, Azure, DO, GCP, OCI)

Home Page: https://registry.terraform.io/modules/hajowieland/multi-cloud/kubernetes/

License: GNU General Public License v3.0

HCL 100.00%
terraform kubernetes k8s aws gke aks digitalocean alicloud oci eks

terraform-kubernetes-multi-cloud's Introduction

Terraform Kubernetes Multi-Cloud

Terraform code for creating a handful of simple managed Kubernetes clusters on multiple public cloud platforms.

Managed in this context means the master nodes (= control plane) are managed by the cloud platform provider. We only create the service, the worker nodes and the bare minimum of everything else to get a working K8s cluster.

ℹ️ This is for demonstration and/or learning purposes.

ℹ️ Please do not use this in production.

Link to my comprehensive blog post (beginner friendly):

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

TOC

Public Cloud Platforms

  • ✅ Alibaba Cloud "Managed Kubernetes Cluster Service" (ACK)
  • ✅ Amazon Web Services "Elastic Kubernetes Engine" (EKS)
  • ✅ Digital Ocean "Kubernetes" (DOK)
  • ✅ Google Cloud Platform "Google Kubernetes Engine" (GKE)
  • ✅ Microsoft Azure "Azure Kubernets Service" (AKS)
  • ✅ Oracle Cloud Infrastructure "Container Engine for Kubernetes" (OKE)
  • 🔜 IBM Cloud Kubernetes Service" (IKS) (when their Terraform provider is 0.12-ready)

Features

  • Fully working K8s Clusters
  • Terraform 0.12 code
  • By default creates small node configurations (low costs!)
  • Outputs ready-to-use kubeconfig files at the end
  • 2-3 worker nodes

Requirements

  • Terraform >= 0.12.x
  • You need to have an account on the cloud platforms (of course).

Terraform Inputs

Name Description Type Default Required
enable_alibaba Enable / Disable Alibaba bool false yes
enable_amazon Enable / Disable Amazon bool false yes
enable_digitalocean Enable / Disable DigitalOcean bool false yes
enable_google Enable / Disable Google bool false yes
enable_microsoft Enable / Disable Microsoft bool false yes
enable_oracle Enable / Disable Oracle bool false yes
nodes Kubernetes worker nodes (e.g. 2) number 2 no
ali_access_key Alibaba Cloud AccessKey ID string yes
ali_secret_key Alibaba Cloud Access Key Secret string yes
aws_profile AWS cli profile (e.g. default) string default yes
gcp_project GCP Project ID string yes
az_client_id Azure Service Principal appId string yes
az_client_secret Azure Service Principal password string yes
az_tenant_id Azure Service Principal tenant string yes
do_token Digital Ocean personal access (API) token string yes
oci_user_ocid OCI User OCID string yes
oci_tenancy_ocid OCI Tenancy OCID string yes
oci_fingerprint OCI SSH public key fingerprint string yes

TODO

  • Combine multiple kubeconfig files into one
  • (partly implemented): Allow K8s API access only from workstation IP
  • Fix OCI destroy dependencies

terraform-kubernetes-multi-cloud's People

Contributors

hajowieland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

terraform-kubernetes-multi-cloud's Issues

terraform plan errors

My terraform.tfvars is:

enable_amazon = true
nodes = 3
aws_profile = "default"
enable_microsoft = false

TF version:

~/terraform-kubernetes-multi-cloud$ terraform version
Terraform v0.12.18
+ provider.alicloud v1.68.0
+ provider.aws v2.43.0
+ provider.azurerm v1.39.0
+ provider.digitalocean v1.12.0
+ provider.external v1.2.0
+ provider.google v3.3.0
+ provider.http v1.1.1
+ provider.local v1.4.0
+ provider.null v2.1.2
+ provider.oci v3.56.0
+ provider.random v2.2.1
+ provider.template v2.1.2
~/terraform-kubernetes-multi-cloud$

After terraform init I'm getting:

~/terraform-kubernetes-multi-cloud$ terraform plan

Warning: "agent_pool_profile": [DEPRECATED] This has been replaced by `default_node_pool` and will be removed in version 2.0 of the AzureRM Provider

  on .terraform/modules/microsoft/hajowieland-terraform-azurerm-k8s-a3499e1/main.tf line 45, in resource "azurerm_kubernetes_cluster" "aks":
  45: resource "azurerm_kubernetes_cluster" "aks" {

Error: Error in function call

  on .terraform/modules/google/hajowieland-terraform-google-k8s-82c6fb4/provider.tf line 3, in provider "google":
   3:   credentials = file("account.json")

Call to function "file" failed: no file exists at account.json.

~/terraform-kubernetes-multi-cloud$

After I commented module "google" { and resource "local_file" "kubeconfiggke" { in main.tf:

~/terraform-kubernetes-multi-cloud$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

module.amazon.data.http.workstation-external-ip[0]: Refreshing state...
module.amazon.data.aws_region.current[0]: Refreshing state...
module.amazon.data.aws_availability_zones.available[0]: Refreshing state...

Warning: "agent_pool_profile": [DEPRECATED] This has been replaced by `default_node_pool` and will be removed in version 2.0 of the AzureRM Provider

  on .terraform/modules/microsoft/hajowieland-terraform-azurerm-k8s-a3499e1/main.tf line 45, in resource "azurerm_kubernetes_cluster" "aks":
  45: resource "azurerm_kubernetes_cluster" "aks" {

Error: can not create client, bad configuration: did not find a proper configuration for tenancy

  on <empty> line 0:
  (source code not available)

Error: Error building AzureRM Client: Azure CLI Authorization Profile was not found. Please ensure the Azure CLI is installed and then log-in with `az login`.

  on .terraform/modules/microsoft/hajowieland-terraform-azurerm-k8s-a3499e1/provider.tf line 1, in provider "azurerm":
   1: provider "azurerm" {

~/terraform-kubernetes-multi-cloud$

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.