Skip to content

Commit

Permalink
one ami
Browse files Browse the repository at this point in the history
  • Loading branch information
TarasPriadka committed Feb 22, 2024
1 parent a7c28b7 commit daf087d
Showing 1 changed file with 6 additions and 39 deletions.
45 changes: 6 additions & 39 deletions sysbox-eks.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -52,44 +52,12 @@ local "timestamp" {
expression = regex_replace(timestamp(), "[- TZ:]", "")
}

locals {
ami_name = "latch-bio/sysbox-eks_${var.sysbox_version}/k8s_${var.k8s_version}/images/hvm-ssd/ubuntu-${var.ubuntu_version}-amd64-serve-${local.timestamp}-${local.git_branch}"
gpu_ami_name = "latch-bio/sysbox-eks_${var.sysbox_version}-gpu/k8s_${var.k8s_version}/images/hvm-ssd/ubuntu-${var.ubuntu_version}-amd64-serve-${local.timestamp}-${local.git_branch}"
local "ami_name" {
expression = "latch-bio/sysbox-eks_${var.sysbox_version}/k8s_${var.k8s_version}/images/hvm-ssd/ubuntu-${var.ubuntu_version}-amd64-serve-${local.timestamp}-${local.git_branch}"
}

source "amazon-ebs" "ubuntu-eks" {
ami_name = "${local.ami_name}"
ami_description = "Latch Bio, Sysbox EKS Node (k8s_${var.k8s_version}), on Ubuntu ${var.ubuntu_version}, amd64 image."

tags = {
Linux = "Ubuntu"
UbuntuRelease = split("-", var.ubuntu_version)[0]
UbuntuVersion = split("-", var.ubuntu_version)[1]
Arch = "amd64"
K8sVersion = var.k8s_version
SysboxVersion = var.sysbox_version

BaseImageID = "{{ .SourceAMI }}"
BaseImageOwnerID = "{{ .SourceAMIOwner }}"

BaseImageOwnerName = "{{ .SourceAMIOwnerName }}"
BaseImageName = "{{ .SourceAMIName }}"
}

source_ami_filter {
filters = {
name = "ubuntu-eks/k8s_${var.k8s_version}/images/hvm-ssd/ubuntu-${var.ubuntu_version}-amd64-server-20230616"
}
owners = ["099720109477"]
}

region = "us-west-2"
instance_type = "t2.micro"
ssh_username = "ubuntu"
}

source "amazon-ebs" "ubuntu-gpu-eks" {
ami_name = "${local.gpu_ami_name}"
ami_description = "Latch Bio, Sysbox EKS Node (k8s_${var.k8s_version}) with NVIDIA GPU support, on Ubuntu ${var.ubuntu_version}, amd64 image."

tags = {
Expand Down Expand Up @@ -123,7 +91,6 @@ build {
name = "sysbox-eks"
sources = [
"source.amazon-ebs.ubuntu-eks",
"source.amazon-ebs.ubuntu-gpu-eks"
]

provisioner "shell" {
Expand Down Expand Up @@ -316,9 +283,6 @@ build {
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.cgroup_manager' 'cgroupfs'",
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.conmon_cgroup' 'pod'",

# enable mounting FUSE device inside of containers
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.allowed_devices.[]' --multiple /dev/fuse",

"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.default_capabilities.[]' --multiple SETFCAP",
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.default_capabilities.[]' --multiple AUDIT_WRITE",
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.default_capabilities.[]' --multiple NET_RAW",
Expand Down Expand Up @@ -365,7 +329,6 @@ build {

provisioner "shell" {
inline_shebang = "/usr/bin/env bash"
only = ["source.amazon-ebs.ubuntu-gpu-eks"]
inline = [
"set -o pipefail -o errexit",
"export DEBIAN_FRONTEND=noninteractive",
Expand All @@ -377,6 +340,10 @@ build {
"sudo apt-get update",
"sudo --preserve-env=DEBIAN_FRONTEND apt-get --yes --no-install-recommends install nvidia-driver-530 nvidia-container-toolkit",

# enable mounting FUSE device inside of containers
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.allowed_devices.[]' --multiple /dev/fuse",

# enable mounting NVIDIA devices inside of containers
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.allowed_devices.[]' --multiple /dev/dri/card0",
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.allowed_devices.[]' --multiple /dev/dri/card1",
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.allowed_devices.[]' --multiple /dev/dri/card2",
Expand Down

0 comments on commit daf087d

Please sign in to comment.