Skip to content
Open
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
33 changes: 26 additions & 7 deletions perfkitbenchmarker/data/cluster/swap_encryption_daemonset.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ data:
# Installs measurement tools, verifies the swap device, then writes /tmp/pkb_ready.
set -euo pipefail

echo "[pkb] Installing measurement tools..."
# Only tools needed for Phase 1 (raw-device fio) and Phase 2 (CPU/I/O overhead).
# Workload benchmarks (redis, opensearch, kernel-build) run in separate pods.
echo "[pkb] Installing benchmark measurement tools..."
# Phase 1 tools: fio (raw-device I/O), cryptsetup/mdadm (dm-crypt inspection),
# sysstat (vmstat/pidstat), nvme-cli (NVMe telemetry).
# Phase 2 tools: stress-ng (CPU/I/O overhead), cgroup-tools (cgroup v1 guard),
# util-linux (taskset/ionice).
# Phase 3b tools: gcc/make/bc/flex/bison/libelf-dev/libssl-dev (kernel build).
# Workload benchmarks (redis, opensearch) run in separate PKB benchmark pods.
PKB_APT_OK=0
for _attempt in 1 2 3; do
DEBIAN_FRONTEND=noninteractive apt-get update -qq 2>&1 || true
Expand All @@ -25,15 +29,30 @@ data:
mdadm \
sysstat \
nvme-cli \
stress-ng \
cgroup-tools \
util-linux \
gcc \
make \
bc \
flex \
bison \
libelf-dev \
libssl-dev \
2>&1 && PKB_APT_OK=1 && break
echo "[pkb] apt-get attempt $_attempt failed, retrying in 15s..." >&2
sleep 15
done
if [ "$PKB_APT_OK" != "1" ] || ! command -v fio >/dev/null 2>&1; then
echo "[pkb] FATAL: fio not installed after 3 attempts" >&2
if [ "$PKB_APT_OK" != "1" ] || \
! command -v fio >/dev/null 2>&1 || \
! command -v stress-ng >/dev/null 2>&1 || \
! command -v make >/dev/null 2>&1; then
echo "[pkb] FATAL: critical tools (fio, stress-ng, make) not installed after 3 attempts" >&2
exit 1
fi
echo "[pkb] fio installed: $(fio --version 2>&1 | head -1)"
echo "[pkb] fio: $(fio --version 2>&1 | head -1)"
echo "[pkb] stress-ng: $(stress-ng --version 2>&1 | head -1)"
echo "[pkb] gcc: $(gcc --version 2>&1 | head -1)"

echo "[pkb] Verifying swap device is active..."
PKB_SWAP_FOUND=0
Expand All @@ -53,7 +72,7 @@ data:
exit 1
fi

echo "[pkb] Measurement tools ready. Writing ready sentinel."
echo "[pkb] Benchmark tools ready. Writing ready sentinel."
touch /tmp/pkb_ready
exec sleep infinity
---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# opensearch-benchmark Kubernetes Job
# Rendered by kubernetes_opensearch_esrally_benchmark.py Run().
#
# Template variables:
# k8s_namespace - Kubernetes namespace (default: 'default')
# race_id - Unique test-execution identifier string
# target_hosts - OpenSearch Service host:port
# esrally_track - opensearch-benchmark workload name, e.g. geonames
# esrally_challenge - test-procedure name, e.g. append-no-conflicts
# esrally_version - opensearch-benchmark pip package version, e.g. 1.7.0
#
# The Job installs opensearch-benchmark at runtime, runs the test in
# benchmark-only pipeline against the OpenSearch headless Service, then
# prints test_execution.json between PKB sentinel markers so Run() can
# parse the results.
---
apiVersion: batch/v1
kind: Job
metadata:
name: esrally-pkb
namespace: {{ k8s_namespace | default('default') }}
labels:
pkb: "true"
spec:
backoffLimit: 0
template:
metadata:
labels:
pkb: "true"
spec:
nodeSelector:
pkb_nodepool: clients
restartPolicy: Never
containers:
- name: esrally
image: python:3.11-slim
resources:
requests:
memory: "4Gi"
cpu: "2"
limits:
memory: "8Gi"
cpu: "4"
env:
- name: BENCHMARK_HOME
value: /var/benchmark
command:
- bash
- -c
- |
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
echo "[pkb] Installing system dependencies (git)..."
apt-get update -qq && apt-get install -y --no-install-recommends git > /dev/null
echo "[pkb] Installing opensearch-benchmark {{ esrally_version }}..."
pip install opensearch-benchmark=={{ esrally_version }} --quiet

