Skip to content

Commit 1e4ccde

Browse files
Merge pull request #218 from rsevilla87/quick-install
Add quick install script
2 parents c87419f + ef4f4cd commit 1e4ccde

File tree

2 files changed

+117
-4
lines changed

2 files changed

+117
-4
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,21 @@ A tool to run network performance tests in Kubernetes clusters.
2929

3030
## Quick Start
3131

32+
Install latest stable version with:
33+
34+
```shell
35+
curl -Ls https://raw.githubusercontent.com/cloud-bulldozer/k8s-netperf/refs/heads/main/hack/install.sh | sh
36+
```
37+
38+
> [!NOTE]
39+
> Default installation path is `${HOME}/.local/bin/`, you can change it by setting the `INSTALL_DIR` environment variable to the desired path.
40+
> before running the script
41+
42+
Then create the required resources:
3243
```shell
33-
$ git clone http://github.com/cloud-bulldozer/k8s-netperf
34-
$ cd k8s-netperf
35-
$ make build
3644
$ kubectl create ns netperf
3745
$ kubectl create sa netperf -n netperf
38-
$ ./bin/amd64/k8s-netperf --config netperf.yml
46+
$ k8s-netperf --config netperf.yml
3947
```
4048

4149
## Documentation

hack/install.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC2086
3+
# Quick install script for k8s-netperf
4+
# Downloads the latest release version based on system architecture and OS
5+
6+
set -euo pipefail
7+
8+
# Configuration
9+
REPO="cloud-bulldozer/k8s-netperf"
10+
INSTALL_DIR="${INSTALL_DIR:-${HOME}/.local/bin/}"
11+
12+
# Detect OS
13+
detect_os() {
14+
local os
15+
os=$(uname -s | tr '[:upper:]' '[:lower:]')
16+
17+
case "${os}" in
18+
linux*)
19+
echo "linux"
20+
;;
21+
darwin*)
22+
echo "darwin"
23+
;;
24+
mingw* | msys* | cygwin*)
25+
echo "windows"
26+
;;
27+
*)
28+
echo "Unsupported operating system: ${os}"
29+
exit 1
30+
;;
31+
esac
32+
}
33+
34+
# Get latest release version from GitHub
35+
get_latest_version() {
36+
local version
37+
if command -v curl &> /dev/null; then
38+
version=$(curl -sL "https://api.github.com/repos/${REPO}/releases/latest" | \
39+
grep '"tag_name":' | \
40+
sed -E 's/.*"([^"]+)".*/\1/')
41+
else
42+
echo "curl command not found. Please install it."
43+
exit 1
44+
fi
45+
46+
if [[ -z "${version}" ]]; then
47+
echo "Failed to fetch latest version"
48+
exit 1
49+
fi
50+
51+
echo "${version}"
52+
}
53+
54+
# Download and extract binary
55+
download_and_extract() {
56+
local version=$1
57+
local os=$2
58+
local arch=$3
59+
local archive_name="k8s-netperf_${os}_${version}_${arch}.tar.gz"
60+
local download_url="https://github.com/${REPO}/releases/download/${version}/${archive_name}"
61+
mkdir -p ${INSTALL_DIR}
62+
echo "Downloading k8s-netperf ${version} for ${os}/${arch}..."
63+
echo "URL: ${download_url}"
64+
curl -sL -f "${download_url}" | tar xz -C ${INSTALL_DIR} k8s-netperf
65+
}
66+
67+
# Verify installation
68+
verify_installation() {
69+
if command -v k8s-netperf &> /dev/null; then
70+
echo "k8s-netperf is now available in your PATH, installed at ${INSTALL_DIR}"
71+
else
72+
echo "k8s-netperf installed to ${INSTALL_DIR}, but not found in PATH"
73+
echo "You may need to add ${INSTALL_DIR} to your PATH"
74+
fi
75+
}
76+
77+
# Main installation flow
78+
main() {
79+
echo "Starting k8s-netperf 🔥 installation..."
80+
81+
# Detect system
82+
local os
83+
local arch
84+
os=$(detect_os)
85+
arch=$(uname -m | sed s/aarch64/arm64/)
86+
87+
echo "Detected system: ${os}/${arch}"
88+
89+
# Get latest version
90+
local version
91+
version=$(get_latest_version)
92+
echo "Latest version: ${version}"
93+
94+
# Download and extract
95+
download_and_extract "${version}" "${os}" "${arch}"
96+
97+
# Verify
98+
verify_installation
99+
100+
echo "Get started with: k8s-netperf help"
101+
}
102+
103+
# Run main function
104+
main "$@"
105+

0 commit comments

Comments
 (0)