Skip to content

Commit

Permalink
build: user data script to install kubectl & helm
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabNeu authored and sydrawat01 committed Oct 27, 2023
1 parent 77f652a commit 7d33c22
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/vm/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
data "template_file" "startup_script" {
template = <<-EOF
sudo apt-get update -y
curl -LO https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
chmod +x kubectl
mkdir -p ~/.local/bin
mv ./kubectl ~/.local/bin/kubectl
kubectl version --client
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm version
EOF
}

resource "google_compute_instance" "vm" {
name = var.vm_name
machine_type = var.machine_type
Expand All @@ -15,6 +33,8 @@ resource "google_compute_instance" "vm" {

tags = ["bastion"]

metadata_startup_script = data.template_file.startup_script.rendered

network_interface {
subnetwork = var.subnet_name
access_config {
Expand Down

0 comments on commit 7d33c22

Please sign in to comment.