echo "[pkb] Running opensearch-benchmark (workload={{ esrally_track }}, test-procedure={{ esrally_challenge }})..."
opensearch-benchmark execute-test \
--pipeline=benchmark-only \
--target-host="{{ target_hosts }}" \
--workload="{{ esrally_track }}" \
--test-procedure="{{ esrally_challenge }}" \
--workload-params="number_of_replicas:0" \
--test-execution-id="{{ race_id }}"

echo "[pkb] Test complete. Locating test_execution.json..."
# Use -path in find (not grep) to avoid non-zero exit with pipefail.
TEST_JSON=$(find /root /var/benchmark \
-path "*{{ race_id }}*" -name "test_execution.json" 2>/dev/null | head -1)
if [ -z "$TEST_JSON" ]; then
echo "[pkb-error] test_execution.json not found. Listing all benchmark files:"
find /root /var/benchmark -maxdepth 8 -type f 2>/dev/null | sort | head -50
exit 1
fi
echo "[pkb] Found: $TEST_JSON"
echo "=== PKB_RACE_JSON_BEGIN ==="
cat "$TEST_JSON"
echo ""
echo "=== PKB_RACE_JSON_END ==="
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# OpenSearch single-node StatefulSet + headless Service (clusterIP: None)
# Rendered by kubernetes_opensearch_esrally_benchmark.py Prepare().
#
# Template variables:
# k8s_namespace - Kubernetes namespace (default: 'default')
# opensearch_version - OpenSearch image tag, e.g. 2.13.0
# opensearch_port - HTTP port, e.g. 9200
#
# Nodes in the 'servers' nodepool are selected via the pkb_nodepool label
# which PKB sets automatically during nodepool creation.
# An initContainer sets vm.max_map_count=262144 which OpenSearch requires.
---
apiVersion: v1
kind: Service
metadata:
name: opensearch
namespace: {{ k8s_namespace | default('default') }}
labels:
app: opensearch
pkb: "true"
spec:
selector:
app: opensearch
ports:
- name: http
port: {{ opensearch_port }}
targetPort: {{ opensearch_port }}
clusterIP: None
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: opensearch
namespace: {{ k8s_namespace | default('default') }}
labels:
app: opensearch
pkb: "true"
spec:
# No volumeClaimTemplates: OpenSearch data lives on ephemeral pod
# storage, giving each PKB run a clean index (intentional).
serviceName: opensearch
replicas: 1
selector:
matchLabels:
app: opensearch
template:
metadata:
labels:
app: opensearch
pkb: "true"
spec:
nodeSelector:
pkb_nodepool: servers
tolerations:
- operator: Exists
initContainers:
- name: sysctl
image: busybox:1.36
command:
- sysctl
- -w
- vm.max_map_count=262144
securityContext:
privileged: true
containers:
- name: opensearch
image: opensearchproject/opensearch:{{ opensearch_version }}
ports:
- name: http
containerPort: {{ opensearch_port }}
env:
- name: discovery.type
value: single-node
- name: DISABLE_SECURITY_PLUGIN
value: "true"
- name: OPENSEARCH_JAVA_OPTS
value: "-Xms4g -Xmx4g"
- name: bootstrap.memory_lock
value: "false"
resources:
requests:
memory: "8Gi"
cpu: "2"
limits:
memory: "16Gi"
cpu: "4"
readinessProbe:
httpGet:
path: /_cluster/health
port: {{ opensearch_port }}
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 12
Loading