From e15cce1ba54a42089a0eee0ebfb9cbba977bc897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?c=C4=83t=C4=83lin?= Date: Fri, 31 Jul 2026 17:00:18 +0200 Subject: [PATCH] feat: add scripts/hbd.sh and some docs --- README.md | 117 ++++++++++++++++++++++++++++++++++++++ scripts/encode-secrets.sh | 49 ---------------- scripts/hbd.sh | 6 +- 3 files changed, 120 insertions(+), 52 deletions(-) delete mode 100755 scripts/encode-secrets.sh diff --git a/README.md b/README.md index 1b287dc..91bb41a 100644 --- a/README.md +++ b/README.md @@ -1 +1,118 @@ # fukuops + + +## scripts + +### `hbd.sh` - Helm Build and Deploy + +Package and push Helm charts to an OCI registry. + +```bash +scripts/hbd.sh [version] [--oci-registry ] +``` + +**Arguments:** +- `chart-name` - Name of the chart in `k8s/charts/` +- `version` (optional) - Version to deploy. If omitted, bumps patch version (e.g., 0.1.0 → 0.1.1) +- `--oci-registry ` (optional) - Override default OCI registry + +**Default registry:** `oci://git.roboces.dev/catalin/fukuops` + +**Examples:** +```bash +# Deploy next patch version (0.1.0 → 0.1.1) +scripts/hbd.sh vaultwarden + +# Deploy specific version +scripts/hbd.sh vaultwarden 0.2.0 + +# Deploy to custom registry +scripts/hbd.sh vaultwarden 0.1.1 --oci-registry oci://my-registry.com/charts +``` + +--- + +### `k3scale.sh` - Kubernetes Scaling + +Scale deployments and statefulsets in a k3s cluster. + +```bash +scripts/k3scale.sh REPLICAS [RESOURCE...] [OPTIONS] +``` + +**Arguments:** +- `REPLICAS` - Number of replicas to scale to +- `RESOURCE` - Resource to scale in `namespace/name` format (can specify multiple) + +**Options:** +- `--all` - Scale all deployments/statefulsets in current namespace +- `--all-namespaces` - Scale across all namespaces +- `-n, --namespace NAMESPACE` - Target namespace +- `--dry-run` - Show actions without executing +- `-v|-vv|-vvv` - Verbosity levels + +**Examples:** +```bash +scripts/k3scale.sh 1 mynamespace/mydeployment +scripts/k3scale.sh 0 --all --namespace production +scripts/k3scale.sh 3 --all --dry-run +``` + +--- + +### `proxmox-power.sh` - Proxmox VM Management + +Start or shutdown QEMU VMs and LXC containers on a Proxmox cluster. + +```bash +scripts/proxmox-power.sh --op start|shutdown [--all | --ids ...]] [OPTIONS] +``` + +**Options:** +- `--op OP` - Operation: `start` or `shutdown` (required) +- `--all` - Operate on all VMs/containers (honors filters) +- `--ids LIST` - Space-separated list of VMIDs +- `--only-qemu` - Only QEMU VMs +- `--only-lxc` - Only LXC containers +- `--force` - Force shutdown if timeout exceeded +- `--timeout SEC` - Shutdown wait timeout (default: 120) +- `--concurrency N` - Parallel operations (default: 4) +- `--node NODE` - Restrict to specific node +- `--dry-run` - Show actions without executing +- `--insecure` - Skip SSL verification + +**Authentication (env vars):** +- API Token: `PVE_TOKEN_ID` + `PVE_TOKEN_SECRET` +- Password: `PVE_USER` + `PVE_PASSWORD` (or via GNOME keyring) + +**Examples:** +```bash +scripts/proxmox-power.sh --op shutdown --all +scripts/proxmox-power.sh --op start --ids 100 101 --node mynode +PVE_TOKEN_ID=user@pam!ci scripts/proxmox-power.sh --op start --all +``` + +--- + + +### `update-argo.sh` - ArgoCD Upgrades + +Upgrade ArgoCD to a new version. + +```bash +scripts/update-argo.sh [VERSION] [OPTIONS] +``` + +**Arguments:** +- `VERSION` (optional) - Target version. If omitted, auto-detects latest + +**Options:** +- `--dry-run` - Show what would be done +- `-v|-vv|-vvv` - Verbosity levels + +**Examples:** +```bash +scripts/update-argo.sh # Upgrade to latest +scripts/update-argo.sh v2.9.0 # Upgrade to specific version +scripts/update-argo.sh --dry-run -vv # Preview with verbose output +``` diff --git a/scripts/encode-secrets.sh b/scripts/encode-secrets.sh deleted file mode 100755 index 642d018..0000000 --- a/scripts/encode-secrets.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -me=$(basename "$0") -usage="Usage: $me [FILE] - -Given a secrets YAML manifest, convert each secret value to base64 -" - -if [ $# -ne 1 ]; then - echo "$usage" - exit 1 -fi - -if ! [ -x "$(command -v yq)" ]; then - echo 'Error: yq is not installed.' >&2 - exit 1 -fi - -file=$1 -if [ ! -f "$file" ]; then - echo "No such file: $file" - exit 1 -fi - -# Read the YAML file -map=$(yq eval '.' "$file") - -# Check if 'data' key exists -if ! yq eval '.data' "$file" > /dev/null 2>&1; then - echo "The YAML file does not contain a 'data' key" - exit 1 -fi - -# Get the 'data' object -data=$(yq eval '.data' "$file") - -# For each key in the 'data' object -while IFS= read -r key; do - # Base64 encode the value - value=$(echo -n "$(yq eval ".${key}" <<< "$data")" | base64) - # Update the 'data' object with the new value - data=$(yq eval ".${key} = \"${value}\"" <<< "$data") -done <<< "$(yq eval '.data | keys | .[]' <<< "$map")" - -# Update the YAML with the new 'data' object -map=$(yq eval ".data = \"${data}\"" <<< "$map") - -# Print the new YAML -echo "$map" diff --git a/scripts/hbd.sh b/scripts/hbd.sh index a2d3ba5..f0c3f1c 100755 --- a/scripts/hbd.sh +++ b/scripts/hbd.sh @@ -63,9 +63,9 @@ function main() { while [[ $# -gt 0 ]]; do case "$1" in - --oci-register) + --oci-registry) if [[ -z "${2:-}" ]] || [[ "$2" == -* ]]; then - echo "Error: --oci-register requires a registry argument" >&2 + echo "Error: --oci-registry requires a registry argument" >&2 exit 1 fi oci_registry="$2" @@ -75,7 +75,7 @@ function main() { echo "$USAGE" echo "" echo "Options:" - echo " --oci-register Override default OCI registry (default: oci://git.roboces.dev/catalin/fukuops)" + echo " --oci-registry Override default OCI registry (default: oci://git.roboces.dev/catalin/fukuops)" exit 0 ;; -*)