Skip to content

cvitaa11/gke-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GKE Demo with Terraform

CI/CD Pipeline

This repository contains Terraform configurations to deploy a Google Kubernetes Engine (GKE) cluster with custom networking settings.

Prerequisites

Network Configuration

The cluster is configured with the following IP ranges:

  • Nodes: 10.0.0.0/16
  • Pods: 10.1.0.0/16
  • Services: 10.2.0.0/16

Example output: Pods CIDR Services CIDR

Usage

  1. Clone the repository:
git clone https://github.com/cvitaa11/gke-demo.git
cd gke-demo/infra/example
  1. Create a terraform.tfvars file with your project settings:
project_id     = "your-project-id"
region         = "your-desired-region"
node_locations = ["your-desired-AZs"]
  1. Initialize Terraform
terraform init
  1. Review the plan:
terraform plan
  1. Apply the configuration:
terraform apply
  1. After deployment, configure kubectl:
gcloud container clusters get-credentials $(terraform output -raw kubernetes_cluster_name) --region $(terraform output -raw region)

Terraform resources

Name Version
terraform ~> 1.5.7
google 6.8.0

Providers

Name Version
google 6.8.0

Resources

Name Type
google_compute_network.vpc resource
google_compute_subnetwork.subnet resource
google_container_cluster.primary resource
google_container_node_pool.primary_nodes resource
google_container_engine_versions.gke_version data source

Inputs

Name Description Type Default Required
node_ip_range IP address range of GKE nodes string "10.0.0.0/16" no
node_locations Availability zone of the GKE nodes any n/a yes
pod_ip_range IP address range of k8s pods string "10.1.0.0/16" no
project_id GCP project id any n/a yes
region region string "us-east1" no
service_ip_range IP address range of k8s services string "10.2.0.0/16" no

Outputs

Name Description
kubernetes_cluster_host GKE Cluster Host
kubernetes_cluster_name GKE Cluster Name
region GCloud Region

Cleanup

To destroy the created resources run the following command:

terraform destroy

Notes

  • The configuration uses minimal resources to stay within GCP's free tier
  • The cluster is deployed in a single zone for cost optimization
  • Remember to monitor your GCP usage and costs

About

GKE demo project with Terraform deployment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages