-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: rename ubuntu jammy client to account for different archs
- Loading branch information
1 parent
a1a02a5
commit 09d88bc
Showing
26 changed files
with
544 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
variable "build_sha" { | ||
type = string | ||
description = "the revision of the packer scripts building this image" | ||
} | ||
|
||
locals { | ||
timestamp = regex_replace(timestamp(), "[- TZ:]", "") | ||
distro = "ubuntu-jammy-22.04-arm64-server-*" | ||
version = "v3" | ||
} | ||
|
||
source "amazon-ebs" "latest_ubuntu_jammy" { | ||
ami_name = "nomad-e2e-${local.version}-ubuntu-jammy-arm64-${local.timestamp}" | ||
iam_instance_profile = "packer_build" // defined in nomad-e2e repo | ||
instance_type = "m7a.large" | ||
region = "us-east-1" | ||
ssh_username = "ubuntu" | ||
ssh_interface = "public_ip" | ||
|
||
source_ami_filter { | ||
filters = { | ||
architecture = "arm64" | ||
"block-device-mapping.volume-type" = "gp2" | ||
name = "ubuntu/images/hvm-ssd/${local.distro}" | ||
root-device-type = "ebs" | ||
virtualization-type = "hvm" | ||
} | ||
most_recent = true | ||
owners = ["099720109477"] // Canonical | ||
} | ||
|
||
tags = { | ||
OS = "Ubuntu" | ||
Version = "Jammy" | ||
BuilderSha = var.build_sha | ||
} | ||
} | ||
|
||
build { | ||
sources = ["source.amazon-ebs.latest_ubuntu_jammy"] | ||
|
||
provisioner "file" { | ||
destination = "/tmp/linux" | ||
source = "./ubuntu-jammy-arm64" | ||
} | ||
|
||
// cloud-init modifies the apt sources, so we need to wait | ||
// before running our setup | ||
provisioner "shell-local" { | ||
inline = ["sleep 30"] | ||
} | ||
|
||
provisioner "shell" { | ||
script = "./ubuntu-jammy-arm64/setup.sh" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
e2e/terraform/packer/ubuntu-jammy-arm64/cni/cni_args.conflist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"cniVersion": "1.0.0", | ||
"name": "cni_args", | ||
"plugins": [ | ||
{ | ||
"type": "cni_args.sh" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
set -euo pipefail | ||
|
||
# things are prefixed with "Fancy*" because this is a fancy plugin. | ||
# CNI_ARGS='IgnoreUnknown=true;FancyTaskDir=/tmp/cni_args;FancyMessage=hiiii;Another=whatever' | ||
# what we need to do: | ||
# 1. read CNI_ARGS environment variable | ||
# * write to a file named $FancyTaskDir/victory | ||
# 2. write CNI-spec json to stdout for Nomad to read | ||
|
||
# https://github.com/containernetworking/cni/blob/main/SPEC.md#version-success | ||
function version() { | ||
cat <<EOF | ||
{ | ||
"cniVersion": "1.0.0", | ||
"supportedVersions": [ "0.1.0", "0.2.0", "0.3.0", "0.3.1", "0.4.0", "1.0.0" ] | ||
} | ||
EOF | ||
} | ||
|
||
# https://github.com/containernetworking/cni/blob/main/SPEC.md#add-success | ||
function add() { | ||
# get our task dir out of the env var | ||
task_dir="$(echo "$CNI_ARGS" | tr ';' '\n' | awk -F= '/^FancyTaskDir=/ {print$2}')" | ||
message="$(echo "$CNI_ARGS" | tr ';' '\n' | awk -F= '/^FancyMessage=/ {print$2}')" | ||
1>&2 echo "got task dir: $task_dir; message: $message" | ||
|
||
mkdir -p "$task_dir" | ||
# and write something to a file we can check in the test. | ||
echo "$message" > "$task_dir/victory" | ||
} | ||
|
||
# run the appropriate CNI command | ||
case "$CNI_COMMAND" in | ||
VERSION) version ; exit ;; | ||
ADD) add ;; | ||
esac | ||
|
||
# bogus reply so nomad doesn't error | ||
cat <<EOF | ||
{ | ||
"cniVersion" : "1.0.0", | ||
"ips": [ | ||
{ | ||
"address": "10.1.0.5/16", | ||
"gateway": "10.1.0.1", | ||
"interface": 0 | ||
} | ||
], | ||
"routes": [ | ||
{ | ||
"dst": "0.0.0.0/0" | ||
} | ||
], | ||
"interfaces": [ | ||
{ | ||
"name": "cni0", | ||
"mac": "00:11:22:33:44:55" | ||
} | ||
], | ||
"dns": { | ||
"nameservers": [ "10.1.0.1" ] | ||
} | ||
} | ||
EOF | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cniVersion": "1.0.0", | ||
"name": "test-loopback-conf", | ||
"type": "loopback" | ||
} |
7 changes: 7 additions & 0 deletions
7
e2e/terraform/packer/ubuntu-jammy-arm64/cni/loopback.conflist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"cniVersion": "1.0.0", | ||
"name": "test-loopback-conflist", | ||
"plugins": [{ | ||
"type": "loopback" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cniVersion": "1.0.0", | ||
"name": "test-loopback-json", | ||
"type": "loopback" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=Consul Agent | ||
Requires=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Restart=on-failure | ||
Environment=CONSUL_ALLOW_PRIVILEGED_PORTS=true | ||
ExecStart=/usr/local/bin/consul agent -config-dir="/etc/consul.d" | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
KillSignal=SIGTERM | ||
User=root | ||
Group=root | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
set -e | ||
|
||
# These tasks can't be executed during AMI builds because they rely on | ||
# instance-specific data. | ||
|
||
mkdir -p /var/run/dnsmasq | ||
mkdir -p /etc/dnsmasq.d | ||
|
||
# Add hostname to /etc/hosts | ||
echo "127.0.0.1 $(hostname)" | tee --append /etc/hosts | ||
|
||
# this script should run after docker.service but we can't guarantee | ||
# it's created docker0 yet, so wait to make sure | ||
while ! (ip link | grep -q docker0) | ||
do | ||
sleep 1 | ||
done | ||
|
||
# Use dnsmasq first and then docker bridge network for DNS resolution | ||
DOCKER_BRIDGE_IP_ADDRESS=$(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}') | ||
cat <<EOF > /tmp/resolv.conf | ||
nameserver 127.0.0.1 | ||
nameserver $DOCKER_BRIDGE_IP_ADDRESS | ||
EOF | ||
cp /tmp/resolv.conf /etc/resolv.conf | ||
|
||
# need to get the interface for dnsmasq config so that we can | ||
# accomodate both "predictable" and old-style interface names | ||
IFACE=$(ip route | grep default | awk '{print $5}') | ||
|
||
cat <<EOF > /tmp/dnsmasq | ||
port=53 | ||
resolv-file=/var/run/dnsmasq/resolv.conf | ||
bind-interfaces | ||
interface=docker0 | ||
interface=lo | ||
interface=$IFACE | ||
listen-address=127.0.0.1 | ||
server=/consul/127.0.0.1#8600 | ||
EOF | ||
cp /tmp/dnsmasq /etc/dnsmasq.d/default | ||
|
||
# need to get the AWS DNS address from the VPC... | ||
# this is pretty hacky but will work for any typical case | ||
MAC=$(curl -s --fail http://169.254.169.254/latest/meta-data/mac) | ||
CIDR_BLOCK=$(curl -s --fail "http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/vpc-ipv4-cidr-block") | ||
VPC_DNS_ROOT=$(echo "$CIDR_BLOCK" | cut -d'.' -f1-3) | ||
echo "nameserver ${VPC_DNS_ROOT}.2" > /tmp/dnsmasq-resolv.conf | ||
cp /tmp/dnsmasq-resolv.conf /var/run/dnsmasq/resolv.conf | ||
|
||
/usr/sbin/dnsmasq --test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
port=53 | ||
resolv-file=/var/run/dnsmasq/resolv.conf | ||
bind-interfaces | ||
interface=docker0 | ||
interface=lo | ||
interface=eth0 | ||
listen-address=127.0.0.1 | ||
server=/consul/127.0.0.1#8600 |
Oops, something went wrong.