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

Add packer files for NGF test image #17

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tools

This directory contains the source code used to generate the VM image used in NGF tests.

## Building the VM image

To build the VM image, run the following command:

```bash
packer build -var 'project_id=<PROJECT_ID>' -var 'builder_sa=<BUILDER_SA>' build.pkr.hcl
```
69 changes: 69 additions & 0 deletions tools/build.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
packer {
required_plugins {
googlecompute = {
source = "github.com/hashicorp/googlecompute"
version = "1.1.3"
}
}
}

variable "project_id" {
type = string
}

variable "builder_sa" {
type = string
}

source "googlecompute" "ngf-image" {
project_id = var.project_id
source_image_family = "debian-12"
zone = "us-west1-a"
image_description = "Debian VM for NGF testing"
ssh_username = "username"
tags = ["test-packer"]
impersonate_service_account = var.builder_sa
image_name = "ngf-debian-12-{{timestamp}}"
image_family = "ngf-debian"
machine_type = "n2-standard-4"
}

build {
sources = ["sources.googlecompute.ngf-image"]

provisioner "shell" {
inline = [
"curl -L https://nixos.org/nix/install -o install-nix.sh",
"chmod +x install-nix.sh",
"bash install-nix.sh --daemon",
"rm install-nix.sh",
"sed -i '1i. /etc/bashrc' ~/.bashrc"
]
}

provisioner "file" {
source = "packages.nix"
destination = "/tmp/packages.nix"


}

provisioner "shell" {
inline = [
"nix-env -if /tmp/packages.nix",
"sudo apt-get update",
"sudo apt-get install -y --no-install-recommends --no-install-suggests google-cloud-sdk-gke-gcloud-auth-plugin locales",
"echo 'en_US.UTF-8 UTF-8' | sudo tee /etc/locale.gen",
"sudo locale-gen",
]
}

provisioner "shell" {
inline = [
"git clone https://github.com/nginxinc/nginx-gateway-fabric.git",
"cd nginx-gateway-fabric/tests",
"go mod download",
]
}

}
13 changes: 13 additions & 0 deletions tools/packages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs ? import <nixpkgs> {} }:

[
pkgs.gh
pkgs.git
pkgs.gnumake
pkgs.gnuplot
pkgs.go
pkgs.kubectl
pkgs.kubernetes-helm
pkgs.rsync
pkgs.wrk
]