All Projects โ†’ Artemmkin โ†’ Terraform Kubernetes

Artemmkin / Terraform Kubernetes

Licence: apache-2.0
Example of deploying a Kubernetes cluster to Google Cloud using Terraform

Projects that are alternatives of or similar to Terraform Kubernetes

Airflow Toolkit
Any Airflow project day 1, you can spin up a local desktop Kubernetes Airflow environment AND one in Google Cloud Composer with tested data pipelines(DAGs) ๐Ÿ–ฅ >> [ ๐Ÿš€, ๐Ÿšข ]
Stars: โœญ 51 (-66.45%)
Mutual labels:  google-cloud, terraform, hcl, kubernetes-deployment
Terraform Aws Eks
Terraform module to create an Elastic Kubernetes (EKS) cluster and associated worker instances on AWS
Stars: โœญ 2,464 (+1521.05%)
Mutual labels:  terraform, hcl, kubernetes-deployment
Terraformer
CLI tool to generate terraform files from existing infrastructure (reverse Terraform). Infrastructure to Code
Stars: โœญ 6,316 (+4055.26%)
Mutual labels:  google-cloud, terraform, hcl
Terraform Aws Gitlab Runner
Terraform module for AWS GitLab runners on ec2 (spot) instances
Stars: โœญ 292 (+92.11%)
Mutual labels:  terraform, hcl, gitlab-ci
Terraform Openstack Rke
Terraform Openstack RKE
Stars: โœญ 23 (-84.87%)
Mutual labels:  terraform, hcl, kubernetes-deployment
Atlantis On Gke
A set of @HashiCorp Terraform configurations for running Atlantis on @GoogleCloud GKE
Stars: โœญ 44 (-71.05%)
Mutual labels:  google-cloud, terraform, hcl
Kubenow
Deploy Kubernetes. Now!
Stars: โœญ 285 (+87.5%)
Mutual labels:  terraform, hcl, helm
Terraform Google Vault
Terraform module to deploy Vault as a container on Google Cloud Run
Stars: โœญ 25 (-83.55%)
Mutual labels:  google-cloud, terraform, hcl
Typhoon
Minimal and free Kubernetes distribution with Terraform
Stars: โœญ 1,397 (+819.08%)
Mutual labels:  google-cloud, terraform, hcl
Ops Cli
Ops - cli wrapper for Terraform, Ansible, Helmfile and SSH for cloud automation
Stars: โœญ 152 (+0%)
Mutual labels:  terraform, helm, kubernetes-deployment
Terraform Google Vault
Modular deployment of Vault on Google Compute Engine with Terraform
Stars: โœญ 147 (-3.29%)
Mutual labels:  terraform, hcl
Terraform Aws Elasticsearch
Terraform module to provision an Elasticsearch cluster with built-in integrations with Kibana and Logstash.
Stars: โœญ 137 (-9.87%)
Mutual labels:  terraform, hcl
Terragrunt Infrastructure Modules Example
A repo used to show examples file/folder structures you can use with Terragrunt and Terraform
Stars: โœญ 135 (-11.18%)
Mutual labels:  terraform, hcl
Terraform Google Gke Cluster
A Terraform module to create a best-practise Google Kubernetes Engine (GKE) cluster.
Stars: โœญ 133 (-12.5%)
Mutual labels:  terraform, hcl
Terraform Aws Airship Ecs Service
Terraform module which creates an ECS Service, IAM roles, Scaling, ALB listener rules.. Fargate & AWSVPC compatible
Stars: โœญ 139 (-8.55%)
Mutual labels:  terraform, hcl
Terraform Aws Cicd
Terraform Module for CI/CD with AWS Code Pipeline and Code Build
Stars: โœญ 138 (-9.21%)
Mutual labels:  terraform, hcl
Terraform Vsphere Kubespray
Deploy a Kubernetes HA cluster on VMware vSphere
Stars: โœญ 141 (-7.24%)
Mutual labels:  terraform, hcl
Terraform With Circleci Example
This is an example of automatic deployments of your infrastructure using terraform and CircleCI 2.0 workflows
Stars: โœญ 142 (-6.58%)
Mutual labels:  terraform, hcl
Multi Env Deploy
Complete example of deploying complex web apps to AWS using Terraform, Ansible, and Packer
Stars: โœญ 132 (-13.16%)
Mutual labels:  terraform, hcl
Example Pragmatic Terraform On Aws
ๆŠ€่ก“ๆ›ธๅ…ธ6ใง้ ’ๅธƒใ—ใŸใ€ŽPragmatic Terraform on AWS ใ€ใฎใ‚ตใƒณใƒ—ใƒซใ‚ณใƒผใƒ‰ใ‚’ๅ…ฌ้–‹ใ—ใฆใ„ใพใ™
Stars: โœญ 140 (-7.89%)
Mutual labels:  terraform, hcl

Table of Contents

About the repo

This repository contains an example of deploying and managing Kubernetes clusters to Google Cloud Platform (GCP) in a reliable and repeatable way.

Terraform is used to describe the desired state of the infrastructure, thus implementing Infrastructure as Code (IaC) approach.

