devMachineSetup/README_SETUP_DEBIAN.md
2026-05-18 10:26:57 +12:00

91 lines
3.6 KiB
Markdown

Debian setup script
This repository contains a simple idempotent-ish script to provision a Debian-based machine after a rebuild.
Files
- setup-debian.sh: main script to run (creates/updates ~/.bashrc entries)
- setup-k8s-workspace.sh: configures kubectl context, k9s defaults, and bootstraps Flux to Git
- .env.example: template for Kubernetes workspace environment variables
Usage
1. Make the script executable and run it as your user (it will use sudo when needed):
```bash
chmod +x ~/setup-debian.sh
~/setup-debian.sh
```
Optional: set your global Git identity during setup:
```bash
GIT_USER_NAME="Your Name" GIT_USER_EMAIL="you@example.com" ~/setup-debian.sh
```
or run with sudo:
```bash
sudo bash ~/setup-debian.sh
```
What the script does
- Updates apt and installs requested packages (curl, net-tools, ncdu, tmux, htop, nala, neofetch, nfs-common, git, neovim, etc.)
- Installs `snapd` and installs Bitwarden via snap
- Attempts to detect a unix socket (ssh/bitwarden) and export `SSH_AUTH_SOCK` to `~/.bashrc`
- Installs VS Code via snap
- Installs latest `kubectl` binary and enables bash completion + aliases (`k`)
- Installs latest `k9s` binary
- Adds a `fgk` alias for `flux get kustomizations all`
- Adds arrow-key history search (type prefix then Up/Down)
Notes
- The script attempts to detect a Bitwarden SSH agent socket but may not find it automatically depending on how Bitwarden exposes it; if needed, manually set `SSH_AUTH_SOCK` in your shell to the socket path.
- `flux` must be installed separately if you need `fgk` to work.
Kubernetes workspace setup
1. Ensure `kubectl`, `k9s`, and `flux` are installed (the main setup script installs these).
2. Copy and edit the env template:
```bash
cp .env.example .env
```
3. Set values in `.env` (default provider is `gitea`, compatible with Forgejo).
4. Run the workspace bootstrap script:
```bash
chmod +x ./setup-k8s-workspace.sh
./setup-k8s-workspace.sh
```
Example `.env` values for Forgejo (`FLUX_PROVIDER=gitea`):
```bash
KUBECONFIG_SOURCE="$HOME/.kube/my-cluster-config" \
KUBE_CONTEXT="my-cluster" \
FLUX_PROVIDER="gitea" \
FLUX_GIT_URL="ssh://git@forgejo.example.com:30222/org/platform-gitops.git" \
FLUX_GIT_BRANCH="main" \
FLUX_GIT_PATH="clusters/my-cluster" \
FLUX_GIT_PRIVATE_KEY_FILE="$HOME/.ssh/id_ed25519" \
./setup-k8s-workspace.sh
```
Environment variables for setup-k8s-workspace.sh
- `ENV_FILE` (default `.env`): env file to load before execution
- `KUBECONFIG_SOURCE` (optional): source kubeconfig to copy to `~/.kube/config`
- `KUBE_CONTEXT` (optional): context to switch to before checks/bootstrap
- `APPLY_K9S_CONFIG` (default `true`): write `~/.config/k9s/config.yaml` if missing
- `FORCE_K9S_CONFIG` (default `false`): overwrite existing k9s config
- `FLUX_BOOTSTRAP` (default `true`): run or skip Flux bootstrap
- `FLUX_PROVIDER` (default `gitea`): `gitea`, `forgejo`, `github`, or `gitlab`
- `FLUX_GIT_BRANCH` (default `main`): branch for Flux manifests
- `FLUX_GIT_PATH` (default `clusters/<current-context>`): path for Flux manifests
- `FLUX_NAMESPACE` (default `flux-system`): Flux namespace
- `FLUX_GIT_URL` (required for `gitea`/`forgejo`): repo URL for `flux bootstrap git`
- `FLUX_GIT_PRIVATE_KEY_FILE` (default `~/.ssh/id_ed25519`): SSH key for `gitea`/`forgejo`
- `FLUX_INSECURE_HOSTKEYS` (default `false`): pass `--insecure-hostkey` for `gitea`/`forgejo`
- `FLUX_GITHUB_OWNER`, `FLUX_GITHUB_REPO` (required for `github`)
- `GITHUB_TOKEN` (required in environment for `github`)
- `FLUX_GITLAB_HOSTNAME` (default `gitlab.com`), `FLUX_GITLAB_OWNER`, `FLUX_GITLAB_REPO` (required for `gitlab`)
- `GITLAB_TOKEN` (required in environment for `gitlab`)