Skip to content

Commit

Permalink
Inits go module and terraform for kubernetes nodes on GCP
Browse files Browse the repository at this point in the history
  • Loading branch information
SaahilNotSahil committed Nov 22, 2023
1 parent 09f9a30 commit 246db63
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,40 @@

# Go workspace file
go.work

ssh/

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/XanderWatson/CSL7510-VCC-Project

go 1.21.0
21 changes: 21 additions & 0 deletions infra/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

167 changes: 167 additions & 0 deletions infra/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
resource "google_compute_instance" "kubenode1" {
boot_disk {
auto_delete = true
device_name = "instance-1"

initialize_params {
image = "projects/ubuntu-os-cloud/global/images/ubuntu-2204-jammy-v20231030"
size = 50
type = "pd-balanced"
}

mode = "READ_WRITE"
}

can_ip_forward = true
deletion_protection = false
enable_display = false
hostname = "kubenode1.vcc"

labels = {
goog-ec-src = "vm_add-tf"
}

machine_type = "e2-medium"
name = "kubenode1"

network_interface {
access_config {
network_tier = "PREMIUM"
}

subnetwork = "projects/vcc-course/regions/asia-south2/subnetworks/default"
}

scheduling {
automatic_restart = true
on_host_maintenance = "MIGRATE"
preemptible = false
provisioning_model = "STANDARD"
}

service_account {
email = var.gcp_svc_email
scopes = var.gcp_svc_scopes
}

shielded_instance_config {
enable_integrity_monitoring = true
enable_secure_boot = false
enable_vtpm = true
}

tags = ["http-server", "https-server", "lb-health-check"]
zone = "asia-south2-a"
}

resource "google_compute_instance" "kubenode2" {
boot_disk {
auto_delete = true
device_name = "instance-2"

initialize_params {
image = "projects/ubuntu-os-cloud/global/images/ubuntu-2204-jammy-v20231030"
size = 50
type = "pd-balanced"
}

mode = "READ_WRITE"
}

can_ip_forward = true
deletion_protection = false
enable_display = false
hostname = "kubenode2.vcc"

labels = {
goog-ec-src = "vm_add-tf"
}

machine_type = "e2-medium"
name = "kubenode2"

network_interface {
access_config {
network_tier = "PREMIUM"
}

subnetwork = "projects/vcc-course/regions/us-west1/subnetworks/default"
}

scheduling {
automatic_restart = true
on_host_maintenance = "MIGRATE"
preemptible = false
provisioning_model = "STANDARD"
}

service_account {
email = var.gcp_svc_email
scopes = var.gcp_svc_scopes
}

shielded_instance_config {
enable_integrity_monitoring = true
enable_secure_boot = false
enable_vtpm = true
}

tags = ["http-server", "https-server", "lb-health-check"]
zone = "us-west1-b"
}

resource "google_compute_instance" "kubenode3" {
boot_disk {
auto_delete = true
device_name = "instance-3"

initialize_params {
image = "projects/ubuntu-os-cloud/global/images/ubuntu-2204-jammy-v20231030"
size = 50
type = "pd-balanced"
}

mode = "READ_WRITE"
}

can_ip_forward = true
deletion_protection = false
enable_display = false
hostname = "kubenode3.vcc"

labels = {
goog-ec-src = "vm_add-tf"
}

machine_type = "e2-medium"
name = "kubenode3"

network_interface {
access_config {
network_tier = "PREMIUM"
}

subnetwork = "projects/vcc-course/regions/europe-west9/subnetworks/default"
}

scheduling {
automatic_restart = true
on_host_maintenance = "MIGRATE"
preemptible = false
provisioning_model = "STANDARD"
}

service_account {
email = var.gcp_svc_email
scopes = var.gcp_svc_scopes
}

shielded_instance_config {
enable_integrity_monitoring = true
enable_secure_boot = false
enable_vtpm = true
}

tags = ["http-server", "https-server", "lb-health-check"]
zone = "europe-west9-a"
}
7 changes: 7 additions & 0 deletions infra/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# GCP Provider

provider "google" {
credentials = file(var.gcp_svc_key)
project = var.gcp_project
region = var.gcp_region
}
9 changes: 9 additions & 0 deletions infra/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "gcp_svc_key" {}

variable "gcp_project" {}

variable "gcp_region" {}

variable "gcp_svc_email" {}

variable "gcp_svc_scopes" {}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package main

0 comments on commit 246db63

Please sign in to comment.