Skip to content

Commit 145218b

Browse files
committed
feat: implement blanket gcp image build
1 parent 447a823 commit 145218b

File tree

31 files changed

+586
-2
lines changed

31 files changed

+586
-2
lines changed

base/mkosi.skeleton/etc/sysconfig/.gitkeep

Whitespace-only changes.

l2/kernel.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_NET_VENDOR_GOOGLE=y
2+
CONFIG_GVE=y
3+
CONFIG_XFS_FS=y

l2/mkosi.build

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
ENV_YAML="$SRCDIR/l2/mkosi.extra/etc/flashbots/l2.yaml"
6+
7+
VAULT_VERSION=$(mkosi-chroot yq -r .vault.version < "$ENV_YAML")
8+
GOMPLATE_VERSION=$(mkosi-chroot yq -r .deps.gomplate_version < "$ENV_YAML")
9+
OPS_AGENT_VERSION=$(mkosi-chroot yq -r .deps.ops_agent_version < "$ENV_YAML")
10+
11+
source scripts/make_git_package.sh
12+
13+
# build gomplate
14+
make_git_package \
15+
"gomplate" \
16+
"v${GOMPLATE_VERSION}" \
17+
"https://github.com/hairyhenderson/gomplate" \
18+
'go build -trimpath -ldflags "-s -w -buildid=" -o ./build/gomplate ./cmd/gomplate' \
19+
"build/gomplate:/usr/bin/gomplate"
20+
chmod +x $DESTDIR/usr/bin/gomplate
21+
22+
# build vault
23+
make_git_package \
24+
"vault" \
25+
"v${VAULT_VERSION}" \
26+
"https://github.com/hashicorp/vault.git" \
27+
'go build -trimpath -ldflags "-s -w -buildid=" -o ./bin/vault .' \
28+
"bin/vault:/usr/bin/vault"
29+
chmod +x $DESTDIR/usr/bin/vault
30+
31+
cd "$BUILDROOT"
32+
33+
# Build Google Cloud Ops Agent
34+
IMPORT_PATH="github.com/GoogleCloudPlatform/ops-agent"
35+
BUILD_CMD="
36+
# Fluentbit
37+
export SOURCE_DATE_EPOCH=0 PATH=/usr/local/go/bin:\$PATH
38+
export CFLAGS='-fno-ident -Wno-date-time' CXXFLAGS='-fno-ident -Wno-date-time'
39+
git submodule update --init --depth 1 submodules/fluent-bit
40+
./builds/fluent_bit.sh \$(pwd)/out
41+
42+
# Main gcs agent binaries
43+
mkdir -p out/libexec
44+
LDFLAGS='-s -w -buildid='
45+
go build -buildvcs=false -trimpath -ldflags \"\$LDFLAGS \\
46+
-X $IMPORT_PATH/internal/version.BuildDistro=debian13 \\
47+
-X $IMPORT_PATH/internal/version.Version=$OPS_AGENT_VERSION\" \\
48+
-o out/libexec/google_cloud_ops_agent_engine \\
49+
$IMPORT_PATH/cmd/google_cloud_ops_agent_engine
50+
51+
go build -buildvcs=false -trimpath -ldflags \"\$LDFLAGS\" \\
52+
-o out/libexec/google_cloud_ops_agent_wrapper \\
53+
$IMPORT_PATH/cmd/agent_wrapper
54+
"
55+
56+
make_git_package \
57+
"google-cloud-ops-agent" \
58+
"$OPS_AGENT_VERSION" \
59+
"https://github.com/GoogleCloudPlatform/ops-agent" \
60+
"$BUILD_CMD" \
61+
"out/libexec:/opt/google-cloud-ops-agent/libexec" \
62+
"out/opt/google-cloud-ops-agent/subagents/fluent-bit:/opt/google-cloud-ops-agent/subagents/fluent-bit" \
63+
"systemd/google-cloud-ops-agent-fluent-bit.service:/usr/lib/systemd/system/google-cloud-ops-agent-fluent-bit.service" \
64+
"systemd/google-cloud-ops-agent.service:/usr/lib/systemd/system/google-cloud-ops-agent.service"
65+
66+
sed -i 's|@PREFIX@|/opt/google-cloud-ops-agent|g; s|@SYSCONFDIR@|/etc|g' "$DESTDIR/usr/lib/systemd/system/google-cloud-ops-agent"*.service

l2/mkosi.conf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[Include]
2+
Include=base/mkosi.conf
3+
4+
[Config]
5+
Profiles=gcp
6+
7+
[Build]
8+
Environment=KERNEL_CONFIG_SNIPPETS=kernel/snippets/ubuntu.config,l2/kernel.config
9+
WithNetwork=true
10+
11+
[Content]
12+
BuildScripts=l2/mkosi.build
13+
ExtraTrees=l2/mkosi.extra
14+
PostInstallationScripts=l2/mkosi.postinst
15+
16+
Packages=prometheus-node-exporter
17+
prometheus-process-exporter
18+
usrmerge
19+
xfsprogs
20+
21+
BuildPackages=golang
22+
libssl-dev
23+
unzip
24+
yq
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Set the command-line arguments to pass to the server.
2+
ARGS="\
3+
--collector.systemd \
4+
--collector.systemd.unit-include=\".*(prometheus-node-exporter|prometheus-process-exporter|vault-agent).*\" \
5+
--log.format=json \
6+
--web.listen-address=0.0.0.0:9100 \
7+
"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Set the command-line arguments to pass to the server.
2+
ARGS="\
3+
-config.path=/etc/prometheus-process-exporter/config.yaml \
4+
-threads=false \
5+
-web.listen-address=0.0.0.0:9256 \
6+
"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
vault:
2+
version: 1.20.1
3+
4+
deps:
5+
gomplate_version: 4.3.0
6+
ops_agent_version: 2.57.0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
logging:
2+
receivers:
3+
syslog:
4+
type: files
5+
include_paths:
6+
- /var/log/messages
7+
- /var/log/syslog
8+
processors:
9+
parse_json:
10+
type: parse_json
11+
field: message
12+
time_key: "@timestamp"
13+
time_format: "%Y-%m-%dT%H:%M:%S.%L%z"
14+
service:
15+
pipelines:
16+
default_pipeline:
17+
receivers: [syslog]
18+
processors: [parse_json]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
process_names:
2+
- name: vault-agent
3+
cmdline:
4+
- '^\/([-.0-9a-zA-Z]+\/)*vault[-.0-9a-zA-Z]* '
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=Automatically mount data volume
3+
4+
[Service]
5+
Type=oneshot
6+
SyslogIdentifier=automount-data
7+
User=root
8+
Group=root
9+
10+
RemainAfterExit=yes
11+
12+
EnvironmentFile=-/etc/sysconfig/automount-data.env
13+
ExecStart=/usr/bin/automount-data.sh
14+
15+
[Install]
16+
WantedBy=default.target

0 commit comments

Comments
 (0)