Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: user data script to install kubectl & helm #22

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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