Google Kubernetes Engine (GKE) service is used for cluster deployment. Since Google announced that they had eliminated the cluster management fees for GKE, it became the safest and cheapest way to run a Kubernetes cluster on GCP, because you only pay for the nodes (compute instances) running in your cluster and Google abstracts away and takes care of the master control plane.

Quick start

Prerequisite: make sure you're authenticated to GCP via gcloud command line tool using either default application credentials or service account with proper access.

Check terraform.tfvars.example file inside my-cluster folder to see what variables you need to define before you can use terraform to create a cluster.

You can run the following command in my-cluster to make your variables definitions available to terraform:

$ mv terraform.tfvars.example terraform.tfvars # variables defined in terraform.tfvars will be automatically picked up by terraform during the run

Once the required variables are defined, use the commands below to create a Kubernetes cluster:

$ terraform init
$ terraform apply

After the cluster is created, run a command from terraform output to configure access to the cluster via kubectl command line tool. The command from terraform output will be in the form of:

$ gcloud container clusters get-credentials my-cluster --zone europe-west1-b --project example-123456

Repository structure

โ”œโ”€โ”€ accounts
โ”‚   โ””โ”€โ”€ service-accounts
โ”œโ”€โ”€ my-cluster
โ”‚   โ”œโ”€โ”€ deploy-app-example
โ”‚   โ””โ”€โ”€ k8s-config
โ”‚       โ”œโ”€โ”€ charts
โ”‚       โ”‚   โ””โ”€โ”€ gitlab-omnibus
โ”‚       โ”‚       โ”œโ”€โ”€ charts
โ”‚       โ”‚       โ”‚   โ””โ”€โ”€ gitlab-runner
โ”‚       โ”‚       โ”‚       โ””โ”€โ”€ templates
โ”‚       โ”‚       โ””โ”€โ”€ templates
โ”‚       โ”‚           โ”œโ”€โ”€ fast-storage
โ”‚       โ”‚           โ”œโ”€โ”€ gitlab
โ”‚       โ”‚           โ”œโ”€โ”€ ingress
โ”‚       โ”‚           โ””โ”€โ”€ load-balancer
โ”‚       โ”‚               โ””โ”€โ”€ nginx
โ”‚       โ”œโ”€โ”€ env-namespaces
โ”‚       โ”œโ”€โ”€ kube-lego
โ”‚       โ””โ”€โ”€ storage-classes
โ””โ”€โ”€ terraform-modules
    โ”œโ”€โ”€ cluster
    โ”œโ”€โ”€ firewall
    โ”‚   โ””โ”€โ”€ ingress-allow
    โ”œโ”€โ”€ node-pool
    โ””โ”€โ”€ vpc

terraform-modules

The folder contains reusable pieces of terraform code which help us manage our configuration more efficiently by avoiding code repetition and reducing the volume of configuration.

The folder contains 4 modules at the moment of writing:

  • cluster module allows to create new Kubernetes clusters.
  • firewall/ingress-allow module allows to create firewall rules to filter incoming traffic.
  • node-pool module is used to create Node Pools which is mechanism to add extra nodes of required configuration to a running Kubernetes cluster. Note that nodes which configuration is specified in the cluster module become the default node pool.
  • vpc module is used to create new Virtual Private Cloud (VPC) networks.

my-cluster

Inside the my-cluster folder, I put terraform configuration for the creation and management of an example of Kubernetes cluster. Important files here:

  • main.tf is the place where we define main configuration such as creation of a network for our cluster, creation of the cluster itself and node pools.

  • firewall.tf is used to describe the firewall rules regarding our cluster.

  • dns.tf is used to manage Google DNS service resources (again with regards to the services and applications which we will run in our cluster).

  • static-ips.tf is used to manage static IP addresses for services and applications which will be running in the cluster.

  • terraform.tfvars.example contains example terraform input variables which you need to define before you can start creating a cluster.

  • outputs.tf contains output variables

  • variables.tf contains input variables

  • k8-confing folder contains Kubernetes configuration files (manifests) which are used to define configuration of the running Kubernetes cluster. It has 4 subdirectories inside:

    • env-namespaces contains manifests for creating namespaces, or virtual environments within the cluster, for running our services. In this example, raddit-namespaces.yml file is used to describe 3 namespaces: raddit-stage and raddit-prod for running example application (which is called raddit in this case) in different virtual environments, and infra namespace for running services vital to our infrastructure like CI/CD, monitoring, or logging software.
    • storage-classes folder is used to create storage classes that could be then used in dynamic volume provisioning for our applications.
    • kube-lego folder has the configuration required to run kube-lego service which is used for automatic SSL certificates requests for our services running inside the cluster.
    • charts contains Helm charts for deploying infra services. In this case it only has a chart for deploying Gitlab CI along with a Runner.
  • deploy-app-example has an bunch of Kubernetes objects definitions which are used to deploy nginx to a Kubernetes cluster. You can use the command below to deploy nginx to the cluster once it is created:

     $ kubectl apply -f ./deploy-app-example/nginx-example.yml
    

accounts

This is another top level folder in this project. It has a separate set of terraform files which are used to manage access accounts to our clusters. For example, you may want to create a service account for your CI tool to allow it to deploy applications to the cluster.

CI/CD example with Gitlab CI and Helm

For an example of building a CI/CD pipeline with Kubernetes, Gitlab CI, and Helm see this blog post.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].