Compare commits
73
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6108d6dbf5 | ||
|
|
7586d8af31 | ||
|
|
063688746e | ||
|
|
86af2c6fcb | ||
|
|
d1c7412f07 | ||
|
|
b50aca4aff | ||
|
|
22d2320e3d | ||
|
|
0f3d4dcb22 | ||
|
|
2091607f0d | ||
|
|
39d3e6cb6f | ||
|
|
d815334b04 | ||
|
|
4ae597cfc4 | ||
|
|
967bbeadc6 | ||
|
|
99cf885600 | ||
|
|
33f72fb88c | ||
|
|
99cae11da3 | ||
|
|
01999ce28f | ||
|
|
8e87e33937 | ||
|
|
1c1a1b2441 | ||
|
|
eb7794962f | ||
|
|
f25d2fdfe9 | ||
|
|
2b5637516a | ||
|
|
ce6173b06a | ||
|
|
22dfe9a26b | ||
|
|
185e0c96d5 | ||
|
|
e55e46d020 | ||
|
|
cf139cd580 | ||
|
|
0623e151bb | ||
|
|
17a8061722 | ||
|
|
f6a708e897 | ||
|
|
b8516bae50 | ||
|
|
6d05f426d0 | ||
|
|
0466bd6929 | ||
|
|
8f9b6fda24 | ||
|
|
6ad6007df4 | ||
|
|
c5e545ef33 | ||
|
|
9d11189f3d | ||
|
|
5dde0da0d2 | ||
|
|
d93d1810f1 | ||
|
|
cdf033686a | ||
|
|
b1aff90ffd | ||
|
|
c6aa571a5c | ||
|
|
ffe976fb16 | ||
|
|
17648b53ae | ||
|
|
46b6593682 | ||
|
|
52e780f4af | ||
|
|
99f5f58a08 | ||
|
|
c2bd27c9a7 | ||
|
|
b21d5fc268 | ||
|
|
3d5b2ba097 | ||
|
|
3320f11e4b | ||
|
|
39dbfafe1c | ||
|
|
356f5b7ad4 | ||
|
|
6647d55050 | ||
|
|
13330ef3fb | ||
|
|
855d1cce85 | ||
|
|
9b388ff8e2 | ||
|
|
0d5f49591a | ||
|
|
12400b4c83 | ||
|
|
05bec1a5ff | ||
|
|
f6f74d9977 | ||
|
|
f2b8704914 | ||
|
|
be09d7592f | ||
|
|
abac1bf532 | ||
|
|
282e1c5236 | ||
|
|
339dcdd214 | ||
|
|
9b15ea5d33 | ||
|
|
344f748b84 | ||
|
|
84cf39e7d9 | ||
|
|
afc9fd36d7 | ||
|
|
3e6c8188da | ||
|
|
4c3a2b4226 | ||
|
|
c40fc0caac |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Old Gitea token in deleted .env.local. Confirmed revoked (API returned 401) on 2026-11-22.
|
||||
8c69ec772ab5f0df73fa2614e5b8b22adb9bbd15:.env.local:gitea-access-token:2
|
||||
@@ -15,6 +15,10 @@
|
||||
# PATH path below /api/v1, e.g. /repos/kasun/homelab-infrastructure-as-code/pulls?state=open
|
||||
# BODY JSON string, or @file to send a file
|
||||
#
|
||||
# Read-only CI wait: gitea.sh WAIT /repos/OWNER/REPO/commits/SHA/status
|
||||
# Polls until checks finish. Exit 0: passed or no CI ran. 1: a check failed.
|
||||
# 2: bad usage. 3: timed out after 15 minutes.
|
||||
#
|
||||
# Config (outside the repo, never committed):
|
||||
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/url e.g. http://192.168.1.208:3000
|
||||
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/token chmod 600
|
||||
@@ -28,6 +32,29 @@ method=${1:?usage: gitea.sh METHOD PATH [BODY]}
|
||||
path=${2:?usage: gitea.sh METHOD PATH [BODY]}
|
||||
body=${3:-}
|
||||
|
||||
if [[ "$method" == "WAIT" ]]; then
|
||||
[[ "$path" =~ ^/repos/[^/]+/[^/]+/commits/[0-9a-f]{40}/status$ ]] \
|
||||
|| { echo "WAIT only accepts /repos/OWNER/REPO/commits/SHA/status" >&2; exit 2; }
|
||||
for ((i = 1; i <= 45; i++)); do
|
||||
status=$("$0" GET "$path") || status='{}'
|
||||
total=$(jq '.statuses // [] | length' <<<"$status")
|
||||
running=$(jq '[.statuses // [] | .[] | select(.status == "pending" or .status == "running")] | length' <<<"$status")
|
||||
# Give checks time to register. Path-filtered workflows may never start any.
|
||||
if (( total == 0 && i >= 7 )); then
|
||||
echo "no CI ran"
|
||||
exit 0
|
||||
fi
|
||||
if (( total > 0 && running == 0 && i >= 4 )); then
|
||||
jq -r '.statuses[] | "\(.context): \(.status) \(.target_url)"' <<<"$status"
|
||||
jq -e '[.statuses[].status] | any(. == "failure" or . == "error") | not' <<<"$status" >/dev/null || exit 1
|
||||
exit 0
|
||||
fi
|
||||
sleep 20
|
||||
done
|
||||
echo "timed out waiting for CI" >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
case "$method" in
|
||||
GET | POST | PATCH | PUT | DELETE) ;;
|
||||
*) echo "unsupported method: $method" >&2; exit 2 ;;
|
||||
|
||||
@@ -20,9 +20,49 @@
|
||||
"Bash(kubectl logs *)",
|
||||
"Bash(kubectl top *)",
|
||||
"Bash(kubectl config get-contexts *)",
|
||||
"Bash(git log *)",
|
||||
"Bash(git status *)",
|
||||
"Bash(git diff *)",
|
||||
"Bash(git show *)",
|
||||
"Bash(git grep *)",
|
||||
"Bash(git blame *)",
|
||||
"Bash(git ls-files *)",
|
||||
"Bash(git ls-tree *)",
|
||||
"Bash(git rev-parse *)",
|
||||
"Bash(git describe *)",
|
||||
"Bash(git shortlog *)",
|
||||
"Bash(git merge-base *)",
|
||||
"Bash(git reflog show *)",
|
||||
"Bash(git stash list *)",
|
||||
"Bash(git branch --list *)",
|
||||
"Bash(git branch -a *)",
|
||||
"Bash(git branch -v *)",
|
||||
"Bash(git tag --list *)",
|
||||
"Bash(git remote -v)",
|
||||
"Bash(git fetch *)",
|
||||
"Bash(pulumi about *)",
|
||||
"Bash(pulumi plugin ls *)",
|
||||
"Bash(kubectl api-resources *)",
|
||||
"Bash(kubectl api-versions *)",
|
||||
"Bash(kubectl explain *)",
|
||||
"Bash(kubectl version *)",
|
||||
"Bash(kubectl events *)",
|
||||
"Bash(kubectl cluster-info)",
|
||||
"Bash(kubectl auth can-i *)",
|
||||
"Bash(kubectl rollout status *)",
|
||||
"Bash(kubectl rollout history *)",
|
||||
"Bash(kubectl config current-context *)",
|
||||
"Bash(npm ls *)",
|
||||
"Bash(npm outdated *)",
|
||||
"Bash(ls *)",
|
||||
"Bash(pwd)",
|
||||
"Bash(wc *)",
|
||||
"Bash(which *)",
|
||||
"Bash(jq *)",
|
||||
"Bash(git add *)",
|
||||
"Bash(git switch *)",
|
||||
"Bash(.claude/scripts/gitea.sh GET *)",
|
||||
"Bash(.claude/scripts/gitea.sh WAIT *)",
|
||||
"Bash(.claude/scripts/gitea.sh POST *)",
|
||||
"Bash(git commit *)",
|
||||
"Bash(git push *)",
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
---
|
||||
name: merge
|
||||
description: Commit the staged and unstaged changes that fit the branch with meaningful messages, push a branch, open a Gitea PR, wait for CI, and merge it, without stopping for confirmation.
|
||||
argument-hint: [optional note on intent, or paths to limit the merge to]
|
||||
disable-model-invocation: true
|
||||
---
|
||||
|
||||
Take the working tree changes through commit, push, PR and merge in one run. If `$ARGUMENTS` names paths, include only those. If it describes intent, use it for the commit messages and PR.
|
||||
|
||||
Typing `/merge` is the user's explicit instruction to commit, push, open a PR and merge these changes. It satisfies the "commit" and "ask before opening or merging" rules in `CLAUDE.md` for this run. Do not ask for confirmation, and do not pause to show drafts. Stop only for a condition under "Stop conditions".
|
||||
|
||||
## Rules
|
||||
|
||||
- Follow `CONVENTIONS.md` for branch names, commit messages and PR titles.
|
||||
- Add no AI attribution to commits or PRs.
|
||||
- Never use `--no-verify`, force push, or commit directly to `main`.
|
||||
- Use `.claude/scripts/gitea.sh` for PR calls, because `gh` does not work here. `$REPO` below means `/repos/kasun/homelab-infrastructure-as-code`, and must be written out in full in each command.
|
||||
- Never stage `Pulumi.dev.yaml`, `.env` files, keys, credentials, `.claude/settings.local.json`, or anything in `sdks/`. Leave them out, carry on, and mention them in the report.
|
||||
- Write commit messages and JSON bodies to files in the scratchpad directory with the Write tool.
|
||||
- Run each command on its own, in the exact forms below, from the repo root. `cd` prefixes, pipes, loops and redirects cause permission prompts.
|
||||
|
||||
## Stop conditions
|
||||
|
||||
Stop and report only if:
|
||||
|
||||
- HEAD is detached, or a merge or rebase is in progress.
|
||||
- There are no changes and no unpushed commits.
|
||||
- Typecheck or `pulumi preview` fails.
|
||||
- The preview shows a replace or delete of a VM, a PVC, or an imported resource.
|
||||
- A file that looks like a secret is the only change.
|
||||
- A commit hook, push or API call fails after one corrected retry of a message-format error.
|
||||
- CI fails, or the PR is not mergeable.
|
||||
|
||||
Leave the branch and PR in place when stopping after they exist, and say what is needed to continue.
|
||||
|
||||
## 1. Inspect
|
||||
|
||||
1. Run `git status`, `git diff --staged`, `git diff`, and `git log --oneline -5`. Read any untracked files that would be included.
|
||||
2. Run `git fetch origin main`.
|
||||
3. On a non-`main` branch, run `.claude/scripts/gitea.sh GET $REPO/pulls?state=open`. If this branch has an open PR, reuse it only for changes that serve its purpose. If all remaining changes are unrelated to it, take that PR through steps 6 and 7 first, which returns you to `main`, then continue with the remaining changes as new work.
|
||||
|
||||
## 2. Group into commits
|
||||
|
||||
Split by reason for the change, and decide without asking. Each commit should make sense and be revertable alone.
|
||||
|
||||
- First decide the PR's purpose from `$ARGUMENTS`, the conversation, the branch name, or else the largest change.
|
||||
- On the first `/merge`, leave out any change that does not serve that purpose, such as an unrelated `.claude/settings.json` edit. Keep it uncommitted and untouched, do not ask, and list it in the report.
|
||||
- On a repeat `/merge`, meaning an earlier run this session left changes out or its PR is still open, handle all remaining changes in this run. Give each separate purpose its own branch and PR, and take them one at a time through steps 3 to 7, so each is merged and you are back on `main` before the next starts. If `$ARGUMENTS` names paths, handle only those.
|
||||
- Use one commit when the remaining changes serve one purpose, and several when they are distinct steps toward it.
|
||||
- Group whole files. If one file mixes purposes, put it in the commit for its main change.
|
||||
- Scope is the stack (`01-proxmox-infra/` is `proxmox-infra`), or `ci` for `.gitea/workflows/`. Omit the scope for repo-wide or `.claude/` changes.
|
||||
- Add a body only when the diff shows a reason that is not obvious. Never invent a reason.
|
||||
|
||||
## 3. Verify
|
||||
|
||||
For each stack with changed code, run:
|
||||
|
||||
- `npm run typecheck --prefix <stack-dir>`
|
||||
- `pulumi preview --cwd <stack-dir> --stack dev`
|
||||
|
||||
## 4. Commit and push
|
||||
|
||||
1. If on `main`, run `git switch -c <type>/<short-kebab-description>`. This carries the changes across.
|
||||
2. For each commit, run `git add -- <paths>`, then `git commit -F <message file> -- <paths>`. Naming the paths commits only those files, whatever else is staged.
|
||||
3. Run `git status` to confirm only intentionally excluded files remain.
|
||||
4. Run `git push -u origin <branch>`.
|
||||
|
||||
## 5. Open the PR
|
||||
|
||||
Unless one exists, run `.claude/scripts/gitea.sh POST $REPO/pulls @<json file>` with `title`, `body`, `head` and `base: "main"`. The body says what changed, why, and the preview result for each stack.
|
||||
|
||||
## 6. Wait for CI
|
||||
|
||||
Get the SHA with `git rev-parse HEAD`, then run `.claude/scripts/gitea.sh WAIT $REPO/commits/<sha>/status` as a background command. Do not write a polling loop, because that causes a permission prompt.
|
||||
|
||||
- Exit 0: checks passed, or it printed `no CI ran` because workflows are path-filtered. Continue.
|
||||
- Exit 1: stop, and report the failing check and its `target_url`.
|
||||
- Exit 3: CI timed out. Stop and report it.
|
||||
|
||||
Then run `.claude/scripts/gitea.sh GET $REPO/pulls/<number>` and confirm `mergeable` is true.
|
||||
|
||||
## 7. Merge
|
||||
|
||||
1. Run `.claude/scripts/gitea.sh POST $REPO/pulls/<number>/merge @<json file>` with `{"Do":"merge","head_commit_id":"<sha>"}`, so only the commit CI checked can merge.
|
||||
2. Run `git fetch origin main:main`, then `git switch main`.
|
||||
|
||||
## 8. Report
|
||||
|
||||
Keep it short:
|
||||
|
||||
- PR link and commits.
|
||||
- What the merge deploys, from the `on.push.paths` in `.gitea/workflows/`. `01`, `03`, `04` and `05` deploy on merge. A change under `.gitea/workflows/` can deploy `03`, `04` and `05`, and a change to `01`'s own workflow deploys `01`.
|
||||
- For `02` changes, say that they are not live until someone runs the manual workflow.
|
||||
- Anything left uncommitted. Also run `git -C .pulumi-config status --short --branch`, and if it shows uncommitted or unpushed changes, remind the user to commit and push them there because CI uses that repo's `main`. Don't commit or push that repo as part of `/merge`.
|
||||
|
||||
Do not delete the branch, dispatch a workflow, or change a live system.
|
||||
@@ -3,6 +3,13 @@ name: Deploy Proxmox Infra
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "01-proxmox-infra/**"
|
||||
- ".gitea/workflows/01-deploy-proxmox-infra.yaml"
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -24,8 +31,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.PROXMOX_INFRA_PULUMI_DEV_YAML }}" | base64 -d > 01-proxmox-infra/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
@@ -51,7 +64,7 @@ jobs:
|
||||
deploy:
|
||||
name: Pulumi Deploy
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
@@ -61,8 +74,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.PROXMOX_INFRA_PULUMI_DEV_YAML }}" | base64 -d > 01-proxmox-infra/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
@@ -75,12 +94,15 @@ jobs:
|
||||
run: pulumi package add terraform-provider marshallford/pfsense 0.22.0
|
||||
working-directory: 01-proxmox-infra
|
||||
|
||||
# Manual runs only: a refresh that finds a VM missing drops it from state,
|
||||
# and `up` would then create a blank replacement without review.
|
||||
- name: Refresh State
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
pulumi login "$PULUMI_BACKEND_URL"
|
||||
pulumi refresh --yes --stack dev \
|
||||
--target 'urn:pulumi:dev::proxmox-infra::proxmoxve*' \
|
||||
--target 'urn:pulumi:dev::proxmox-infra::tls*'
|
||||
--target 'urn:pulumi:dev::proxmox-infra::proxmoxve**' \
|
||||
--target 'urn:pulumi:dev::proxmox-infra::tls**'
|
||||
working-directory: 01-proxmox-infra
|
||||
env:
|
||||
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
|
||||
|
||||
@@ -23,8 +23,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.K8S_BOOTSTRAP_PULUMI_DEV_YAML }}" | base64 -d > 02-k8s-bootstrap/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
@@ -53,8 +59,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.K8S_BOOTSTRAP_PULUMI_DEV_YAML }}" | base64 -d > 02-k8s-bootstrap/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "03-k8s-infra/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/03-deploy-k8s-infra.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -29,8 +29,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.K8S_INFRA_PULUMI_DEV_YAML }}" | base64 -d > 03-k8s-infra/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@v4
|
||||
@@ -62,8 +68,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.K8S_INFRA_PULUMI_DEV_YAML }}" | base64 -d > 03-k8s-infra/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@v4
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "04-k8s-apps/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/04-deploy-k8s-apps.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -29,8 +29,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.K8S_APPS_PULUMI_DEV_YAML }}" | base64 -d > 04-k8s-apps/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
@@ -59,8 +65,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.K8S_APPS_PULUMI_DEV_YAML }}" | base64 -d > 04-k8s-apps/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "05-monitoring/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/05-deploy-monitoring.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -29,8 +29,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.MONITORING_PULUMI_DEV_YAML }}" | base64 -d > 05-monitoring/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
@@ -59,8 +65,14 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Restore Stack Config
|
||||
run: echo "${{ secrets.MONITORING_PULUMI_DEV_YAML }}" | base64 -d > 05-monitoring/Pulumi.dev.yaml
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
name: Deploy Openbao
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "06-openbao/**"
|
||||
- ".gitea/workflows/06-deploy-openbao.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "06-openbao/**"
|
||||
- ".gitea/workflows/**"
|
||||
|
||||
jobs:
|
||||
preview:
|
||||
name: Pulumi Preview
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request'
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
working-directory: 06-openbao
|
||||
|
||||
- name: Preview
|
||||
uses: pulumi/actions@v5
|
||||
with:
|
||||
command: preview
|
||||
stack-name: dev
|
||||
work-dir: 06-openbao
|
||||
cloud-url: ${{ secrets.PULUMI_BACKEND_URL }}
|
||||
env:
|
||||
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
|
||||
|
||||
deploy:
|
||||
name: Pulumi Deploy
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
- name: Checkout Stack Config
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kasun/homelab-pulumi-config
|
||||
ref: main
|
||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
||||
path: .pulumi-config
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
working-directory: 06-openbao
|
||||
|
||||
- name: Refresh State
|
||||
uses: pulumi/actions@v5
|
||||
with:
|
||||
command: refresh
|
||||
stack-name: dev
|
||||
work-dir: 06-openbao
|
||||
cloud-url: ${{ secrets.PULUMI_BACKEND_URL }}
|
||||
env:
|
||||
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
|
||||
|
||||
- name: Deploy
|
||||
uses: pulumi/actions@v5
|
||||
with:
|
||||
command: up
|
||||
stack-name: dev
|
||||
work-dir: 06-openbao
|
||||
cloud-url: ${{ secrets.PULUMI_BACKEND_URL }}
|
||||
env:
|
||||
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Secret Scan
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
BETTERLEAKS_VERSION: "1.10.1"
|
||||
BETTERLEAKS_SHA256: c174b42d7aa60caf58c0c3e555c0e4bed01fe6b0d99a412bce777b5af4ce913e
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
name: Betterleaks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Full History
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Betterleaks
|
||||
run: |
|
||||
curl -fsSL -o /tmp/betterleaks.tar.gz \
|
||||
"https://github.com/betterleaks/betterleaks/releases/download/v${BETTERLEAKS_VERSION}/betterleaks_${BETTERLEAKS_VERSION}_linux_x64.tar.gz"
|
||||
echo "${BETTERLEAKS_SHA256} /tmp/betterleaks.tar.gz" | sha256sum -c -
|
||||
tar -xzf /tmp/betterleaks.tar.gz -C /tmp betterleaks
|
||||
|
||||
- name: Scan Git History
|
||||
run: /tmp/betterleaks git . --redact --verbose --no-banner --no-color --log-opts="--all -m -p -U0"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git pre-commit hook: blocks a commit if its staged changes contain a secret.
|
||||
#
|
||||
# Activate once per clone: git config core.hooksPath .githooks
|
||||
# Skip in an emergency: git commit --no-verify
|
||||
if ! command -v betterleaks >/dev/null 2>&1; then
|
||||
echo "pre-commit: betterleaks is not installed, so staged changes can't be scanned" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec betterleaks git --pre-commit --staged --redact --no-banner --no-color .
|
||||
+4
-1
@@ -5,4 +5,7 @@ node_modules/
|
||||
bin/
|
||||
Pulumi.dev.yaml
|
||||
sdks/
|
||||
.env
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
.pulumi-config
|
||||
@@ -11,6 +11,8 @@ config:
|
||||
packages:
|
||||
pfsense:
|
||||
source: terraform-provider
|
||||
version: 1.1.3
|
||||
version: 1.5.1
|
||||
parameters:
|
||||
- marshallford/pfsense
|
||||
- 0.22.0
|
||||
stackConfigDir: ../.pulumi-config/01-proxmox-infra
|
||||
+110
-13
@@ -26,6 +26,12 @@ const worker2Ip = config.requireSecret("worker2Ip");
|
||||
const worker3Ip = config.requireSecret("worker3Ip");
|
||||
|
||||
const ansibleIp = config.requireSecret("ansibleIp");
|
||||
const runnerIp = config.requireSecret("runnerIp");
|
||||
// Generated on the Ansible node and used only for the runner VM, so access to
|
||||
// the runner (and the CI credentials on it) can be revoked on its own.
|
||||
const runnerAnsibleSshPublicKey = config.requireSecret(
|
||||
"runnerAnsibleSshPublicKey",
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// VM templates — one per node, cloned from the downloaded cloud image.
|
||||
@@ -141,7 +147,7 @@ const pveNodes = pveNodeSeeds
|
||||
},
|
||||
],
|
||||
},
|
||||
{ provider: n.provider, ignoreChanges: ["disks"] },
|
||||
{ provider: n.provider, protect: true, ignoreChanges: ["disks"] },
|
||||
),
|
||||
}));
|
||||
|
||||
@@ -291,7 +297,7 @@ const k3sVms = nodeConfigs.map(
|
||||
agent: { enabled: true, timeout: "30s" },
|
||||
cdrom: { fileId: "none" },
|
||||
started: false,
|
||||
stopOnDestroy: true,
|
||||
rebootAfterUpdate: false,
|
||||
},
|
||||
{
|
||||
provider: node.host.provider,
|
||||
@@ -322,7 +328,7 @@ k3sVms.forEach((vmResource, i) => {
|
||||
ipAddress: nodeConfigs[i].ip,
|
||||
hostname: nodeConfigs[i].name,
|
||||
},
|
||||
{ dependsOn: vmResource, provider: pfSenseProvider },
|
||||
{ dependsOn: vmResource, provider: pfSenseProvider, protect: true },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -332,21 +338,21 @@ k3sVms.forEach((vmResource, i) => {
|
||||
// boot; otherwise its first DHCP lease could come from the dynamic pool.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const ansibleHost = hostFor("pve-b550");
|
||||
const proxmoHost = hostFor("pve-b550");
|
||||
const ansibleMac = "02:A5:1B:00:01:54";
|
||||
|
||||
const ansibleTemplate = new proxmox.download.File(
|
||||
const ubuntuTemplate = new proxmox.download.File(
|
||||
"ubuntu-resolute-lxc-pve-b550",
|
||||
{
|
||||
nodeName: ansibleHost.nodeName,
|
||||
datastoreId: ansibleHost.isoStore,
|
||||
nodeName: proxmoHost.nodeName,
|
||||
datastoreId: proxmoHost.isoStore,
|
||||
contentType: "vztmpl",
|
||||
fileName: "ubuntu-26.04-standard_26.04-1_amd64.tar.zst",
|
||||
url: "https://download.proxmox.com/images/system/ubuntu-26.04-standard_26.04-1_amd64.tar.zst",
|
||||
overwrite: false,
|
||||
overwriteUnmanaged: true,
|
||||
},
|
||||
{ provider: ansibleHost.provider },
|
||||
{ provider: proxmoHost.provider },
|
||||
);
|
||||
|
||||
const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
|
||||
@@ -357,24 +363,24 @@ const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
|
||||
ipAddress: ansibleIp,
|
||||
hostname: "ansible",
|
||||
},
|
||||
{ provider: pfSenseProvider },
|
||||
{ provider: pfSenseProvider, protect: true },
|
||||
);
|
||||
|
||||
new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
||||
"ansible",
|
||||
{
|
||||
nodeName: ansibleHost.nodeName,
|
||||
nodeName: proxmoHost.nodeName,
|
||||
description: "Ansible control node — managed by Pulumi",
|
||||
tags: ["ansible"],
|
||||
unprivileged: true,
|
||||
features: { nesting: true },
|
||||
operatingSystem: {
|
||||
templateFileId: ansibleTemplate.id,
|
||||
templateFileId: ubuntuTemplate.id,
|
||||
type: "ubuntu",
|
||||
},
|
||||
cpu: { cores: 1 },
|
||||
memory: { dedicated: 1024, swap: 0 },
|
||||
disk: { datastoreId: ansibleHost.dataStore, size: 8 },
|
||||
disk: { datastoreId: proxmoHost.dataStore, size: 8 },
|
||||
networkInterfaces: [
|
||||
{ name: "eth0", bridge: "vmbr0", macAddress: ansibleMac },
|
||||
],
|
||||
@@ -391,11 +397,102 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
||||
},
|
||||
started: true,
|
||||
startOnBoot: true,
|
||||
protection: true,
|
||||
},
|
||||
{
|
||||
provider: ansibleHost.provider,
|
||||
provider: proxmoHost.provider,
|
||||
dependsOn: ansibleDhcp,
|
||||
retainOnDelete: true,
|
||||
protect: true,
|
||||
},
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Gitea Runner — VM with a pfSense DHCP reservation.
|
||||
// A VM rather than an LXC: jobs run in Docker, and Docker in an LXC needs
|
||||
// nesting + keyctl, which widens the shared-kernel attack surface towards the
|
||||
// Proxmox host. The runner holds the most powerful credentials (Proxmox,
|
||||
// pfSense, Pulumi), so it gets its own kernel. Fixed MAC for the same reason
|
||||
// as the Ansible node: the reservation exists before the first boot.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const runnerMac = "02:A5:1B:00:01:55";
|
||||
|
||||
const runnerDhcp = new pfsense.Dhcpv4Staticmapping(
|
||||
"runner-dhcp",
|
||||
{
|
||||
interface: "lan",
|
||||
macAddress: runnerMac,
|
||||
ipAddress: runnerIp,
|
||||
hostname: "runner",
|
||||
},
|
||||
{ provider: pfSenseProvider, protect: true },
|
||||
);
|
||||
|
||||
new proxmox.VmLegacy( // NOSONAR typescript:S1848
|
||||
"runner",
|
||||
{
|
||||
nodeName: proxmoHost.nodeName,
|
||||
name: "runner",
|
||||
description: "Gitea Runner — managed by Pulumi",
|
||||
tags: ["runner"],
|
||||
clone: {
|
||||
vmId: proxmoHost.pveTemplate.vmId,
|
||||
full: true,
|
||||
datastoreId: proxmoHost.dataStore,
|
||||
},
|
||||
cpu: {
|
||||
cores: 2,
|
||||
sockets: 1,
|
||||
type: "host",
|
||||
numa: true,
|
||||
},
|
||||
memory: {
|
||||
dedicated: 4096,
|
||||
floating: 0,
|
||||
},
|
||||
disks: [
|
||||
{
|
||||
interface: "scsi0",
|
||||
datastoreId: proxmoHost.dataStore,
|
||||
size: 20,
|
||||
ssd: true,
|
||||
discard: "on",
|
||||
},
|
||||
],
|
||||
initialization: {
|
||||
datastoreId: proxmoHost.dataStore,
|
||||
ipConfigs: [{ ipv4: { address: "dhcp" } }],
|
||||
// Key-only login: no password, unlike the k3s nodes.
|
||||
userAccount: {
|
||||
username: "ubuntu",
|
||||
keys: [
|
||||
pve1SshPublicKey.apply((k) => k.trim()),
|
||||
pve2SshPublicKey.apply((k) => k.trim()),
|
||||
pve3SshPublicKey.apply((k) => k.trim()),
|
||||
runnerAnsibleSshPublicKey.apply((k) => k.trim()),
|
||||
],
|
||||
},
|
||||
},
|
||||
networkDevices: [
|
||||
{ bridge: "vmbr0", model: "virtio", macAddress: runnerMac },
|
||||
],
|
||||
scsiHardware: "virtio-scsi-pci",
|
||||
serialDevices: [{}],
|
||||
vga: { type: "serial0" },
|
||||
agent: { enabled: true, timeout: "30s" },
|
||||
cdrom: { fileId: "none" },
|
||||
started: true,
|
||||
onBoot: true,
|
||||
protection: true,
|
||||
rebootAfterUpdate: false,
|
||||
},
|
||||
{
|
||||
provider: proxmoHost.provider,
|
||||
dependsOn: runnerDhcp,
|
||||
retainOnDelete: true,
|
||||
protect: true,
|
||||
ignoreChanges: ["clone", "disks[0].speed"],
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Generated
+378
-1704
File diff suppressed because it is too large.
Load diff
@@ -8,6 +8,6 @@
|
||||
|
||||
## Running against live VMs
|
||||
|
||||
Re-running this stack restarts the bootstrap sequence against already-provisioned VMs. That's why it only deploys via manual dispatch. For changes to the running cluster, write the code for a fresh bootstrap and give separate manual steps.
|
||||
Re-running this stack restarts the bootstrap sequence against already-provisioned VMs. That's why it only deploys via manual dispatch. For changes to the running cluster, write the code for a fresh bootstrap and give separate manual steps. To rebuild the whole cluster, follow [the rebuild runbook](../docs/runbooks/full-cluster-rebuild.md).
|
||||
|
||||
The SSH key comes from `proxmox-infra`'s first `pulumi up`. VMs created before that need the public key added to `~/.ssh/authorized_keys` by hand.
|
||||
@@ -8,3 +8,4 @@ config:
|
||||
pulumi:tags:
|
||||
value:
|
||||
pulumi:template: typescript
|
||||
stackConfigDir: ../.pulumi-config/02-k8s-bootstrap
|
||||
@@ -0,0 +1,34 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIF3TCCA8WgAwIBAgIUDXajbsIFjkrtUM/HEOAMI06xHjEwDQYJKoZIhvcNAQEL
|
||||
BQAwdjEkMCIGA1UEAwwbUHJveG1veCBWaXJ0dWFsIEVudmlyb25tZW50MS0wKwYD
|
||||
VQQLDCRiYTk0ZDJhZC0wOTc2LTRmZjAtODQ1Mi1kMjM1OGMxZGM3OGIxHzAdBgNV
|
||||
BAoMFlBWRSBDbHVzdGVyIE1hbmFnZXIgQ0EwHhcNMjYxMTAzMDAwODM5WhcNMzYx
|
||||
MDMxMDAwODM5WjB2MSQwIgYDVQQDDBtQcm94bW94IFZpcnR1YWwgRW52aXJvbm1l
|
||||
bnQxLTArBgNVBAsMJGJhOTRkMmFkLTA5NzYtNGZmMC04NDUyLWQyMzU4YzFkYzc4
|
||||
YjEfMB0GA1UECgwWUFZFIENsdXN0ZXIgTWFuYWdlciBDQTCCAiIwDQYJKoZIhvcN
|
||||
AQEBBQADggIPADCCAgoCggIBAM1OPRmaMGdkrgVQikVCOFAF7eXL0H7lUfognG4A
|
||||
Xi/D85bLKGJYF106PQFlmkvw+CvNIHCeeqvgDJc2AoV22PnKjPlP34b3j4AAoEm3
|
||||
sMvKHke+N3kSfhG7hxZ8JfnV+EIZO1ZAI0X2z0ixmmn3gzIVjdtO9VycL7Nj2JJV
|
||||
O+Ws+yc3j3swhVA87bIikc+sD0YT8F8dK41DQfgM01wWhieGLCk4g8DSbOt1Ypgv
|
||||
hAwlKziUtUdw/teC8vmE0GwUMas/uwFVXzBEd/4ancI1SkPH/Mtu568HCVzcCBjE
|
||||
wFAhdMZ90g7UXC58m5cFqs2PafDsAYv2rmSCic8yO2aZCO5nbQOtU9rN2b1e9KGs
|
||||
xfDksugSJ2ZsIZ4YsG9Eao6WXkZIohANEhUkGK3yI4REiJO96/pmqf1QtNRvUZWW
|
||||
YIxa56i2KrjB2RdGe9eirNlshTPA3DpJbLHmcsw1agPEI5mN4uQJ3DrSGrFwXHkB
|
||||
QYW9NmgwLHUlOYdvUUq7AIY3RqCBWWkBW0vlg78W2fiaq1Gp6Mx/9HeVdriB2FGa
|
||||
UlAE6CAzDI+JqQPQkmzo6QmFB3hFa9m1aPctLZo0bOKCeoyREBaPmmZfn6VaI1Xk
|
||||
+mUIw6NLstdG0lS/qThNYbG5LWdRIyHdLcjsg19pFfmj9YUMphoMD7k2IG4Cu9nP
|
||||
mwqlAgMBAAGjYzBhMB0GA1UdDgQWBBTKcVA3Li/Qe4f/vEsHFHc/VNVFHzAfBgNV
|
||||
HSMEGDAWgBTKcVA3Li/Qe4f/vEsHFHc/VNVFHzAPBgNVHRMBAf8EBTADAQH/MA4G
|
||||
A1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAMLrQvbGlgpqxSaxQKb4N
|
||||
wmmRQqgWvJ7/s9UhHE5BNfkUzJ+3ktAwfbswuNc4yfREjPqRBWzd/mz/WhlsDOzR
|
||||
KT+ECQpNbnlR3JBJMYOiLDwKydnYWgiTiINxtc7p74NoGe/fu8dGKiGYtsk+bmps
|
||||
yP1FOp3YQ2UM1NjQoalk2sZYOCRUL1HbgfaSHEwFXskJMKprUEEjJjXLxyJey14U
|
||||
u6gSvUb2T8bbycW8Ilibo5Dn/DxLFBNT154M7GHQyVSdWLoEAVVzkrlJJ9b0RYnb
|
||||
PQXOySSuIvrQx8QqG6X/4AfPrm2L1O8CAAwpNi3xa6jvVX6DWT1+HOhN8MfjtYJE
|
||||
9KxbG6MNxnE8A39m46O2iYfwW+zTej842N1Fq6eA7i2nMuzHB3jqNVdvxaLCNK2a
|
||||
FCAilpl2iuqO5eOWZG2Gd9qcPQSslRrhJid6GV/pTeh/ZpZyf/OG4XXata+IB2aq
|
||||
0ggaQgGn5dFiCklLeFsnX0k0pydz/ZVA1v5C/sVk3q07JrPJo0IKs0SuS0lsHH9n
|
||||
hPIdbUH3AsG850vDTIsKYgmZdssnG13bsGwZtC8x3MS1c868PRgG/ZycdT6BGk6Q
|
||||
qX9ogoFrdUy3XYSRVDb2L+Z8NEI8grFOTDRXAlp5B4BHAbvXoIeeYjGtjtOunYCo
|
||||
f3Em5SShmS4B2U/jTPyDeZ0=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,34 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIF3TCCA8WgAwIBAgIUUfheavZDUF4EvmQ6q8upF7dd74UwDQYJKoZIhvcNAQEL
|
||||
BQAwdjEkMCIGA1UEAwwbUHJveG1veCBWaXJ0dWFsIEVudmlyb25tZW50MS0wKwYD
|
||||
VQQLDCQxZWQ0Nzc1Yi1hMjc1LTQ3ZDktYTA1Mi1kM2M1MThhYjE2MzIxHzAdBgNV
|
||||
BAoMFlBWRSBDbHVzdGVyIE1hbmFnZXIgQ0EwHhcNMjYxMTAyMDMzMDIxWhcNMzYx
|
||||
MDMwMDMzMDIxWjB2MSQwIgYDVQQDDBtQcm94bW94IFZpcnR1YWwgRW52aXJvbm1l
|
||||
bnQxLTArBgNVBAsMJDFlZDQ3NzViLWEyNzUtNDdkOS1hMDUyLWQzYzUxOGFiMTYz
|
||||
MjEfMB0GA1UECgwWUFZFIENsdXN0ZXIgTWFuYWdlciBDQTCCAiIwDQYJKoZIhvcN
|
||||
AQEBBQADggIPADCCAgoCggIBAK3vi3/3+0trXhEkDXoSrOFWTuXc7x7vPmORzQ6R
|
||||
V/sg1X6KTbguzSPg71B/8Qu1vRYTkS6Pf5YclpE0P+z45hCV+G8B40cAL3D1Xpbo
|
||||
JTznI2gaO00XDTei1MdDTC/mwUzoNBa7osXEmMwgz7Oid7WHJbIQegwq2LEMRbqQ
|
||||
UtAXsAone1eq+N2vQys57MlnXnSbMFFlY1VNfUJIinjyLZgE9klFkvVFSqy9CkUs
|
||||
4Yq9M6YSgvNA77tPSH/yc0605N1462x/VRHUkY4nufrWqI8oUlcGrK8mNieCtPK7
|
||||
FOr3PZXq5K0I3LsSlbp7M43Bbumnuscg0ustyf/eCM7tdMQm9E5yfQsMH+Ao390x
|
||||
nBrlpVqA6RSWGAeDhspuB6Sj+InVfzoLKvhqwzlGV5S+WT+uDN4VhRdGlet/kVC8
|
||||
Xn5GIRgeGR/x5zs93Xxz9OEyVhSxPB6+NP/NJ4z7OD21Oiar7GUFzPbaMpWnSChW
|
||||
5Vsp2i8HUikjUyiGb8nYZfVEHwj/w3JEs+m4eTwUroT4YgLRMwahye5gJTcq19oA
|
||||
xFUzStAXEGglv5AVf0ngU3KTkwFP2ROLry/FIk6ZQSedJtnBpq0+CcMZe+vKSVD7
|
||||
acFZ6k/bFh4jMeD9i1/Zx+mRf8XvZEeaImxYc0P9vnxfl2XP7QiroEP7PkuFZ6As
|
||||
69rpAgMBAAGjYzBhMB0GA1UdDgQWBBSex+vVqEdCLAk0eKJiSfYltlTaKTAfBgNV
|
||||
HSMEGDAWgBSex+vVqEdCLAk0eKJiSfYltlTaKTAPBgNVHRMBAf8EBTADAQH/MA4G
|
||||
A1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAkeVBiV4Zs+yoXKTcdy0A
|
||||
Y7cEAGUY+zWQeg/eZnbNMWqG5x4UKWpA+9LZDOhAu7lBwkWoTlYLw6foDuy47uzQ
|
||||
LBxqxI5gXkUi/CvIlOZ8AjuNdVU02wdDoib8O5mJDpvEMIOQawbRno84mlYdzhRs
|
||||
BHeBugNdiORBk1JbqZjsvAmtlbjDaDNV0oxm9C5Np4F9sbA9lChkz+bv/KJxYexB
|
||||
P91nonJfmyajDkWqrCaFIyjliNjfmff1CM2EpNDlngwXo6XjSgWjFuEVtHE2xl3t
|
||||
J21a0WSxuIkQUNWJMcyr9j9LLAnZG06XCNEy6g2R8vMFmm3xGM76NkABkCsFT5PZ
|
||||
lEmrAVmVDWKx2heAlVmVQ1wFrlGVYnlVxTWWcIHrHRCJJfc12tCwczbumBDxO45u
|
||||
iJ5d4GI5HBSYz3kdMzzpBhLIH5l5h/AzmGebkhbSAK7I/V0kPOQvOVVrtCYr/Ec4
|
||||
gU1AV6bjiu3USOeiAqkxW791Xp0IFkP+8e4FYohyG6QyS5jHtf0Vtl8/xJSKU9mj
|
||||
idc4dwZSWu0V9LaNcMbk8kyRTvX/LwKuLOYp++a0/vxUMvgsv0yqeElvWAJB33xe
|
||||
Ih/rsFCIC247ccQZ1g4JGHRJqRTAIQT4VsDqSRh+0KwarPvgJPEsluDB9bholfZ9
|
||||
LoZqoymHgYm95H7LaDTdytA=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,34 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFzTCCA7WgAwIBAgIUHFXkUXk2cmTrkKJxLSTvxhg5lfowDQYJKoZIhvcNAQEL
|
||||
BQAwdjEkMCIGA1UEAwwbUHJveG1veCBWaXJ0dWFsIEVudmlyb25tZW50MS0wKwYD
|
||||
VQQLDCQ4NzNhNGYzMS05YWQ2LTQ3MDYtYTg5MS0xZmU2NDIzNzgyYzQxHzAdBgNV
|
||||
BAoMFlBWRSBDbHVzdGVyIE1hbmFnZXIgQ0EwHhcNMjUwODI5MjIzNjU5WhcNMzUw
|
||||
ODI3MjIzNjU5WjB2MSQwIgYDVQQDDBtQcm94bW94IFZpcnR1YWwgRW52aXJvbm1l
|
||||
bnQxLTArBgNVBAsMJDg3M2E0ZjMxLTlhZDYtNDcwNi1hODkxLTFmZTY0MjM3ODJj
|
||||
NDEfMB0GA1UECgwWUFZFIENsdXN0ZXIgTWFuYWdlciBDQTCCAiIwDQYJKoZIhvcN
|
||||
AQEBBQADggIPADCCAgoCggIBAL3iGXWp8BkVcXIpfVybY0slRl36bQp3OkswgTc9
|
||||
awdsN62wWkN6NIa4yZsItzjHnCyte6Nac9qCmu25Pwhw4QEc7XRWuh4sVPvw4ica
|
||||
0JgDw7yJbn8IM3C7qm9+g5iXoGcOdY41xsKJz7+cWgySh4EBPWYEuKOxtWuvTRzV
|
||||
Q3b/o+LT8X/Q5qR7EehgLVy5KtWZCDjV/6862hh9zEiA87zosULHtVYAa1lWtL48
|
||||
9q0flbQsIIFmaeio/iEJR66YHXTF7AlKaIrXLVCMRdRV6oef/b4SqECwnZVQnE28
|
||||
I1uwnOV88MIfr9sINhdW7ogxSvlGFptkDkRVXnqfIOwLJjjPRuIifFg98KYR1gLp
|
||||
vGMeRY96mJvJ98NUSeVZOQMVs8vnEXHlpPewsklQty23KQJTr42R5zIKXSguZZUU
|
||||
NjNgDTPdUu45jNDu8nzU8guK3AcTkLbtmbL5uUCGZo860ScUFQUtuibou6plYVjx
|
||||
Yca+mH3QoZI/lfnB/f2aNL9JP+DlTUfwTMgSAKiilOOqWvsHLjXvZjZupoAW0Xh4
|
||||
CREKf0n5T9ldy6goRzbmWE475uc0UPtmLdlVrqt0F89YH8wZAlPu91a6pvomWUYX
|
||||
pokkimWvPf3C+YgRDJIkolAQ1l+egnS/KR2tgLVEKktfXm4nRk2VotWOcsBDme40
|
||||
Hwz3AgMBAAGjUzBRMB0GA1UdDgQWBBTK4krmBcFK3+fphDn5+DuknRdz4TAfBgNV
|
||||
HSMEGDAWgBTK4krmBcFK3+fphDn5+DuknRdz4TAPBgNVHRMBAf8EBTADAQH/MA0G
|
||||
CSqGSIb3DQEBCwUAA4ICAQCFW1DCfMOMTy/MvbYT8KKhwLujjjQvdKsgnRaktRzq
|
||||
j66dohxWHiN0jDDgIeT1DkB/guh5pqcDnwVaiVZAagEJ/NvigTPRodTcijhomCzz
|
||||
p9GCaMnl21YX2D5Ckg69iJ+AVekwNTHWqAVwbXZj1dpxs3SBceps9NQvzfNUI823
|
||||
jDNpgYo9E4kymBIe8ibXNXiGbrZb171aqWzdJEdXIGmvbruXiIOwkkynJHViMo1Y
|
||||
8RiUQx+NwGJw5NTTuHuCI0zYTxrqObPvtfwvyYEpaOf1fs246fRHDo8okffxLuMR
|
||||
AbEVJuU4GCh3JhO5M1BUWEKllx4wZW8/ygtHc8TkKwxMQS86/bEptSoMn0TJ0XeC
|
||||
YnnhML0XD0aRtcoqRhmfBjMntNeiHaAkXusLyc8LNyynhqWv3ldTw05JSfVSlhjC
|
||||
paJNzLYYFa2VC/EG++1Kv6nvZjNZHzV34fkBw9dS6cJbhp5WK7WQgoZgIUF6kJN3
|
||||
nEm0DzRUR6R4KjNgYJxmhXxHvKOeYyp52muiNkehFZ0d1/RdftgUvjh8pR7KEfSH
|
||||
JaO5K0BWMy7infAcAOHb6krEMwfkr3NXUfF4pbuqNGQx5MHYfXkPiIdPy6q6ZqmO
|
||||
ittFd5xKjL7J0QaDkAcxmJFJ2FdtQhoV14eKESBUdQV0NCSKXQgebkV5a8ik0mJU
|
||||
GA==
|
||||
-----END CERTIFICATE-----
|
||||
+102
-27
@@ -4,14 +4,21 @@ import * as command from "@pulumi/command";
|
||||
const config = new pulumi.Config();
|
||||
|
||||
// Bootstrap commands run once, on a fresh install. Without this, a changed VM
|
||||
// ID or command would re-run the k3s installer on the live cluster. After
|
||||
// recreating a VM, re-run its commands explicitly with --target-replace.
|
||||
// ID, node IP, SSH key or command would re-run the k3s installer on the live
|
||||
// cluster. After recreating a VM, re-run its commands explicitly with
|
||||
// --target-replace.
|
||||
pulumi.runtime.registerResourceTransform((args) =>
|
||||
args.type.startsWith("command:")
|
||||
? {
|
||||
props: args.props,
|
||||
opts: pulumi.mergeOptions(args.opts, {
|
||||
ignoreChanges: ["create", "triggers"],
|
||||
ignoreChanges: [
|
||||
"create",
|
||||
"triggers",
|
||||
"connection",
|
||||
"environment",
|
||||
"stdin",
|
||||
],
|
||||
}),
|
||||
}
|
||||
: undefined,
|
||||
@@ -51,11 +58,26 @@ const worker3Ip = infraRef.requireOutput("worker3Ip");
|
||||
// Pre-shared k3s cluster token
|
||||
const k3sToken = config.requireSecret("k3sToken");
|
||||
|
||||
// Control-plane VIP — floating IP for API server access, ARP-announced by
|
||||
// kube-vip on whichever master is alive. Added as a TLS SAN on master-1's
|
||||
// cert below, then used (instead of master1Ip) for every other node's join
|
||||
// URL and for the exported kubeconfig, so the cluster stays reachable
|
||||
// through the loss of any single master.
|
||||
// Version for fresh installs. Changing it does not upgrade the live cluster.
|
||||
const k3sVersion = "v1.36.2+k3s1";
|
||||
const k3sInstallerUrl = `https://raw.githubusercontent.com/k3s-io/k3s/${encodeURIComponent(k3sVersion)}/install.sh`;
|
||||
|
||||
const secretsEncryptionArgs =
|
||||
"--secrets-encryption --secrets-encryption-provider=secretbox";
|
||||
|
||||
// Runs the pinned installer. The token arrives on stdin and travels in the
|
||||
// environment, so it never appears in process arguments.
|
||||
function k3sInstallScript(
|
||||
installEnv: pulumi.Input<string>,
|
||||
installArgs: pulumi.Input<string>,
|
||||
): pulumi.Output<string> {
|
||||
return pulumi.interpolate`set -euo pipefail; IFS= read -r K3S_TOKEN || true; export K3S_TOKEN; curl -sfL ${k3sInstallerUrl} | sudo --preserve-env=K3S_TOKEN INSTALL_K3S_VERSION='${k3sVersion}' ${installEnv} sh -s - ${installArgs}`;
|
||||
}
|
||||
|
||||
// Kubernetes API address (port 6443), used by kubectl, Pulumi and joining nodes.
|
||||
// pfSense holds this IP, and HAProxy forwards connections to the masters, so
|
||||
// the API doesn't depend on a single master.
|
||||
// This isn't kubeVipAddress in 03-k8s-infra, which is Traefik's IP for web apps.
|
||||
const controlPlaneVipAddress = config.requireSecret("controlPlaneVipAddress");
|
||||
|
||||
// VM IDs and CI runner SSH key — read from proxmox-infra stack outputs
|
||||
@@ -81,37 +103,56 @@ function conn(
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Step 1: Start all VMs (fire-and-forget — VMs are owned by proxmox-infra)
|
||||
// triggers: vmId — forces re-run when VMs are deleted and recreated
|
||||
// Step 1: Start all VMs (VMs are owned by proxmox-infra)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Succeeds if the VM is already running, or reaches running after a start.
|
||||
// TLS is verified against the host's Proxmox CA in certs/. The API token comes
|
||||
// from PVE_API_TOKEN and reaches curl on stdin, keeping it out of process
|
||||
// arguments.
|
||||
function startVmScript(
|
||||
endpoint: pulumi.Input<string>,
|
||||
caName: string,
|
||||
nodeName: string,
|
||||
vmId: pulumi.Input<string>,
|
||||
): pulumi.Output<string> {
|
||||
return pulumi.interpolate`base="${endpoint}/api2/json/nodes/${nodeName}/qemu/${vmId}/status"; ca="certs/${caName}-ca.pem"; auth() { printf 'header = "Authorization: PVEAPIToken=%s"
|
||||
' "$PVE_API_TOKEN"; }; is_running() { auth | curl -sf -K - --cacert "$ca" "$base/current" | grep -Eq '"status" *: *"running"'; }; is_running && exit 0; auth | curl -sf -K - --cacert "$ca" -X POST "$base/start" >/dev/null || exit 1; for i in $(seq 1 30); do is_running && exit 0; sleep 2; done; exit 1`;
|
||||
}
|
||||
|
||||
const startMaster1 = new command.local.Command("start-master-1", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve1ApiToken}" "${pve1Endpoint}/api2/json/nodes/pve/qemu/${master1VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve1Endpoint, "pve1", "pve", master1VmId),
|
||||
environment: { PVE_API_TOKEN: pve1ApiToken },
|
||||
triggers: [master1VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startMaster2 = new command.local.Command("start-master-2", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve3ApiToken}" "${pve3Endpoint}/api2/json/nodes/pve/qemu/${master2VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve3Endpoint, "pve3", "pve", master2VmId),
|
||||
environment: { PVE_API_TOKEN: pve3ApiToken },
|
||||
triggers: [master2VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startWorker1 = new command.local.Command("start-worker-1", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve1ApiToken}" "${pve1Endpoint}/api2/json/nodes/pve/qemu/${worker1VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve1Endpoint, "pve1", "pve", worker1VmId),
|
||||
environment: { PVE_API_TOKEN: pve1ApiToken },
|
||||
triggers: [worker1VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startMaster3 = new command.local.Command("start-master-3", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve2ApiToken}" "${pve2Endpoint}/api2/json/nodes/pve-bckp/qemu/${master3VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve2Endpoint, "pve2", "pve-bckp", master3VmId),
|
||||
environment: { PVE_API_TOKEN: pve2ApiToken },
|
||||
triggers: [master3VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startWorker2 = new command.local.Command("start-worker-2", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve2ApiToken}" "${pve2Endpoint}/api2/json/nodes/pve-bckp/qemu/${worker2VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve2Endpoint, "pve2", "pve-bckp", worker2VmId),
|
||||
environment: { PVE_API_TOKEN: pve2ApiToken },
|
||||
triggers: [worker2VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startWorker3 = new command.local.Command("start-worker-3", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve3ApiToken}" "${pve3Endpoint}/api2/json/nodes/pve/qemu/${worker3VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve3Endpoint, "pve3", "pve", worker3VmId),
|
||||
environment: { PVE_API_TOKEN: pve3ApiToken },
|
||||
triggers: [worker3VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
@@ -143,7 +184,11 @@ const installMaster1 = new command.remote.Command(
|
||||
"install-k3s-master-1",
|
||||
{
|
||||
connection: conn(master1Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_TOKEN='${k3sToken}' sh -s - server --cluster-init --tls-san ${master1Ip} --tls-san ${controlPlaneVipAddress} --disable servicelb --node-name k3s-master-1`,
|
||||
create: k3sInstallScript(
|
||||
"",
|
||||
pulumi.interpolate`server --cluster-init --tls-san ${master1Ip} --tls-san ${controlPlaneVipAddress} --disable servicelb ${secretsEncryptionArgs} --node-name k3s-master-1`,
|
||||
),
|
||||
stdin: k3sToken,
|
||||
triggers: [master1VmId],
|
||||
},
|
||||
{ dependsOn: [waitMaster1Ssh] },
|
||||
@@ -176,7 +221,9 @@ const waitControlPlaneVipReady = new command.remote.Command(
|
||||
"wait-control-plane-vip-ready",
|
||||
{
|
||||
connection: conn(master1Ip),
|
||||
create: pulumi.interpolate`for i in $(seq 1 60); do curl -sk --max-time 3 https://${controlPlaneVipAddress}:6443/healthz && exit 0; sleep 5; done; exit 1`,
|
||||
// 401/403 still prove the API server answered through the VIP: the request
|
||||
// is anonymous, and some clusters reject anonymous health checks.
|
||||
create: pulumi.interpolate`for i in $(seq 1 60); do code=$(curl -sk --max-time 3 -o /dev/null -w '%{http_code}' https://${controlPlaneVipAddress}:6443/healthz); case "$code" in 200|401|403) exit 0;; esac; sleep 5; done; exit 1`,
|
||||
triggers: [master1VmId],
|
||||
},
|
||||
{ dependsOn: [waitK3sMaster1Ready] },
|
||||
@@ -210,7 +257,11 @@ const joinMaster2 = new command.remote.Command(
|
||||
"join-k3s-master-2",
|
||||
{
|
||||
connection: conn(master2Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_TOKEN='${k3sToken}' sh -s - server --server https://${controlPlaneVipAddress}:6443 --disable servicelb --node-name k3s-master-2`,
|
||||
create: k3sInstallScript(
|
||||
"",
|
||||
pulumi.interpolate`server --server https://${controlPlaneVipAddress}:6443 --disable servicelb ${secretsEncryptionArgs} --node-name k3s-master-2`,
|
||||
),
|
||||
stdin: k3sToken,
|
||||
triggers: [master2VmId],
|
||||
},
|
||||
{ dependsOn: [waitMaster2Ssh, waitControlPlaneVipReady] },
|
||||
@@ -220,7 +271,11 @@ const joinMaster3 = new command.remote.Command(
|
||||
"join-k3s-master-3",
|
||||
{
|
||||
connection: conn(master3Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_TOKEN='${k3sToken}' sh -s - server --server https://${controlPlaneVipAddress}:6443 --disable servicelb --node-name k3s-master-3`,
|
||||
create: k3sInstallScript(
|
||||
"",
|
||||
pulumi.interpolate`server --server https://${controlPlaneVipAddress}:6443 --disable servicelb ${secretsEncryptionArgs} --node-name k3s-master-3`,
|
||||
),
|
||||
stdin: k3sToken,
|
||||
triggers: [master3VmId],
|
||||
},
|
||||
{ dependsOn: [waitMaster3Ssh, waitControlPlaneVipReady, joinMaster2] },
|
||||
@@ -264,7 +319,11 @@ const joinWorker1 = new command.remote.Command(
|
||||
"join-k3s-worker-1",
|
||||
{
|
||||
connection: conn(worker1Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-1`,
|
||||
create: k3sInstallScript(
|
||||
pulumi.interpolate`K3S_URL=https://${controlPlaneVipAddress}:6443`,
|
||||
"--node-name k3s-worker-1",
|
||||
),
|
||||
stdin: k3sToken,
|
||||
triggers: [worker1VmId],
|
||||
},
|
||||
{ dependsOn: [waitWorker1Ssh] },
|
||||
@@ -274,7 +333,11 @@ const joinWorker2 = new command.remote.Command(
|
||||
"join-k3s-worker-2",
|
||||
{
|
||||
connection: conn(worker2Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-2`,
|
||||
create: k3sInstallScript(
|
||||
pulumi.interpolate`K3S_URL=https://${controlPlaneVipAddress}:6443`,
|
||||
"--node-name k3s-worker-2",
|
||||
),
|
||||
stdin: k3sToken,
|
||||
triggers: [worker2VmId],
|
||||
},
|
||||
{ dependsOn: [waitWorker2Ssh] },
|
||||
@@ -284,7 +347,11 @@ const joinWorker3 = new command.remote.Command(
|
||||
"join-k3s-worker-3",
|
||||
{
|
||||
connection: conn(worker3Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-3`,
|
||||
create: k3sInstallScript(
|
||||
pulumi.interpolate`K3S_URL=https://${controlPlaneVipAddress}:6443`,
|
||||
"--node-name k3s-worker-3",
|
||||
),
|
||||
stdin: k3sToken,
|
||||
triggers: [worker3VmId],
|
||||
},
|
||||
{ dependsOn: [waitWorker3Ssh] },
|
||||
@@ -304,11 +371,15 @@ workers.forEach((worker, i) => {
|
||||
connection: conn(worker),
|
||||
create: `set -euo pipefail;
|
||||
DISK_ID=$(ls /dev/disk/by-id/ | grep 'scsi1');
|
||||
[ "$(echo "$DISK_ID" | wc -l)" -eq 1 ];
|
||||
DISK_PATH="/dev/disk/by-id/$DISK_ID";
|
||||
sudo blkid "$DISK_PATH" >/dev/null 2>&1 || sudo mkfs.ext4 "$DISK_PATH";
|
||||
BLKID_RC=0;
|
||||
sudo blkid -p "$DISK_PATH" >/dev/null 2>&1 || BLKID_RC=$?;
|
||||
if [ "$BLKID_RC" -eq 2 ]; then sudo mkfs.ext4 "$DISK_PATH"; elif [ "$BLKID_RC" -ne 0 ]; then exit "$BLKID_RC"; fi;
|
||||
sudo mkdir -p /mnt/longhorn-extra;
|
||||
echo ""$DISK_PATH" /mnt/longhorn-extra ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab;
|
||||
grep -qs " /mnt/longhorn-extra " /etc/fstab || echo "$DISK_PATH /mnt/longhorn-extra ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab;
|
||||
sudo mount -a;
|
||||
mountpoint -q /mnt/longhorn-extra;
|
||||
df -h /mnt/longhorn-extra`,
|
||||
},
|
||||
{ dependsOn: workerSshReader[i] },
|
||||
@@ -326,7 +397,10 @@ const getKubeconfig = new command.remote.Command(
|
||||
create: `sudo cat /etc/rancher/k3s/k3s.yaml`,
|
||||
triggers: [master1VmId],
|
||||
},
|
||||
{ dependsOn: [joinWorker1, joinWorker2, joinWorker3] },
|
||||
{
|
||||
dependsOn: [joinWorker1, joinWorker2, joinWorker3],
|
||||
additionalSecretOutputs: ["stdout"],
|
||||
},
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -377,7 +451,8 @@ allVms.forEach(({ id, ip, name, readiness }) => {
|
||||
`install-packages-${name}`,
|
||||
{
|
||||
connection: conn(ip),
|
||||
create: pulumi.interpolate`sudo apt update && sudo apt install -y qemu-guest-agent && sudo systemctl enable --now qemu-guest-agent`,
|
||||
// cloud-init exit code 2 means it finished with recoverable errors.
|
||||
create: pulumi.interpolate`{ sudo cloud-init status --wait >/dev/null || [ $? -eq 2 ]; } && sudo apt-get -o DPkg::Lock::Timeout=300 update && sudo apt-get -o DPkg::Lock::Timeout=300 install -y qemu-guest-agent && sudo systemctl enable --now qemu-guest-agent`,
|
||||
triggers: [id],
|
||||
},
|
||||
{ dependsOn: readiness },
|
||||
|
||||
Generated
+375
-1807
File diff suppressed because it is too large.
Load diff
@@ -10,7 +10,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@pulumi/command": "^1.2.1",
|
||||
"@pulumi/kubernetes": "^4.31.1",
|
||||
"@pulumi/pulumi": "^3.244.0"
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,4 @@ runtime:
|
||||
name: nodejs
|
||||
options:
|
||||
packagemanager: npm
|
||||
stackConfigDir: ../.pulumi-config/03-k8s-infra
|
||||
+12
-1
@@ -16,6 +16,10 @@ const truenasNfsPath = config.requireSecret("truenasNfsPath");
|
||||
const cloudflareToken = config.requireSecret("cloudflareApiToken");
|
||||
const letsencryptEmail = config.requireSecret("letsencryptEmail");
|
||||
|
||||
// Traefik's IP for web apps (ports 80 and 443). kube-vip announces it on the
|
||||
// LAN, and the app domains in pfSense's DNS Resolver must point to it.
|
||||
// This isn't the Kubernetes API address. That's controlPlaneVipAddress in
|
||||
// 02-k8s-bootstrap, which is provided by pfSense and HAProxy.
|
||||
const kubeVipAddress = config.requireSecret("kubeVipAddress");
|
||||
const kubeVipInterface = config.require("kubeVipInterface");
|
||||
|
||||
@@ -23,7 +27,13 @@ const domain = config.requireSecret("domain");
|
||||
const longhornUiUser = config.requireSecret("longhornUiUser");
|
||||
const longhornUiPassword = config.requireSecret("longhornUiPassword");
|
||||
|
||||
const k8sProvider = new k8s.Provider("k3s", { kubeconfig });
|
||||
// A fixed identifier makes kubeconfig changes (e.g. a new API address) provider
|
||||
// updates. Without it, they replace the provider and every resource in this
|
||||
// stack. Changing this value triggers that replacement, so never change it.
|
||||
const k8sProvider = new k8s.Provider("k3s", {
|
||||
kubeconfig,
|
||||
clusterIdentifier: "homelab-k3s",
|
||||
});
|
||||
const opts = (extras?: pulumi.ResourceOptions): pulumi.ResourceOptions => ({
|
||||
provider: k8sProvider,
|
||||
...extras,
|
||||
@@ -541,6 +551,7 @@ const kubeVipCloudProvider = new k8s.apps.v1.Deployment(
|
||||
opts({ dependsOn: [cloudProviderClusterRoleBinding, kubeVipPool] }),
|
||||
);
|
||||
|
||||
// Assigns kubeVipAddress to the Traefik Service that k3s creates.
|
||||
new k8s.core.v1.ServicePatch(
|
||||
"traefik-vip",
|
||||
{
|
||||
|
||||
Generated
+392
-1682
File diff suppressed because it is too large.
Load diff
@@ -5,11 +5,11 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18",
|
||||
"typescript": "^5.0.0"
|
||||
"@types/node": "^24.19.4",
|
||||
"typescript": "^6.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pulumi/kubernetes": "^4.0.0",
|
||||
"@pulumi/pulumi": "^3.113.0"
|
||||
"@pulumi/kubernetes": "^4.31.1",
|
||||
"@pulumi/pulumi": "^3.278.0"
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,4 @@ runtime:
|
||||
name: nodejs
|
||||
options:
|
||||
packagemanager: npm
|
||||
stackConfigDir: ../.pulumi-config/04-k8s-apps
|
||||
@@ -10,7 +10,13 @@ const bootstrapRef = new pulumi.StackReference(
|
||||
const kubeconfig = bootstrapRef.requireOutput("kubeconfig");
|
||||
export const domain = config.requireSecret("domain");
|
||||
|
||||
const k8sProvider = new k8s.Provider("k3s", { kubeconfig });
|
||||
// A fixed identifier makes kubeconfig changes (e.g. a new API address) provider
|
||||
// updates. Without it, they replace the provider and every resource in this
|
||||
// stack. Changing this value triggers that replacement, so never change it.
|
||||
const k8sProvider = new k8s.Provider("k3s", {
|
||||
kubeconfig,
|
||||
clusterIdentifier: "homelab-k3s",
|
||||
});
|
||||
const opts = (extras?: pulumi.ResourceOptions): pulumi.ResourceOptions => ({
|
||||
provider: k8sProvider,
|
||||
...extras,
|
||||
|
||||
Generated
+385
-1675
File diff suppressed because it is too large.
Load diff
@@ -1,3 +1,3 @@
|
||||
# monitoring
|
||||
|
||||
- The `monitoring` namespace and the `kube-prometheus-stack` Helm release were adopted from existing cluster resources via the Pulumi `import` option. Be careful with renames or changes that would force a replace.
|
||||
- The `monitoring` namespace and the `kube-prometheus-stack` Helm release were originally adopted from existing cluster resources and are now `protected`. Be careful with renames or changes that would force a replace.
|
||||
@@ -4,3 +4,4 @@ runtime:
|
||||
name: nodejs
|
||||
options:
|
||||
packagemanager: npm
|
||||
stackConfigDir: ../.pulumi-config/05-monitoring
|
||||
@@ -18,12 +18,18 @@ const grafanaDbPassword = config.requireSecret("grafanaDbPassword");
|
||||
const grafanaDbHost = config.requireSecret("grafanaDbHost");
|
||||
const grafanaDbName = config.require("grafanaDbName");
|
||||
|
||||
const k8sProvider = new k8s.Provider("k3s", { kubeconfig });
|
||||
// A fixed identifier makes kubeconfig changes (e.g. a new API address) provider
|
||||
// updates. Without it, they replace the provider and every resource in this
|
||||
// stack. Changing this value triggers that replacement, so never change it.
|
||||
const k8sProvider = new k8s.Provider("k3s", {
|
||||
kubeconfig,
|
||||
clusterIdentifier: "homelab-k3s",
|
||||
});
|
||||
|
||||
const monitoringNs = new k8s.core.v1.Namespace(
|
||||
"monitoring",
|
||||
{ metadata: { name: "monitoring" } },
|
||||
{ provider: k8sProvider, import: "monitoring" },
|
||||
{ provider: k8sProvider, protect: true },
|
||||
);
|
||||
|
||||
const grafanaHost = pulumi.interpolate`grafana.${domain}`;
|
||||
@@ -95,5 +101,5 @@ new k8s.helm.v3.Release(
|
||||
alertmanager: { enabled: false },
|
||||
},
|
||||
},
|
||||
{ provider: k8sProvider, import: "monitoring/kube-prometheus-stack" },
|
||||
{ provider: k8sProvider, protect: true },
|
||||
);
|
||||
Generated
+385
-1675
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
name: openbao
|
||||
description: Openbao stack for centralized ha secret management
|
||||
runtime:
|
||||
name: nodejs
|
||||
options:
|
||||
packagemanager: npm
|
||||
stackConfigDir: ../.pulumi-config/06-openbao
|
||||
@@ -0,0 +1,343 @@
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import * as k8s from "@pulumi/kubernetes";
|
||||
|
||||
const bootstrapRef = new pulumi.StackReference(
|
||||
`${pulumi.getOrganization()}/k8s-bootstrap/dev`,
|
||||
);
|
||||
const appsRef = new pulumi.StackReference(
|
||||
`${pulumi.getOrganization()}/k8s-apps/dev`,
|
||||
);
|
||||
|
||||
const config = new pulumi.Config();
|
||||
const snapshotS3AccessKeyId = config.requireSecret("snapshotS3AccessKeyId");
|
||||
const snapshotS3SecretAccessKey = config.requireSecret(
|
||||
"snapshotS3SecretAccessKey",
|
||||
);
|
||||
|
||||
const kubeconfig = bootstrapRef.requireOutput("kubeconfig");
|
||||
const domain = appsRef.requireOutput("domain");
|
||||
const openbaoHost = pulumi.interpolate`bao.${domain}`;
|
||||
// RustFS on TrueNAS, see docs/runbooks/truenas-rustfs.md.
|
||||
const snapshotS3Host = pulumi.interpolate`rustfs.${domain}:30292`;
|
||||
const snapshotBucket = "openbao-backups";
|
||||
|
||||
const k8sProvider = new k8s.Provider("k3s", {
|
||||
kubeconfig,
|
||||
clusterIdentifier: "homelab-k3s",
|
||||
});
|
||||
|
||||
const opts = (extras?: pulumi.ResourceOptions): pulumi.ResourceOptions => ({
|
||||
provider: k8sProvider,
|
||||
...extras,
|
||||
});
|
||||
|
||||
const openbaoNs = new k8s.core.v1.Namespace(
|
||||
"openbao",
|
||||
{ metadata: { name: "openbao" } },
|
||||
{ provider: k8sProvider, protect: true },
|
||||
);
|
||||
|
||||
const selfsigned = new k8s.apiextensions.CustomResource(
|
||||
"openbao-selfsigned",
|
||||
{
|
||||
apiVersion: "cert-manager.io/v1",
|
||||
kind: "Issuer",
|
||||
metadata: {
|
||||
name: "openbao-selfsigned",
|
||||
namespace: openbaoNs.metadata.name,
|
||||
},
|
||||
spec: {
|
||||
selfSigned: {},
|
||||
},
|
||||
},
|
||||
opts(),
|
||||
);
|
||||
|
||||
const caCert = new k8s.apiextensions.CustomResource(
|
||||
"openbao-ca",
|
||||
{
|
||||
apiVersion: "cert-manager.io/v1",
|
||||
kind: "Certificate",
|
||||
metadata: { name: "openbao-ca", namespace: openbaoNs.metadata.name },
|
||||
spec: {
|
||||
secretName: "openbao-ca",
|
||||
commonName: "openbao-ca",
|
||||
isCA: true,
|
||||
issuerRef: { name: "openbao-selfsigned", kind: "Issuer" },
|
||||
duration: "87600h",
|
||||
},
|
||||
},
|
||||
opts({ dependsOn: [selfsigned] }),
|
||||
);
|
||||
|
||||
const caIssuer = new k8s.apiextensions.CustomResource(
|
||||
"openbao-ca-issuer",
|
||||
{
|
||||
apiVersion: "cert-manager.io/v1",
|
||||
kind: "Issuer",
|
||||
metadata: { name: "openbao-ca", namespace: openbaoNs.metadata.name },
|
||||
spec: {
|
||||
ca: { secretName: "openbao-ca" },
|
||||
},
|
||||
},
|
||||
opts({ dependsOn: [caCert] }),
|
||||
);
|
||||
|
||||
const serverCert = new k8s.apiextensions.CustomResource(
|
||||
"openbao-server-tls",
|
||||
{
|
||||
apiVersion: "cert-manager.io/v1",
|
||||
kind: "Certificate",
|
||||
metadata: {
|
||||
name: "openbao-server-tls",
|
||||
namespace: openbaoNs.metadata.name,
|
||||
},
|
||||
spec: {
|
||||
secretName: "openbao-server-tls",
|
||||
dnsNames: [
|
||||
"openbao-0.openbao-internal",
|
||||
"openbao-1.openbao-internal",
|
||||
"openbao-2.openbao-internal",
|
||||
"openbao-active.openbao.svc",
|
||||
"localhost",
|
||||
],
|
||||
ipAddresses: ["127.0.0.1"],
|
||||
issuerRef: { name: "openbao-ca", kind: "Issuer" },
|
||||
},
|
||||
},
|
||||
opts({ dependsOn: [caIssuer] }),
|
||||
);
|
||||
|
||||
const serversTransport = new k8s.apiextensions.CustomResource(
|
||||
"openbao-servers-transport",
|
||||
{
|
||||
apiVersion: "traefik.io/v1alpha1",
|
||||
kind: "ServersTransport",
|
||||
metadata: {
|
||||
name: "openbao-servers-transport",
|
||||
namespace: openbaoNs.metadata.name,
|
||||
},
|
||||
spec: {
|
||||
serverName: "openbao-active.openbao.svc",
|
||||
rootCAs: [{ secret: "openbao-server-tls" }],
|
||||
},
|
||||
},
|
||||
opts({ dependsOn: [serverCert] }),
|
||||
);
|
||||
|
||||
// Upload-only RustFS key for the snapshot CronJob. Object lock on the bucket
|
||||
// keeps uploaded snapshots from being deleted or overwritten.
|
||||
const snapshotS3Credentials = new k8s.core.v1.Secret(
|
||||
"openbao-snapshot-s3",
|
||||
{
|
||||
metadata: {
|
||||
name: "openbao-snapshot-s3",
|
||||
namespace: openbaoNs.metadata.name,
|
||||
},
|
||||
stringData: {
|
||||
AWS_ACCESS_KEY_ID: snapshotS3AccessKeyId,
|
||||
AWS_SECRET_ACCESS_KEY: snapshotS3SecretAccessKey,
|
||||
},
|
||||
},
|
||||
opts(),
|
||||
);
|
||||
|
||||
new k8s.helm.v3.Release(
|
||||
"openbao",
|
||||
{
|
||||
name: "openbao",
|
||||
chart: "openbao",
|
||||
repositoryOpts: { repo: "https://openbao.github.io/openbao-helm" },
|
||||
namespace: "openbao",
|
||||
version: "0.30.8",
|
||||
// Pods stay unready until they are initialised and unsealed by hand.
|
||||
skipAwait: true,
|
||||
values: {
|
||||
global: {
|
||||
tlsDisable: false,
|
||||
},
|
||||
injector: {
|
||||
enabled: false,
|
||||
},
|
||||
server: {
|
||||
podManagementPolicy: "Parallel",
|
||||
resources: {
|
||||
requests: { cpu: "100m", memory: "256Mi" },
|
||||
limits: { memory: "512Mi" },
|
||||
},
|
||||
volumes: [
|
||||
{ name: "server-tls", secret: { secretName: "openbao-server-tls" } },
|
||||
],
|
||||
volumeMounts: [
|
||||
{
|
||||
name: "server-tls",
|
||||
mountPath: "/openbao/userconfig/openbao-server-tls",
|
||||
readOnly: true,
|
||||
},
|
||||
],
|
||||
extraEnvironmentVars: {
|
||||
BAO_CACERT: "/openbao/userconfig/openbao-server-tls/ca.crt",
|
||||
},
|
||||
service: {
|
||||
active: {
|
||||
annotations: {
|
||||
"traefik.ingress.kubernetes.io/service.serverstransport":
|
||||
"openbao-openbao-servers-transport@kubernetescrd",
|
||||
},
|
||||
},
|
||||
},
|
||||
ingress: {
|
||||
enabled: true,
|
||||
ingressClassName: "traefik",
|
||||
annotations: { "cert-manager.io/cluster-issuer": "letsencrypt-prod" },
|
||||
hosts: [{ host: openbaoHost, paths: ["/"] }],
|
||||
tls: [{ secretName: "openbao-ingress-tls", hosts: [openbaoHost] }],
|
||||
},
|
||||
networkPolicy: {
|
||||
enabled: true,
|
||||
ingress: [
|
||||
{
|
||||
from: [
|
||||
{
|
||||
namespaceSelector: {
|
||||
matchLabels: {
|
||||
"kubernetes.io/metadata.name": "kube-system",
|
||||
},
|
||||
},
|
||||
podSelector: {
|
||||
matchLabels: { "app.kubernetes.io/name": "traefik" },
|
||||
},
|
||||
},
|
||||
],
|
||||
ports: [{ port: 8200, protocol: "TCP" }],
|
||||
},
|
||||
{
|
||||
from: [
|
||||
{
|
||||
podSelector: {
|
||||
matchLabels: {
|
||||
"app.kubernetes.io/name": "openbao",
|
||||
"app.kubernetes.io/instance": "openbao",
|
||||
component: "server",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
ports: [
|
||||
{ port: 8200, protocol: "TCP" },
|
||||
{ port: 8201, protocol: "TCP" },
|
||||
],
|
||||
},
|
||||
{
|
||||
from: [
|
||||
{
|
||||
podSelector: {
|
||||
matchLabels: {
|
||||
"app.kubernetes.io/name": "openbao",
|
||||
"app.kubernetes.io/instance": "openbao",
|
||||
"app.kubernetes.io/component": "snapshot-agent",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
ports: [{ port: 8200, protocol: "TCP" }],
|
||||
},
|
||||
],
|
||||
},
|
||||
ha: {
|
||||
enabled: true,
|
||||
replicas: 3,
|
||||
apiAddr: "https://$(BAO_K8S_POD_NAME).openbao-internal:8200",
|
||||
raft: {
|
||||
enabled: true,
|
||||
setNodeId: true,
|
||||
config: `ui = true
|
||||
|
||||
listener "tcp" {
|
||||
address = "[::]:8200"
|
||||
cluster_address = "[::]:8201"
|
||||
tls_cert_file = "/openbao/userconfig/openbao-server-tls/tls.crt"
|
||||
tls_key_file = "/openbao/userconfig/openbao-server-tls/tls.key"
|
||||
tls_auto_reload = true
|
||||
}
|
||||
|
||||
storage "raft" {
|
||||
path = "/openbao/data"
|
||||
|
||||
retry_join {
|
||||
leader_api_addr = "https://openbao-0.openbao-internal:8200"
|
||||
leader_ca_cert_file = "/openbao/userconfig/openbao-server-tls/ca.crt"
|
||||
}
|
||||
retry_join {
|
||||
leader_api_addr = "https://openbao-1.openbao-internal:8200"
|
||||
leader_ca_cert_file = "/openbao/userconfig/openbao-server-tls/ca.crt"
|
||||
}
|
||||
retry_join {
|
||||
leader_api_addr = "https://openbao-2.openbao-internal:8200"
|
||||
leader_ca_cert_file = "/openbao/userconfig/openbao-server-tls/ca.crt"
|
||||
}
|
||||
}
|
||||
|
||||
service_registration "kubernetes" {}
|
||||
|
||||
audit "file" "stdout" {
|
||||
options {
|
||||
file_path = "stdout"
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
},
|
||||
dataStorage: {
|
||||
enabled: true,
|
||||
storageClass: "local-path",
|
||||
size: "2Gi",
|
||||
},
|
||||
},
|
||||
// Hourly Raft snapshots to RustFS. The job logs in to OpenBao with
|
||||
// Kubernetes auth, set up by hand in docs/runbooks/openbao.md.
|
||||
snapshotAgent: {
|
||||
enabled: true,
|
||||
schedule: "0 * * * *",
|
||||
s3CredentialsSecret: "openbao-snapshot-s3",
|
||||
config: {
|
||||
s3Host: snapshotS3Host,
|
||||
// s3cmd's --host-bucket. Using the host itself keeps requests
|
||||
// path-style, so DNS doesn't need a record per bucket.
|
||||
s3Bucket: snapshotS3Host,
|
||||
s3Uri: `s3://${snapshotBucket}`,
|
||||
// Empty turns off the agent's own pruning, which would need delete
|
||||
// access. RustFS lifecycle rules handle retention instead.
|
||||
s3ExpireDays: "",
|
||||
// RustFS rejects s3cmd's default signing region, "US".
|
||||
s3cmdExtraFlag: "-v --region=us-east-1",
|
||||
baoAuthPath: "kubernetes",
|
||||
baoRole: "openbao-snapshot",
|
||||
},
|
||||
extraEnvironmentVars: {
|
||||
BAO_CACERT: "/openbao/tls/ca.crt",
|
||||
},
|
||||
extraVolumes: [
|
||||
{
|
||||
name: "openbao-ca",
|
||||
secret: {
|
||||
secretName: "openbao-server-tls",
|
||||
items: [{ key: "ca.crt", path: "ca.crt" }],
|
||||
},
|
||||
},
|
||||
],
|
||||
extraVolumeMounts: [
|
||||
{ name: "openbao-ca", mountPath: "/openbao/tls", readOnly: true },
|
||||
],
|
||||
resources: {
|
||||
requests: { cpu: "50m", memory: "64Mi" },
|
||||
limits: { memory: "256Mi" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
opts({
|
||||
dependsOn: [serversTransport, snapshotS3Credentials],
|
||||
protect: true,
|
||||
}),
|
||||
);
|
||||
Generated
+1499
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "openbao",
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.19.4",
|
||||
"typescript": "^6.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pulumi/kubernetes": "^4.31.1",
|
||||
"@pulumi/pulumi": "^3.278.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"outDir": "bin",
|
||||
"target": "es2024",
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"pretty": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.ts"
|
||||
]
|
||||
}
|
||||
@@ -24,9 +24,11 @@ proxmox-infra → k8s-bootstrap → k8s-infra
|
||||
## Shared conventions
|
||||
|
||||
- **Secrets**: read via `config.requireSecret()`, never via environment variables or hardcoded values.
|
||||
- **`Pulumi.dev.yaml`**: gitignored (contains the encryption salt). Never delete it or secrets become unrecoverable. CI restores it from a base64 Gitea secret `<STACK>_PULUMI_DEV_YAML`; after changing local config, remind me to update that secret.
|
||||
- **`Pulumi.dev.yaml`**: in `.pulumi-config/<stack-dir>/` (set by `stackConfigDir`). `.pulumi-config/` is a separate private repo, gitignored here and not a submodule, so this repo's `git status` doesn't show its changes; use `git -C .pulumi-config status`. These files contain the encryption salt: never delete them or secrets become unrecoverable, and never commit them to this repo. Any `0N-*/Pulumi.dev.yaml` is an unused old copy; don't edit it.
|
||||
- **Config changes**: CI checks out the config repo's `main`, so a local preview can use config that CI doesn't have yet. After config changes, remind me to commit and push them there, before opening or updating a PR that needs them. That push doesn't start a deploy. The commit rule below applies to that repo too. Setup steps are in `.pulumi-config/README.md`.
|
||||
- **Private repos**: don't write a private repo's name, owner/name path or URL in READMEs or other docs. Say "the private config repo", or use a placeholder. Naming it in workflows is fine, and so is the local folder name `.pulumi-config/`.
|
||||
- **Environment**: `PULUMI_BACKEND_URL` (self-hosted Postgres backend) and `PULUMI_CONFIG_PASSPHRASE` must be set.
|
||||
- **CI**: PRs run `pulumi preview`. `03`–`05` deploy on push to `main`; `01`/`02` deploy only via manual dispatch.
|
||||
- **CI**: PRs run `pulumi preview`. `01` and `03`–`05` deploy on push to `main`; `02` deploys only via manual dispatch. Automatic `01` deploys skip `pulumi refresh`, so run its workflow manually after changing VMs in the Proxmox GUI.
|
||||
|
||||
## Git conventions
|
||||
|
||||
@@ -34,7 +36,7 @@ Branch names, commit messages and PR titles follow @CONVENTIONS.md. The commit-m
|
||||
|
||||
Only commit when I explicitly say "commit" for that change. A yes to a question that also mentioned committing is not enough; when unsure, ask.
|
||||
|
||||
The remote is a self-hosted Gitea, so `gh` doesn't work. For PRs and their CI status use `.claude/scripts/gitea.sh` (acts as `claude-bot`), e.g. `.claude/scripts/gitea.sh GET '/repos/kasun/homelab-infrastructure-as-code/pulls?state=open'`. Use it for PRs only, and ask before opening or merging one.
|
||||
The remote is a self-hosted Gitea, so `gh` doesn't work. For PRs and their CI status use `.claude/scripts/gitea.sh` (acts as `claude-bot`), e.g. `.claude/scripts/gitea.sh GET '/repos/kasun/homelab-infrastructure-as-code/pulls?state=open'`.
|
||||
|
||||
## Live infrastructure
|
||||
|
||||
|
||||
+1
-1
@@ -60,4 +60,4 @@ This repo uses Gitea Actions (see root `CLAUDE.md`); Gitea's merge commit reuses
|
||||
- `Enhancement: Refactor k8s-bootstrap for clearer deployment order`
|
||||
- `Chore: Upgrade Pulumi packages across all stacks`
|
||||
|
||||
Since `01`/`02` deploys are manual (`workflow_dispatch`) and `03`–`05` deploy on merge to `main`, a clear PR title also doubles as a quick changelog of what just went live.
|
||||
Since `02` deploys are manual (`workflow_dispatch`) and `01` and `03`–`05` deploy on merge to `main`, a clear PR title also doubles as a quick changelog of what just went live.
|
||||
@@ -95,6 +95,8 @@ export PULUMI_BACKEND_URL=postgresql://<user>:<pass>@<host>/<db>
|
||||
export PULUMI_CONFIG_PASSPHRASE=<your-passphrase>
|
||||
```
|
||||
|
||||
Clone your private config repo into `.pulumi-config/` (see [Stack config](#stack-config)). For an existing setup, use the config from that repo and skip the `stack init` and `config set` commands below.
|
||||
|
||||
Then for each stack, in order:
|
||||
|
||||
```bash
|
||||
@@ -107,7 +109,7 @@ pulumi up --yes
|
||||
|
||||
Stack-specific notes:
|
||||
|
||||
1. **proxmox-infra** — set Proxmox API tokens, pfSense credentials, VM credentials/SSH public key, and a static IP per node.
|
||||
1. **proxmox-infra** — set Proxmox API tokens, pfSense credentials, VM credentials/SSH public key, and a static IP per node. The CI runner VM needs `runnerIp` and `runnerAnsibleSshPublicKey`, see [the runbook](docs/runbooks/ci-runner-vm.md).
|
||||
2. **k8s-bootstrap** — set `k3sToken` (e.g. `openssl rand -hex 32`) and `controlPlaneVipAddress` (secret; a free IP outside the DHCP pool, fronted by pfSense + HAProxy, see [the runbook](docs/runbooks/pfsense-control-plane-vip.md)). Node IPs, Proxmox credentials and the SSH key come automatically from `proxmox-infra`.
|
||||
3. **k8s-infra** — before deploying, create an NFS dataset/share on TrueNAS (POSIX ACLs, `root`/`root` maproot, restricted to your k3s nodes). Set `truenasHost`, `truenasNfsPath`, `cloudflareApiToken`, `letsencryptEmail`, `kubeVipAddress` (all secrets) and `kubeVipInterface`.
|
||||
4. **k8s-apps** — set `domain`, the base domain used for ingress hostnames.
|
||||
@@ -120,36 +122,41 @@ One workflow per stack, `.gitea/workflows/0N-deploy-<stack>.yaml`, scoped to cha
|
||||
| Trigger | Stacks | Action |
|
||||
| --- | --- | --- |
|
||||
| PR → `main` | all | `pulumi preview` (read-only) |
|
||||
| Push to `main` | 01 | `pulumi up` (no refresh) |
|
||||
| Push to `main` | 03–05 | `pulumi refresh` + `pulumi up` |
|
||||
| Manual dispatch | all | `pulumi refresh` + `pulumi up` |
|
||||
|
||||
Stacks 01/02 (VM provisioning, cluster bootstrap) deploy **only** via manual dispatch — they're riskier to automate.
|
||||
Stack 02 (cluster bootstrap) deploys **only** via manual dispatch, because re-running it restarts the bootstrap sequence. Stack 01 (VM provisioning) skips the refresh on automatic deploys so a VM missing from Proxmox can't be recreated blank. After changing VMs in the Proxmox GUI, run its workflow manually to sync state.
|
||||
|
||||
To rebuild the whole cluster from new VMs, follow [the rebuild runbook](docs/runbooks/full-cluster-rebuild.md). A normal `pulumi up` won't do it.
|
||||
|
||||
### Required secrets
|
||||
|
||||
| Secret | Used by |
|
||||
| --- | --- |
|
||||
| `PULUMI_BACKEND_URL`, `PULUMI_CONFIG_PASSPHRASE` | all workflows |
|
||||
| `PROXMOX_INFRA_PULUMI_DEV_YAML` | 01-deploy-proxmox-infra |
|
||||
| `K8S_BOOTSTRAP_PULUMI_DEV_YAML` | 02-deploy-k8s-bootstrap |
|
||||
| `K8S_INFRA_PULUMI_DEV_YAML` | 03-deploy-k8s-infra |
|
||||
| `K8S_APPS_PULUMI_DEV_YAML` | 04-deploy-k8s-apps |
|
||||
| `MONITORING_PULUMI_DEV_YAML` | 05-deploy-monitoring |
|
||||
| `PULUMI_CONFIG_REPO_TOKEN` (`ci-bot` token with read-only access to the config repo) | all workflows |
|
||||
|
||||
Each `<STACK>_PULUMI_DEV_YAML` secret is a base64-encoded copy of that stack's gitignored `Pulumi.dev.yaml`. After changing local config, re-encode and update the secret:
|
||||
### Stack config
|
||||
|
||||
```bash
|
||||
base64 -w 0 0N-<stack>/Pulumi.dev.yaml
|
||||
```
|
||||
Each stack's encrypted `Pulumi.dev.yaml` is in a private repo, cloned into the gitignored `.pulumi-config/` folder. CI checks out its `main` branch. After changing config, commit and push it there. That push doesn't start a deploy. See that repo's README for setup and usage.
|
||||
|
||||
CI reads the config repo as a separate user, so its token can't access your other private repos:
|
||||
|
||||
1. As a Gitea admin, create a regular (non-admin) user named `ci-bot`.
|
||||
2. In the config repo's settings, add `ci-bot` as a collaborator with **Read** access. Don't add it to any other private repo.
|
||||
3. Sign in as `ci-bot` and create an access token with only the `read:repository` permission.
|
||||
4. In this repo's Actions secrets, add the token as `PULUMI_CONFIG_REPO_TOKEN`.
|
||||
|
||||
## Using this as a template
|
||||
|
||||
1. Fork or copy the repo
|
||||
2. Update Proxmox node names/datastores and the `nodeConfigs` array in `01-proxmox-infra/index.ts` for your VM topology
|
||||
3. Set your own config/secrets per stack with `pulumi config set [--secret]` — see each stack's `CLAUDE.md` for the full list of required keys
|
||||
4. Point the CI/CD workflows at your own Gitea/GitOps instance and update the secrets above
|
||||
4. Create your own private config repo and a `ci-bot` user that can read it (see [Stack config](#stack-config)), then set the repo as `repository` in each workflow's `Checkout Stack Config` steps
|
||||
5. Point the CI/CD workflows at your own Gitea/GitOps instance and update the secrets above
|
||||
|
||||
## Roadmap
|
||||
|
||||
- Migrate secrets management to [OpenBao](https://openbao.org/) — replace `PULUMI_CONFIG_PASSPHRASE` and manual `Pulumi.dev.yaml` encoding with a self-hosted vault
|
||||
- Migrate secrets management to [OpenBao](https://openbao.org/) — replace `PULUMI_CONFIG_PASSPHRASE` and the encrypted config repo with a self-hosted vault
|
||||
- Add a third bare-metal Proxmox node for true 3-node HA parity
|
||||
@@ -0,0 +1,28 @@
|
||||
# 0002: CI runner on a dedicated VM with Docker job containers
|
||||
|
||||
Status: accepted (December 2026)
|
||||
|
||||
## Context
|
||||
|
||||
The Gitea runner ran as a container on the shared Docker host, next to Gitea and Postgres, with the Docker socket mounted. A job that reached the socket had root on that host. Jobs in this repo also hold the most powerful credentials in the homelab: the Proxmox API tokens, pfSense access and the Pulumi passphrase.
|
||||
|
||||
## Decision
|
||||
|
||||
The runner runs on its own VM (`runner`, defined in `01-proxmox-infra`), outside the k3s cluster:
|
||||
|
||||
- act_runner runs as a systemd service, installed and configured by Ansible.
|
||||
- Each job runs in a fresh Docker container that is removed afterwards. Job containers don't get the Docker socket (`container.docker_host: "-"`), and `capacity: 1`.
|
||||
- The registration token is entered by hand at registration time and isn't stored anywhere.
|
||||
- SSH is key-only. Ansible uses a key that exists only for this VM.
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
- **Unprivileged LXC with Docker:** Docker in an LXC needs `nesting` and `keyctl`, which widens the shared-kernel attack surface towards the Proxmox host. Proxmox itself recommends running Docker in a VM. For the host holding the strongest credentials, a separate kernel is worth the extra RAM.
|
||||
- **Host mode (no Docker):** jobs would leave files and tools behind for the next job and could read the runner's own credential (`.runner`). The security gain is small, because deploy secrets are in the job environment in either mode.
|
||||
- **Runner pods in k3s:** `01` and `02` create and repair the cluster, so the runner can't depend on it. Gitea also has no mature per-job pod autoscaler.
|
||||
|
||||
## Consequences
|
||||
|
||||
- When everything is down, recovery doesn't go through CI. You run `pulumi up` from the workstation instead.
|
||||
- Deploy secrets are still readable by any job. The real protection is scoping the credentials and filtering the runner's outbound traffic, both tracked separately.
|
||||
- Access to the runner VM is as sensitive as the CI credentials themselves. That includes the Ansible node, through its dedicated key.
|
||||
@@ -0,0 +1,27 @@
|
||||
# CI runner VM: first-time setup
|
||||
|
||||
The `runner` VM is defined in `01-proxmox-infra`. For the design, see [decision 0002](../decisions/0002-ci-runner-on-a-vm.md). Do this once, before the first deploy that creates the VM.
|
||||
|
||||
1. On the Ansible node, create a key that is used only for the runner VM:
|
||||
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -f ~/.ssh/runner_vm -C ansible-runner-vm
|
||||
```
|
||||
|
||||
2. Set the config from the repo root, then commit and push it in the private config repo:
|
||||
|
||||
```bash
|
||||
cd 01-proxmox-infra
|
||||
pulumi config set --secret runnerIp <free IP outside the DHCP pool>
|
||||
pulumi config set --secret runnerAnsibleSshPublicKey "$(cat runner_vm.pub)" # copy of ~/.ssh/runner_vm.pub from the Ansible node
|
||||
```
|
||||
|
||||
3. Deploy `01-proxmox-infra`. Pulumi creates the pfSense DHCP reservation and the VM.
|
||||
|
||||
4. Check that the Ansible node can log in: `ssh -i ~/.ssh/runner_vm ubuntu@<runnerIp>`.
|
||||
|
||||
5. Install and register act_runner with the runner playbook in the Ansible repo. The playbook asks for a registration token: create one in Gitea, then reset it right after registering.
|
||||
|
||||
## Revoke access
|
||||
|
||||
To lock the Ansible node out of the runner VM, remove its key from `~ubuntu/.ssh/authorized_keys` on the VM. Changing the config alone isn't enough, because cloud-init only applies keys on the first boot.
|
||||
@@ -0,0 +1,113 @@
|
||||
# Full cluster rebuild
|
||||
|
||||
Use this to rebuild the k3s cluster from new VMs. **It destroys everything stored in the cluster.** To change a running cluster, don't use this runbook.
|
||||
|
||||
> This procedure has not been run end to end. Stop at any checkpoint that doesn't match, and don't work around it with `--force` or by clicking through a preview.
|
||||
|
||||
## Why a normal `pulumi up` isn't enough
|
||||
|
||||
- **`02-k8s-bootstrap` commands run once.** They are recorded as done in state, so after new VMs appear, `pulumi up` would report them unchanged and install nothing.
|
||||
- **`03`–`06` state describes the old cluster.** The fixed `clusterIdentifier` tells Pulumi it is still the same cluster, so it would try to update resources that no longer exist.
|
||||
|
||||
## Before you start
|
||||
|
||||
1. **Save your data.** Longhorn has no backup target configured, so its volumes are lost with the VMs. That includes `heimdall-config` and the Prometheus metrics. Grafana's database is external and is not affected. OpenBao's data is lost too, so [save a snapshot](openbao.md#save-a-snapshot) outside the cluster and keep its unseal key and admin password.
|
||||
2. **Stop automatic deploys.** In Gitea's **Actions** tab, disable the `01`, `03`, `04`, `05` and `06` workflows, and don't merge anything until the last step.
|
||||
3. **Back up all state.** Run this from the repo root:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/state-backups/rebuild
|
||||
for S in 01-proxmox-infra 02-k8s-bootstrap 03-k8s-infra 04-k8s-apps 05-monitoring 06-openbao; do
|
||||
pulumi stack export --stack dev --cwd "$S" --file ~/state-backups/rebuild/$S.json
|
||||
done
|
||||
```
|
||||
|
||||
These backups describe the old cluster. Once its VMs are deleted, don't restore them.
|
||||
|
||||
4. **Check what the rebuild depends on:**
|
||||
- pfSense is running, with the [control-plane VIP and HAProxy](pfsense-control-plane-vip.md) configured. They are not managed by Pulumi. pfSense is VM 200 on the Optiplex, so if you reinstall that host, restore pfSense from a config backup first.
|
||||
- The [TrueNAS NFS share](truenas-nfs.md) exists.
|
||||
|
||||
5. **If you reinstalled any Proxmox host:**
|
||||
- Replace its CA in `02-k8s-bootstrap/certs/` (`pve1` is B550, `pve2` is Optiplex, `pve3` is Esprimo). Get it with `cat /etc/pve/pve-root-ca.pem`, and never copy anything from `/etc/pve/priv/`.
|
||||
- Check that the host's certificate lists its current IP. `/etc/hosts` must have that IP before the certificate is generated.
|
||||
- Recreate the API token, then update the token and endpoint in `01-proxmox-infra` config. Commit and push the change in `.pulumi-config` (see [Stack config](../../README.md#stack-config)), because CI uses the pushed version.
|
||||
- The VM template on that host is gone too, so expect step 1 to recreate it.
|
||||
|
||||
## 1. Recreate the VMs (`01-proxmox-infra`)
|
||||
|
||||
1. In Proxmox, delete the six `k3s-*` VMs. Keep the `k3s-ubuntu-noble-template` VMs.
|
||||
2. In pfSense, delete the six `k3s-*` DHCP static mappings. New VMs get new MAC addresses.
|
||||
3. Sync state and preview:
|
||||
|
||||
```bash
|
||||
pulumi refresh --stack dev --cwd 01-proxmox-infra
|
||||
pulumi preview --stack dev --cwd 01-proxmox-infra
|
||||
```
|
||||
|
||||
**Checkpoint:** the preview creates six VMs and six DHCP mappings, plus a template for any reinstalled host. It must show no replace or delete. These resources are protected, so if one is still in state after the refresh, find its URN with `pulumi stack --show-urns` and remove only that entry:
|
||||
|
||||
```bash
|
||||
pulumi state delete --force --stack dev --cwd 01-proxmox-infra '<urn>'
|
||||
```
|
||||
|
||||
4. Deploy. The VMs stay stopped until step 3.
|
||||
|
||||
```bash
|
||||
pulumi up --stack dev --cwd 01-proxmox-infra
|
||||
```
|
||||
|
||||
## 2. Clear the state of `02`–`06`
|
||||
|
||||
Only do this after the old VMs are gone. It removes Pulumi's records and doesn't touch real resources or `Pulumi.dev.yaml`. `--force` is needed because `05-monitoring` and `06-openbao` protect their namespaces and Helm releases, so check that the old cluster is really gone before running it.
|
||||
|
||||
```bash
|
||||
for S in 06-openbao 05-monitoring 04-k8s-apps 03-k8s-infra 02-k8s-bootstrap; do
|
||||
pulumi state delete --all --force --yes --stack dev --cwd "$S"
|
||||
done
|
||||
```
|
||||
|
||||
Previews of `03`–`06` fail until step 3 is done, because `02` has no `kubeconfig` output yet.
|
||||
|
||||
## 3. Bootstrap k3s (`02-k8s-bootstrap`)
|
||||
|
||||
```bash
|
||||
pulumi preview --stack dev --cwd 02-k8s-bootstrap
|
||||
pulumi up --stack dev --cwd 02-k8s-bootstrap
|
||||
```
|
||||
|
||||
**Checkpoint:** the preview only creates resources. The deploy starts the VMs, installs k3s on master-1, waits for the VIP, then joins the other nodes through it. If a step fails, fix the cause and run `pulumi up` again.
|
||||
|
||||
Check the new cluster with its own kubeconfig:
|
||||
|
||||
```bash
|
||||
(umask 077; pulumi stack output kubeconfig --show-secrets --stack dev --cwd 02-k8s-bootstrap > ~/k3s-rebuilt.yaml)
|
||||
KUBECONFIG=~/k3s-rebuilt.yaml kubectl get nodes
|
||||
```
|
||||
|
||||
Secret encryption is configured with `secretbox`.
|
||||
|
||||
**Checkpoint:** all six nodes are `Ready`. Then replace your normal kubeconfig with this file, because the old one no longer works.
|
||||
|
||||
## 4. Deploy `03`–`06`
|
||||
|
||||
Deploy these through Gitea, because the runners have the `helm` CLI that `03` needs. Re-enable each workflow as you reach it, and wait for each run to finish.
|
||||
|
||||
1. Run the **Deploy k8s Infra** workflow manually.
|
||||
2. Run the **Deploy k8s Apps** workflow manually.
|
||||
3. Run the **Deploy Monitoring** workflow manually.
|
||||
4. Run the **Deploy Openbao** workflow manually, then [restore the OpenBao snapshot](openbao.md#restore-into-a-new-openbao).
|
||||
|
||||
## 5. Verify
|
||||
|
||||
```bash
|
||||
kubectl get nodes
|
||||
kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded
|
||||
kubectl get pvc -A
|
||||
kubectl get nodes.longhorn.io -n longhorn-system
|
||||
kubectl get certificates -A
|
||||
```
|
||||
|
||||
**Checkpoint:** nodes are `Ready`, no pods are unhealthy, PVCs are `Bound`, and certificates become `Ready`. New certificates come from Let's Encrypt, which rate-limits repeated requests for the same hostnames, so avoid repeated rebuilds in a short period.
|
||||
|
||||
Run `pulumi preview --stack dev --cwd <stack>` for all six stacks. None should show changes. Re-enable the `01` workflow, restore any data you saved, and delete `~/k3s-rebuilt.yaml` and `~/state-backups/rebuild`.
|
||||
@@ -0,0 +1,188 @@
|
||||
# Turn on k3s Secret encryption
|
||||
|
||||
Use this once to encrypt the Secrets in an existing cluster with `secretbox`. Don't use it for fresh installs, because `02-k8s-bootstrap` turns on encryption during installation. Don't use it to rotate keys later either.
|
||||
|
||||
> Steps 1–5 worked on the live cluster on 2026-12-01 with `v1.36.2+k3s1`. They're based on the k3s guide for existing clusters and the source code for that version. The guide doesn't cover starting with `secretbox`. **If a check doesn't match, stop.** Don't repeat `rotate-keys`, use `--force` or delete k3s files.
|
||||
|
||||
Don't deploy `02`, run the k3s installer or recreate VMs for this change.
|
||||
|
||||
## Before you start
|
||||
|
||||
1. Check that you have current VM backups of all 3 masters. They contain unencrypted Secrets, so restrict access to them.
|
||||
2. Pause deployments, and don't merge anything until you finish.
|
||||
3. Check that you can reach each master directly over SSH, not only through the control-plane VIP.
|
||||
4. From your workstation, check the nodes:
|
||||
|
||||
```bash
|
||||
kubectl get nodes
|
||||
```
|
||||
|
||||
**Checkpoint:** all six nodes are `Ready`, and the masters run `v1.36.2+k3s1`.
|
||||
|
||||
5. On **each master**, check etcd and look for existing settings. The last two commands only print file or setting names:
|
||||
|
||||
```bash
|
||||
sudo k3s kubectl get --raw=/readyz/etcd; echo
|
||||
sudo grep -rls 'secrets-encryption' /etc/rancher/k3s/
|
||||
{ systemctl cat k3s; sudo cat /etc/default/k3s /etc/sysconfig/k3s /etc/systemd/system/k3s.service.env 2>/dev/null; } | grep -oE -- '--config|--secrets-encryption|K3S_CONFIG_FILE'
|
||||
```
|
||||
|
||||
**Checkpoint:** each master prints only `ok`. Any other output means etcd has a problem, encryption settings already exist or k3s uses a custom config path.
|
||||
|
||||
## Restarting the masters
|
||||
|
||||
Steps 2 and 4 use this procedure. Restart `k3s-master-1` first, then `k3s-master-2`, then `k3s-master-3`. On each one, run:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart k3s
|
||||
sudo k3s kubectl get --raw=/readyz/etcd; echo
|
||||
sudo k3s kubectl get nodes
|
||||
```
|
||||
|
||||
**Checkpoint:** etcd returns `ok` and all nodes are `Ready` before you restart the next master. The API can take a minute to respond, so rerun the two checks if needed. Finish all 3 restarts without long breaks.
|
||||
|
||||
## 1. Enable encryption and add the settings
|
||||
|
||||
1. On `k3s-master-1`, check the status:
|
||||
|
||||
```bash
|
||||
sudo k3s secrets-encrypt status
|
||||
```
|
||||
|
||||
**Checkpoint:** it shows `Disabled, no configuration file found`.
|
||||
|
||||
2. On `k3s-master-1` **only**, run this. It doesn't create a key or encrypt anything yet:
|
||||
|
||||
```bash
|
||||
sudo k3s secrets-encrypt enable
|
||||
```
|
||||
|
||||
3. On **all 3 masters**, add the settings in a separate file, so the existing config stays unchanged:
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /etc/rancher/k3s/config.yaml.d
|
||||
sudo install -m 600 /dev/stdin /etc/rancher/k3s/config.yaml.d/90-secrets-encryption.yaml <<'EOF'
|
||||
secrets-encryption: true
|
||||
secrets-encryption-provider: secretbox
|
||||
EOF
|
||||
```
|
||||
|
||||
## 2. Restart and check the settings
|
||||
|
||||
1. [Restart all 3 masters](#restarting-the-masters).
|
||||
2. On `k3s-master-1`, check the status:
|
||||
|
||||
```bash
|
||||
sudo k3s secrets-encrypt status
|
||||
```
|
||||
|
||||
**Checkpoint:** it shows `Disabled`, stage `start` and `All hashes match`.
|
||||
|
||||
3. From your workstation, check which encryption settings each master uses:
|
||||
|
||||
```bash
|
||||
kubectl get nodes -l node-role.kubernetes.io/control-plane -o json | jq -r '.items[] | .metadata.name + ": " + (.metadata.annotations["k3s.io/node-args"] | fromjson | join(" ") | [scan("--secrets-encryption[^ ]*(?: (?!--)[^ ]+)?")] | join(" "))'
|
||||
```
|
||||
|
||||
**Checkpoint:** all 3 masters show `--secrets-encryption` set to `true` and `--secrets-encryption-provider` set to `secretbox`. **Don't continue without both**, because the next step uses the provider setting to choose the key type.
|
||||
|
||||
## 3. Encrypt the Secrets
|
||||
|
||||
**Don't interrupt this step or restart any masters until it finishes.** A crash could stop the cluster from starting ([k3s issue 13763](https://github.com/k3s-io/k3s/issues/13763)), and we haven't confirmed a fix.
|
||||
|
||||
1. On `k3s-master-1`, run this **once**. It creates the key and re-encrypts the existing Secrets:
|
||||
|
||||
```bash
|
||||
sudo k3s secrets-encrypt rotate-keys
|
||||
```
|
||||
|
||||
2. Check the status until the stage is `reencrypt_finished`:
|
||||
|
||||
```bash
|
||||
sudo k3s secrets-encrypt status
|
||||
```
|
||||
|
||||
If there's an error or no progress, check the logs with `sudo journalctl -u k3s --since '15 min ago'`, then stop. Don't run `rotate-keys` again.
|
||||
|
||||
## 4. Restart and check the status
|
||||
|
||||
1. [Restart all 3 masters](#restarting-the-masters) again.
|
||||
2. On `k3s-master-1`, check the status:
|
||||
|
||||
```bash
|
||||
sudo k3s secrets-encrypt status
|
||||
```
|
||||
|
||||
**Checkpoint:** it shows `Enabled`, `reencrypt_finished`, `All hashes match` and an active `XSalsa20-POLY1305` key.
|
||||
|
||||
## 5. Verify
|
||||
|
||||
1. On **each master**, check that its API can read all Secrets. This doesn't print them:
|
||||
|
||||
```bash
|
||||
sudo k3s kubectl get secrets -A -o name >/dev/null && echo ok
|
||||
```
|
||||
|
||||
**Checkpoint:** each master prints `ok`.
|
||||
|
||||
2. From your workstation, create a test Secret with a fake value:
|
||||
|
||||
```bash
|
||||
kubectl -n default create secret generic encryption-test --from-literal=value=not-a-real-secret
|
||||
```
|
||||
|
||||
3. On `k3s-master-1`, check the test Secret and an existing Secret in etcd. This needs `etcdctl`. If it's missing, install it with `sudo apt install etcd-client`. The command only prints the first 21 characters of each stored value:
|
||||
|
||||
```bash
|
||||
for key in default/encryption-test heimdall/heimdall-tls; do
|
||||
sudo env ETCDCTL_API=3 etcdctl \
|
||||
--endpoints=https://127.0.0.1:2379 \
|
||||
--cacert=/var/lib/rancher/k3s/server/tls/etcd/server-ca.crt \
|
||||
--cert=/var/lib/rancher/k3s/server/tls/etcd/client.crt \
|
||||
--key=/var/lib/rancher/k3s/server/tls/etcd/client.key \
|
||||
get "/registry/secrets/$key" --print-value-only | head -c 21
|
||||
echo
|
||||
done
|
||||
```
|
||||
|
||||
**Checkpoint:** both lines are `k8s:enc:secretbox:v1:`.
|
||||
|
||||
4. From your workstation, delete the test Secret, then check that your apps still work:
|
||||
|
||||
```bash
|
||||
kubectl -n default delete secret encryption-test
|
||||
kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded
|
||||
```
|
||||
|
||||
**Checkpoint:** no pods are listed, and the apps work normally.
|
||||
|
||||
## 6. Clean up
|
||||
|
||||
1. Make new VM backups of all 3 masters. Once they finish, delete the older ones, because their Secrets aren't encrypted. The new backups contain both the encrypted data and its key, so keep access restricted.
|
||||
2. On **each master**, take a new etcd snapshot, then list the snapshots:
|
||||
|
||||
```bash
|
||||
sudo k3s etcd-snapshot save --name after-secrets-encryption
|
||||
sudo k3s etcd-snapshot ls
|
||||
```
|
||||
|
||||
3. On the master that holds each snapshot, delete any taken before step 4 finished. Check the name and date first, and delete any copies stored elsewhere too:
|
||||
|
||||
```bash
|
||||
sudo k3s etcd-snapshot delete <snapshot-name>
|
||||
```
|
||||
|
||||
Keep the remaining snapshots separate from the k3s server token. Someone with both can decrypt the Secrets.
|
||||
|
||||
4. Merge the `02` change, then resume deployments. Don't deploy `02`.
|
||||
|
||||
## If something goes wrong
|
||||
|
||||
Stop and save the status output and logs. **Don't restore just one master from a VM backup.** Its old etcd data and encryption settings may not match the other masters. Plan the recovery for all 3 masters together first. Restoring them loses any Kubernetes changes made after the backups and can leave them out of sync with the workers and Longhorn volumes.
|
||||
|
||||
## References
|
||||
|
||||
- [k3s: Turn on Secrets encryption](https://docs.k3s.io/cli/secrets-encrypt)
|
||||
- [k3s: Encryption types](https://docs.k3s.io/security/secrets-encryption)
|
||||
- [k3s: Config files](https://docs.k3s.io/installation/configuration)
|
||||
- [k3s: Snapshots](https://docs.k3s.io/cli/etcd-snapshot)
|
||||
@@ -0,0 +1,473 @@
|
||||
# OpenBao
|
||||
|
||||
Use this to set up OpenBao after its first deploy, unseal it after restarts, and back it up or recover it. `06-openbao` runs three pods that copy their data to each other using Raft. Unsealing is manual, with one unseal key.
|
||||
|
||||
> The main commands were tested on local OpenBao 2.7.3 servers without Kubernetes or TLS, not on the cluster. **If a checkpoint doesn't match, stop.**
|
||||
|
||||
## Rules
|
||||
|
||||
- **Only run `init` once, during first setup or on a new, empty OpenBao before a restore.** After a restart, you only need to unseal.
|
||||
- **Keep the unseal key in Bitwarden, plus a copy outside Bitwarden** (on paper or an offline USB stick). If all pods restart and the key is lost, the data can't be recovered, even from snapshots.
|
||||
- Never put keys, tokens or passwords in Git, chats, tickets or commands. Enter them only when prompted, in a terminal that isn't being recorded.
|
||||
- **Don't delete the `data-openbao-*` PVCs**, except when [replacing a lost worker](#replace-a-lost-worker). Deleting one deletes that pod's data.
|
||||
|
||||
Run the commands in Bash on your workstation. Replace `<domain>` with your domain. In steps that use `$POD`, set it to the active pod first, and again whenever you open a new terminal or a pod restarts:
|
||||
|
||||
```bash
|
||||
POD=$(kubectl -n openbao get pod -l openbao-active=true -o name); echo "$POD"
|
||||
```
|
||||
|
||||
**Checkpoint:** it prints exactly one pod.
|
||||
|
||||
## First setup
|
||||
|
||||
### 1. Check the deployment
|
||||
|
||||
1. In pfSense's DNS Resolver, point `bao.<domain>` to Traefik's IP (`kubeVipAddress`), not the Kubernetes API address.
|
||||
2. Check the pods, volumes and certificates:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao get pods,pvc,certificates
|
||||
```
|
||||
|
||||
**Checkpoint:** all three pods are `Running` but show `0/1`, the PVCs are `Bound` and the certificates are `Ready`. The web UI doesn't work until OpenBao is unsealed.
|
||||
|
||||
### 2. Initialise
|
||||
|
||||
Run this **once, only on `openbao-0`**:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it openbao-0 -- bao operator init -key-shares=1 -key-threshold=1
|
||||
```
|
||||
|
||||
It shows the **unseal key** and **initial root token** only once. Save both in Bitwarden and make the second copy of the unseal key. Then clear the terminal and its scrollback. You'll delete the root token in step 7.
|
||||
|
||||
### 3. Unseal
|
||||
|
||||
1. Unseal `openbao-0`, and paste the key when prompted:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it openbao-0 -- bao operator unseal
|
||||
kubectl -n openbao exec openbao-0 -- bao status
|
||||
```
|
||||
|
||||
**Checkpoint:** after a few seconds, `bao status` shows `Sealed false` and `HA Mode active`.
|
||||
|
||||
2. Check that `openbao-1` has found `openbao-0`, then unseal it with the same key:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec openbao-1 -- bao status
|
||||
kubectl -n openbao exec -it openbao-1 -- bao operator unseal
|
||||
```
|
||||
|
||||
**Checkpoint:** `bao status` shows `Initialized true` before you unseal. Exit code 2 is normal because the pod is still sealed. If it shows `Initialized false`, don't run `init`. Check `kubectl -n openbao logs openbao-1` instead.
|
||||
|
||||
3. Do the same for `openbao-2`, then check all three:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao get pods -L openbao-active,openbao-sealed
|
||||
```
|
||||
|
||||
**Checkpoint:** all pods show `1/1` and `openbao-sealed=false`, and only one has `openbao-active=true`.
|
||||
|
||||
### 4. Create the admin login
|
||||
|
||||
1. Set [`$POD`](#rules), then log in with the root token when prompted:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print
|
||||
kubectl -n openbao exec "$POD" -- bao operator raft list-peers
|
||||
```
|
||||
|
||||
**Checkpoint:** there's one `leader` and two `follower`s. All three show `Voter true`, which can take a moment.
|
||||
|
||||
2. Create a policy with **full access**. Only use it for your admin login, never for apps:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -i "$POD" -- bao policy write admin - <<'EOF'
|
||||
path "*" {
|
||||
capabilities = ["create", "read", "update", "patch", "delete", "list", "scan", "sudo"]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
3. Turn on username and password logins:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao auth enable userpass
|
||||
```
|
||||
|
||||
4. Generate a strong password in Bitwarden and create the `admin` user. Run these lines one at a time, and paste the password after the first one:
|
||||
|
||||
```bash
|
||||
read -rsp 'Admin password: ' PW; echo
|
||||
printf %s "$PW" | kubectl -n openbao exec -i "$POD" -- bao write auth/userpass/users/admin password=- token_policies=admin token_ttl=1h token_max_ttl=8h
|
||||
unset PW
|
||||
```
|
||||
|
||||
5. Turn on a KV v2 secrets engine, which stores passwords and API keys:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao secrets enable -path=secret -version=2 kv
|
||||
```
|
||||
|
||||
### 5. Test the admin login
|
||||
|
||||
Open `https://bao.<domain>` in a private window. Choose **Username** as the login method and log in as `admin`. Then:
|
||||
|
||||
1. Create a fake secret in `secret/`, read it, then delete it.
|
||||
2. Create a test policy, then delete it.
|
||||
|
||||
**Checkpoint:** everything works, and the browser shows no certificate warning.
|
||||
|
||||
### 6. Save the first snapshot
|
||||
|
||||
Follow [Save a snapshot](#save-a-snapshot). This also checks that the admin login can make backups. Before storing real secrets, test the [restore steps](#restore-into-a-new-openbao) on a separate test cluster.
|
||||
|
||||
### 7. Revoke the root token
|
||||
|
||||
Only do this once steps 5 and 6 have worked. Check that Bitwarden has the admin password and that you have a copy outside it.
|
||||
|
||||
1. Set [`$POD`](#rules), then log in with the **root token**. Log in again even if you did so earlier, because the snapshot steps replaced the saved login:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print
|
||||
kubectl -n openbao exec "$POD" -- bao read -field=policies auth/token/lookup-self
|
||||
```
|
||||
|
||||
**Checkpoint:** it prints `[root]`. If it prints anything else, **don't continue**, because the next command revokes whichever token is logged in.
|
||||
|
||||
2. Revoke it and remove the saved login:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao token revoke -self
|
||||
kubectl -n openbao exec "$POD" -- rm -f /home/openbao/.vault-token
|
||||
```
|
||||
|
||||
3. Check that you can still log in to the UI as `admin`. Then delete the root token from Bitwarden, but **keep the unseal key**.
|
||||
|
||||
## Automatic backups
|
||||
|
||||
A CronJob from the OpenBao Helm chart saves a Raft snapshot every hour and uploads it to the `openbao-backups` bucket in RustFS on TrueNAS. Object lock keeps each backup for 30 days. The job logs in with Kubernetes auth and can only read snapshots. Its RustFS key can only upload.
|
||||
|
||||
> Missed or failed backups don't trigger alerts yet. Check the job now and then, and still [save a snapshot](#save-a-snapshot) before upgrades.
|
||||
|
||||
### Set up backups
|
||||
|
||||
Do these in order. Otherwise, the hourly job fails until its login exists.
|
||||
|
||||
1. Set up RustFS, then create the bucket and upload-only user. Follow [the RustFS runbook](truenas-rustfs.md), including step 8.
|
||||
2. Add the backup user's key to the stack's config. Run these from the repo root, and paste each value when prompted:
|
||||
|
||||
```bash
|
||||
pulumi config set --secret --cwd 06-openbao snapshotS3AccessKeyId
|
||||
pulumi config set --secret --cwd 06-openbao snapshotS3SecretAccessKey
|
||||
```
|
||||
|
||||
Commit and push the change in the private config repo, because CI uses the pushed version.
|
||||
|
||||
3. Set [`$POD`](#rules) and log in as `admin`. Run the login **by itself**, not pasted with the next steps, or the password prompt may not work. Then check it:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print -method=userpass username=admin
|
||||
kubectl -n openbao exec "$POD" -- bao read -field=policies auth/token/lookup-self
|
||||
```
|
||||
|
||||
**Checkpoint:** it prints `[admin default]`. If it doesn't, stop. The next steps fail with `permission denied` without a valid login.
|
||||
|
||||
4. Turn on Kubernetes logins. OpenBao uses its own service account and the cluster's CA to check logins:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao auth enable kubernetes
|
||||
kubectl -n openbao exec "$POD" -- bao write auth/kubernetes/config kubernetes_host=https://kubernetes.default.svc:443
|
||||
```
|
||||
|
||||
5. Create the backup policy and role. The role only accepts the `openbao-snapshot` service account in the `openbao` namespace:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -i "$POD" -- bao policy write openbao-snapshot - <<'EOF'
|
||||
path "sys/storage/raft/snapshot" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
EOF
|
||||
kubectl -n openbao exec "$POD" -- bao write auth/kubernetes/role/openbao-snapshot bound_service_account_names=openbao-snapshot bound_service_account_namespaces=openbao token_policies=openbao-snapshot token_ttl=10m token_max_ttl=10m
|
||||
```
|
||||
|
||||
6. Remove the saved login:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao token revoke -self
|
||||
kubectl -n openbao exec "$POD" -- rm -f /home/openbao/.vault-token
|
||||
```
|
||||
|
||||
7. Deploy `06-openbao`. Then start a backup without waiting for the hourly run:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao create job --from=cronjob/openbao-snapshot openbao-snapshot-manual
|
||||
kubectl -n openbao wait --for=condition=complete job/openbao-snapshot-manual --timeout=5m
|
||||
kubectl -n openbao logs job/openbao-snapshot-manual
|
||||
```
|
||||
|
||||
**Checkpoint:** the job completes, and the log ends with an `upload:` line for a `bao_<date>-<time>.snapshot` file. Delete the job afterwards with `kubectl -n openbao delete job openbao-snapshot-manual`.
|
||||
|
||||
### Check backups
|
||||
|
||||
```bash
|
||||
kubectl -n openbao get cronjob openbao-snapshot
|
||||
kubectl -n openbao get jobs -l app.kubernetes.io/component=snapshot-agent
|
||||
```
|
||||
|
||||
**Checkpoint:** `LAST SCHEDULE` is less than an hour ago, and recent jobs show `Complete`. For a failed job, check its logs with `kubectl -n openbao logs job/<job-name>`.
|
||||
|
||||
### Download a backup
|
||||
|
||||
Set up the `admin` function from [step 8 of the RustFS runbook](truenas-rustfs.md#8-create-the-backup-bucket-and-user), then:
|
||||
|
||||
```bash
|
||||
admin s3api list-objects-v2 --bucket openbao-backups --query 'Contents[].[Key,LastModified,Size]' --output text | sort -k2 | tail -5
|
||||
admin s3api get-object --bucket openbao-backups --key <snapshot-file> <snapshot-file>
|
||||
```
|
||||
|
||||
The file is saved in the current folder. Use it with [Restore into a new OpenBao](#restore-into-a-new-openbao). The job doesn't check its snapshots, so a backup is only proven once a restore from it has been tested.
|
||||
|
||||
## Unseal after a restart
|
||||
|
||||
| What restarted | What to do |
|
||||
|---|---|
|
||||
| One OpenBao pod or its node | Unseal that pod. The other two keep OpenBao running. |
|
||||
| All three pods | Unseal all three. OpenBao works again once two are unsealed. |
|
||||
| A node without an OpenBao pod | Nothing |
|
||||
|
||||
1. Find the sealed pods, which show `0/1`:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao get pods -L openbao-active,openbao-sealed
|
||||
```
|
||||
|
||||
2. Unseal each one, replacing `<n>` with its number:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it openbao-<n> -- bao operator unseal
|
||||
```
|
||||
|
||||
3. Run the first command again.
|
||||
|
||||
**Checkpoint:** all pods show `1/1`, and only one is active.
|
||||
|
||||
## Restart pods after a change
|
||||
|
||||
Changes to the OpenBao version or its config only take effect after you restart the pods. Before an upgrade, read the release notes and [save a snapshot](#save-a-snapshot).
|
||||
|
||||
1. Check that all three pods show `1/1`, and note which one is active:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao get pods -L openbao-active
|
||||
```
|
||||
|
||||
2. Restart one **non-active** pod, then [unseal it](#unseal-after-a-restart):
|
||||
|
||||
```bash
|
||||
kubectl -n openbao delete pod openbao-<n>
|
||||
```
|
||||
|
||||
**Checkpoint:** all three pods show `1/1` before you restart the next one.
|
||||
|
||||
3. Do the same for the other non-active pod, then restart the active pod **last**. Another pod takes over, which can cause a short interruption.
|
||||
|
||||
## Save a snapshot
|
||||
|
||||
Do this before upgrades and after important changes, even with [automatic backups](#automatic-backups).
|
||||
|
||||
1. Set [`$POD`](#rules), then log in as `admin`:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print -method=userpass username=admin
|
||||
```
|
||||
|
||||
2. Save a snapshot and copy it to your workstation:
|
||||
|
||||
```bash
|
||||
SNAP=~/openbao-$(date +%F-%H%M).snap
|
||||
kubectl -n openbao exec "$POD" -- bao operator raft snapshot save /home/openbao/openbao.snap
|
||||
(umask 077; kubectl -n openbao exec "$POD" -- cat /home/openbao/openbao.snap > "$SNAP")
|
||||
kubectl -n openbao exec "$POD" -- sha256sum /home/openbao/openbao.snap
|
||||
sha256sum "$SNAP"
|
||||
```
|
||||
|
||||
**Checkpoint:** both checksums match.
|
||||
|
||||
3. Remove the copy and saved login from the pod:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao token revoke -self
|
||||
kubectl -n openbao exec "$POD" -- rm -f /home/openbao/openbao.snap /home/openbao/.vault-token
|
||||
```
|
||||
|
||||
4. Move the snapshot to storage outside the cluster and restrict access to it. **Don't store it with the unseal key**, because someone with both can read your secrets. Note which unseal key it needs.
|
||||
|
||||
## Restore into a new OpenBao
|
||||
|
||||
Use this on a separate test cluster, or if all three pods have lost their data. **It replaces everything in the new OpenBao.** Don't use it for a single lost pod or node. If the cluster being restored to has any working OpenBao data, stop and plan the recovery first.
|
||||
|
||||
You need the snapshot, the **original unseal key** and an admin password that was valid when the snapshot was taken. Use the same OpenBao version as the snapshot.
|
||||
|
||||
1. Deploy a new, empty OpenBao. Follow [First setup](#first-setup) steps 1–3, but save the new unseal key and root token as **temporary**. Don't replace the original key in Bitwarden.
|
||||
2. Set [`$POD`](#rules), then log in with the **temporary root token**:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print
|
||||
```
|
||||
|
||||
3. Check your `kubectl` context, because `-force` overwrites the data and skips the unseal key check:
|
||||
|
||||
```bash
|
||||
kubectl config current-context
|
||||
```
|
||||
|
||||
**Checkpoint:** it's the cluster you want to restore to. Also check that its API address is correct, because different clusters can use the same context name:
|
||||
|
||||
```bash
|
||||
kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'; echo
|
||||
```
|
||||
|
||||
4. Copy the snapshot to the pod and restore it:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -i "$POD" -- sh -c 'cat > /home/openbao/restore.snap' < <snapshot-file>
|
||||
sha256sum <snapshot-file>
|
||||
kubectl -n openbao exec "$POD" -- sha256sum /home/openbao/restore.snap
|
||||
```
|
||||
|
||||
**Checkpoint:** both checksums match. Then run:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao operator raft snapshot restore -force /home/openbao/restore.snap
|
||||
```
|
||||
|
||||
5. Wait 10 seconds, then restart **all three** pods. Otherwise, the non-active pods keep using the temporary key and get stuck:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao delete pod openbao-0 openbao-1 openbao-2
|
||||
```
|
||||
|
||||
6. Once all three are running, [unseal them](#unseal-after-a-restart) with the **original key**. The temporary key and root token no longer work, so delete them.
|
||||
7. Set [`$POD`](#rules) again, log in as `admin` and check the cluster:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print -method=userpass username=admin
|
||||
kubectl -n openbao exec "$POD" -- bao operator raft list-peers
|
||||
```
|
||||
|
||||
**Checkpoint:** there's one leader and two followers, and your secrets are there. All three should show `Voter true`, but this can take a moment.
|
||||
|
||||
8. Remove the saved login:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao token revoke -self
|
||||
kubectl -n openbao exec "$POD" -- rm -f /home/openbao/.vault-token
|
||||
```
|
||||
|
||||
## Replace a lost worker
|
||||
|
||||
Only use this if the worker **can't be recovered** and the other two OpenBao pods are working. If it's only offline, bring it back and unseal its pod. `local-path` data can't move to another node, and each OpenBao pod needs its own node.
|
||||
|
||||
1. [Save a snapshot](#save-a-snapshot). Make sure the old worker can't come back online, then add its replacement to the cluster and remove the old node from Kubernetes. Wait until the replacement is `Ready`.
|
||||
2. Set [`$POD`](#rules), log in as `admin`, then remove the lost pod from the Raft cluster. Replace `<n>` with its number:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print -method=userpass username=admin
|
||||
kubectl -n openbao exec "$POD" -- bao operator raft remove-peer openbao-<n>
|
||||
kubectl -n openbao exec "$POD" -- bao operator raft list-peers
|
||||
```
|
||||
|
||||
**Checkpoint:** only the two working pods are listed.
|
||||
|
||||
3. Delete **only the lost pod** and its PVC. Check the number first:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao delete pvc data-openbao-<n> --wait=false
|
||||
kubectl -n openbao delete pod openbao-<n>
|
||||
```
|
||||
|
||||
If the pod gets stuck in `Terminating`, stop and check that the old node was removed. Don't force-delete the pod while its node could still be running.
|
||||
|
||||
4. Wait for the new pod to show `Running` and `Initialized true`. Don't run `init`. [Unseal it](#unseal-after-a-restart) and run `list-peers` again.
|
||||
|
||||
**Checkpoint:** all three pods are listed with `Voter true`, which can take a moment.
|
||||
|
||||
5. Remove the saved login:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec "$POD" -- bao token revoke -self
|
||||
kubectl -n openbao exec "$POD" -- rm -f /home/openbao/.vault-token
|
||||
```
|
||||
|
||||
## If you lose the admin login
|
||||
|
||||
By default, **the unseal key alone can't create a new root token**. You need to temporarily turn on an older endpoint that doesn't need a login. While it's on, anyone who has the unseal key and can reach OpenBao can get full access.
|
||||
|
||||
1. In `06-openbao/index.ts`, add this to the `listener "tcp"` block. Preview the change, then deploy it:
|
||||
|
||||
```hcl
|
||||
disable_unauthed_generate_root_endpoints = false
|
||||
```
|
||||
|
||||
2. [Restart all three pods](#restart-pods-after-a-change), one at a time.
|
||||
3. Run this on your workstation. The `bao` command doesn't work for this without a login. Enter `https://bao.<domain>` and the unseal key when prompted. It cancels any unfinished attempt first:
|
||||
|
||||
```bash
|
||||
cat > /tmp/openbao-root.py <<'EOF'
|
||||
import base64, getpass, json, urllib.request
|
||||
|
||||
url = input("OpenBao URL: ").rstrip("/")
|
||||
|
||||
def call(method, path, data=None):
|
||||
body = None if data is None else json.dumps(data).encode()
|
||||
req = urllib.request.Request(f"{url}/v1/sys/generate-root/{path}", body, method=method)
|
||||
with urllib.request.urlopen(req) as res:
|
||||
return json.loads(res.read() or b"{}")
|
||||
|
||||
call("DELETE", "attempt")
|
||||
start = call("PUT", "attempt", {})
|
||||
key = getpass.getpass("Unseal key: ")
|
||||
done = call("PUT", "update", {"key": key, "nonce": start["nonce"]})
|
||||
encoded = done["encoded_root_token"]
|
||||
raw = base64.b64decode(encoded + "=" * (-len(encoded) % 4))
|
||||
print("Root token:", bytes(a ^ b for a, b in zip(raw, start["otp"].encode())).decode())
|
||||
EOF
|
||||
python3 /tmp/openbao-root.py
|
||||
rm /tmp/openbao-root.py
|
||||
```
|
||||
|
||||
Save the token in Bitwarden for now, then clear the terminal and its scrollback. If the script shows `405 Method Not Allowed`, the setting isn't active on the pod that answered.
|
||||
|
||||
4. Set [`$POD`](#rules) and log in with the new root token:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao exec -it "$POD" -- bao login -no-print
|
||||
```
|
||||
|
||||
Set a new password with step 4.4 of [First setup](#4-create-the-admin-login). Then [test the login](#5-test-the-admin-login) and [revoke the root token](#7-revoke-the-root-token).
|
||||
|
||||
5. **Remove the setting**, deploy again and restart all three pods, one at a time. Run the script again and enter any text as the key.
|
||||
|
||||
**Checkpoint:** it fails with `405 Method Not Allowed`.
|
||||
|
||||
## Certificates
|
||||
|
||||
cert-manager renews both the browser certificate (`openbao-ingress-tls`) and OpenBao's internal one (`openbao-server-tls`). OpenBao loads its new internal certificate without a restart, so you don't need to unseal it.
|
||||
|
||||
**Don't delete the `openbao-ca` Secret.** It holds the key for our internal CA. Renewing or replacing the CA doesn't immediately renew OpenBao's internal certificate. We haven't tested this, so plan and test it first. Check the certificates with:
|
||||
|
||||
```bash
|
||||
kubectl -n openbao get certificates
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [OpenBao: Running on Kubernetes](https://openbao.org/docs/platform/k8s/helm/run/)
|
||||
- [OpenBao: Raft commands](https://openbao.org/docs/commands/operator/raft/)
|
||||
- [OpenBao: Raft API](https://openbao.org/docs/api/system/storage/raft/)
|
||||
- [OpenBao: Username and password login](https://openbao.org/docs/auth/userpass/)
|
||||
- [OpenBao: Generate a root token](https://openbao.org/docs/commands/operator/generate-root/)
|
||||
- [OpenBao: Listener settings](https://openbao.org/docs/configuration/listener/tcp/)
|
||||
@@ -0,0 +1,285 @@
|
||||
# TrueNAS: RustFS for OpenBao backups (one-time setup)
|
||||
|
||||
Do this after the [first OpenBao setup](openbao.md#first-setup). It installs RustFS, an S3-compatible storage server, on TrueNAS and sets up HTTPS. Then it creates the bucket and upload-only user for [OpenBao's automatic backups](openbao.md#automatic-backups). OpenBao's Helm chart has a backup job that can only upload to S3.
|
||||
|
||||
> This setup was done on TrueNAS 25.10 with app catalog version `1.1.47` (RustFS `1.0.7`). These were tested on a temporary bucket: upload-only access, object lock (even the admin can't delete a locked version), uploads from OpenBao's backup image, and restoring RustFS data from a ZFS snapshot. **Not tested yet:** automatic cleanup of old backups, and certificate renewal. Menu names can differ between TrueNAS versions.
|
||||
|
||||
## Placeholders
|
||||
|
||||
| Placeholder | Meaning |
|
||||
|---|---|
|
||||
| `<domain>` | Your domain, with DNS managed by Cloudflare |
|
||||
| `<truenas-ip>` | TrueNAS's fixed local IP |
|
||||
| `<pool>` | The TrueNAS pool that stores the backups |
|
||||
| `<email>` | An email address you own |
|
||||
| `<timezone>` | Your timezone |
|
||||
|
||||
## Rules
|
||||
|
||||
- **Don't expose RustFS to the internet.** Don't forward its ports in pfSense, and don't create an A, AAAA or CNAME record for `rustfs.<domain>` in Cloudflare.
|
||||
- **Never give the cluster admin access to TrueNAS or RustFS.** Don't use the RustFS admin login for backups.
|
||||
- **Don't share the RustFS dataset over NFS or SMB**, and don't add it to other apps. Anyone who can write to its files can bypass RustFS's access rules and object lock.
|
||||
- Save passwords and tokens in Bitwarden. Never put them in Git, tickets, chats or commands.
|
||||
- **Don't use the MinIO app.** TrueNAS has removed it from its catalog, and the open-source version no longer gets updates.
|
||||
|
||||
## 1. Check TrueNAS
|
||||
|
||||
1. Use a stable TrueNAS release, not a beta or release candidate. The current app catalog needs 24.10 or newer. If you need to upgrade, [back up the config with its secret seed](https://www.truenas.com/docs/scale/25.10/scaletutorials/systemsettings/updatescale/) and follow the [official upgrade path](https://www.truenas.com/docs/truenasupgrades/). **Don't upgrade the ZFS pools at the same time.** Older TrueNAS versions may not be able to open them afterwards.
|
||||
2. Check that the pools are healthy and the existing NFS and SMB shares work.
|
||||
3. Go to **Apps > Configuration > Settings**. Under **Preferred Trains**, select **community** and keep **stable** selected. Save.
|
||||
4. Go to **Apps > Discover Apps**, refresh the catalog and search for **RustFS**. Don't install it yet.
|
||||
|
||||
**Checkpoint:** RustFS is listed, and its **app version** is `1.0.7` or newer. This is different from the catalog version, such as `1.1.47`. Check the [RustFS security advisories](https://github.com/rustfs/rustfs/security/advisories) before installing or updating it.
|
||||
|
||||
## 2. Create the dataset
|
||||
|
||||
Don't use the dataset for the [`truenas-nfs` share](truenas-nfs.md), or create this one inside it. The k3s nodes have root access to that share, so a compromised node could change or delete the backups directly.
|
||||
|
||||
1. Go to **Datasets**, select the top level of `<pool>`, and click **Add Dataset**:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Name | `rustfs` |
|
||||
| Dataset Preset | **Apps** |
|
||||
| Quota | None for now. Set one once you know how much space the backups and ZFS snapshots need. New backups fail if it's too low. |
|
||||
|
||||
The path is `/mnt/<pool>/rustfs`.
|
||||
|
||||
2. Select `rustfs` and click **Edit** under **Permissions**. RustFS runs as TrueNAS's built-in `apps` user and group, both with ID `568`. Check that `apps` has **Modify** access. If it doesn't, add this NFSv4 ACL entry:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Who | **User** |
|
||||
| User | `apps` |
|
||||
| Type | **Allow** |
|
||||
| Permissions | **Modify** |
|
||||
| Flags | Keep the default inheritance setting, so new files and folders get the same access |
|
||||
|
||||
Don't add access for `everyone@`, use `777`, or change permissions on the top level of the pool. If the dataset is new and empty, you don't need to apply the ACL recursively. If TrueNAS shows **Read / Write / Execute** instead, stop. The dataset uses a different permission type.
|
||||
|
||||
**Checkpoint:** `apps` has **Modify** access. No NFS or SMB share includes `/mnt/<pool>/rustfs`, not even a share for a parent folder such as `/mnt/<pool>`.
|
||||
|
||||
This dataset **doesn't protect the backups if the whole pool fails**.
|
||||
|
||||
## 3. Add the pfSense DNS entry
|
||||
|
||||
Go to **Services > DNS Resolver > General Settings**. Under **Host Overrides**, click **Add**:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Host | `rustfs` |
|
||||
| Domain | `<domain>` |
|
||||
| IP Address | `<truenas-ip>`, **not** Traefik's IP |
|
||||
| Description | `RustFS on TrueNAS` |
|
||||
|
||||
Save, then click **Apply Changes**. Check it from your workstation:
|
||||
|
||||
```bash
|
||||
getent ahostsv4 rustfs.<domain>
|
||||
```
|
||||
|
||||
**Checkpoint:** it only shows `<truenas-ip>`.
|
||||
|
||||
## 4. Create the Cloudflare token
|
||||
|
||||
Let's Encrypt uses a temporary DNS TXT record to check that you own the domain. TrueNAS adds it through Cloudflare, so RustFS doesn't need to be available from the internet. The hostname will appear in public certificate logs.
|
||||
|
||||
Use a separate token from pfSense and cert-manager. That way, you can replace or revoke it without breaking their certificates.
|
||||
|
||||
1. In Cloudflare, go to **My Profile > API Tokens > Create Token**. Use the **Edit zone DNS** template or create a custom token:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Token name | `truenas-acme` |
|
||||
| Permission 1 | `Zone` → `DNS` → `Edit` |
|
||||
| Permission 2 | `Zone` → `Zone` → `Read` |
|
||||
| Zone Resources | `Include` → `Specific zone` → `<domain>` |
|
||||
| Client IP Address Filtering | Empty. A filter can stop renewals if your public IP changes. |
|
||||
| TTL | Empty. The certificate can't renew once the token expires. |
|
||||
|
||||
If you can't limit the token to `<domain>`, stop. Don't choose **All zones** to get around this.
|
||||
|
||||
2. Check the summary, then create the token. Save it in Bitwarden, because Cloudflare **only shows it once**. Don't run Cloudflare's test command with the real token in it, because it could be saved in your shell history.
|
||||
|
||||
## 5. Create the certificate in TrueNAS
|
||||
|
||||
1. Go to **Credentials > Certificates**. Under **ACME DNS-Authenticators**, click **Add**:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Name | `cloudflare` |
|
||||
| Authenticator | `cloudflare` |
|
||||
| Cloudflare Email | Empty |
|
||||
| API Key | Empty. This is for the global API key. |
|
||||
| API Token | The `truenas-acme` token |
|
||||
|
||||
2. Under **Certificate Signing Requests**, click **Add**:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Name | `rustfs`. This is only a label in TrueNAS. |
|
||||
| Type | **Certificate Signing Request** |
|
||||
| Profile | **HTTPS RSA Certificate** |
|
||||
| Key Type / Key Length | **RSA** / `2048` |
|
||||
| Digest Algorithm | **SHA256** |
|
||||
| Common Name | `rustfs.<domain>` |
|
||||
| Subject Alternative Name (SAN) | `rustfs.<domain>` |
|
||||
| Email | `<email>` |
|
||||
| Country, state, city and organisation | Fill in the required fields. Let's Encrypt doesn't include them in the certificate. |
|
||||
| Basic Constraints | **Critical Extension** only. Don't select **CA**, because this certificate doesn't need to sign others. |
|
||||
| Extended Key Usage | `SERVER_AUTH` only, with **Critical Extension** selected. `CLIENT_AUTH` isn't needed. |
|
||||
| Key Usage | **Critical Extension**, **Digital Signature**, **Key Encipherment** and **Key Agreement**. Key Agreement isn't needed, but it's part of the tested setup. |
|
||||
|
||||
Enter only the hostname in **Common Name** and **SAN**, without `https://` or a port. Both must be **exactly the same**. Check the summary, then save.
|
||||
|
||||
3. Click the wrench icon next to the `rustfs` request to create an ACME certificate:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Identifier | `rustfs-le` |
|
||||
| ACME Server Directory URI | Let's Encrypt **production**, not staging |
|
||||
| Terms of Service | Accept |
|
||||
| Renew Certificate Days | Default |
|
||||
| Authenticator for `rustfs.<domain>` | `cloudflare` |
|
||||
|
||||
It can take a few minutes. If it fails, check the error before trying again, because Let's Encrypt has rate limits.
|
||||
|
||||
**Checkpoint:** `rustfs-le` is listed under **Certificates**, with Let's Encrypt as the issuer.
|
||||
|
||||
## 6. Install RustFS
|
||||
|
||||
Go to **Apps > Discover Apps**, select **RustFS** and click **Install**. Enter these settings:
|
||||
|
||||
| Section | Setting | Value |
|
||||
|---|---|---|
|
||||
| General | Application Name | `rustfs` |
|
||||
| General | Version | `1.1.47`, or a newer version you've checked. This is the catalog version. |
|
||||
| RustFS | Timezone | `<timezone>` |
|
||||
| RustFS | Deployment Mode | **SNSD (Single Node Single Disk)**. RustFS uses one data location, so only the ZFS pool can protect against disk failures. |
|
||||
| RustFS | Account Name | `rustfs-admin` |
|
||||
| RustFS | Secret Key | A unique password with 40 random letters and numbers, saved in Bitwarden. Leaving out symbols such as `$` avoids possible config problems. |
|
||||
| RustFS | Additional Environment Variables | None |
|
||||
| User and Group | User ID / Group ID | `568` / `568` |
|
||||
| Network | API Port | **Publish port on the host for external access**, port `30292` |
|
||||
| Network | WebUI Port | **Publish port on the host for external access**, port `30293` |
|
||||
| Network | Host IPs (both ports) | None. RustFS listens on all TrueNAS addresses. |
|
||||
| Network | Networks | None |
|
||||
| Network | Host Network | Off |
|
||||
| Network | Certificate | `rustfs-le`. Don't choose **No Certificate** or the default TrueNAS certificate. |
|
||||
| Storage | Data Disks | Keep one data disk and change its type from **ixVolume** to **Host Path** |
|
||||
| Storage | Enable ACL | Off. The permissions were set in [step 2](#2-create-the-dataset). |
|
||||
| Storage | Host Path | `/mnt/<pool>/rustfs` |
|
||||
| Storage | Additional Storage | None |
|
||||
| Labels | Labels | None |
|
||||
| Resources | CPUs / Memory | `2` / `4096` MB. These are limits, not reserved resources. |
|
||||
|
||||
Before you click **Install**, check that the type is **Host Path** and the certificate is `rustfs-le`. **If you've already installed RustFS with an ixVolume, don't just change the path.** Its data, settings and users may not move with it.
|
||||
|
||||
pfSense usually can't block devices on the same subnet from reaching TrueNAS. "External access" here means access from outside the app's container. It doesn't expose the ports to the internet unless you also forward them.
|
||||
|
||||
**Checkpoint:** the app is **Running**. If it isn't, check its logs for permission or certificate errors. Don't use `777` to fix permission errors.
|
||||
|
||||
## 7. Check RustFS
|
||||
|
||||
1. Check both ports from your workstation:
|
||||
|
||||
```bash
|
||||
curl -sS -o /dev/null -w 'S3: HTTP %{http_code}, TLS check %{ssl_verify_result}\n' https://rustfs.<domain>:30292/
|
||||
curl -sS -o /dev/null -w 'Console: HTTP %{http_code}, TLS check %{ssl_verify_result}\n' https://rustfs.<domain>:30293/rustfs/console/
|
||||
```
|
||||
|
||||
**Checkpoint:** S3 shows `HTTP 403`, which is expected without a login. The console shows `HTTP 200`. Both show `TLS check 0`, and there are no `curl` errors.
|
||||
|
||||
2. Check the certificate:
|
||||
|
||||
```bash
|
||||
openssl s_client -connect rustfs.<domain>:30292 -servername rustfs.<domain> </dev/null 2>/dev/null \
|
||||
| openssl x509 -noout -subject -issuer -enddate -ext subjectAltName
|
||||
```
|
||||
|
||||
**Checkpoint:** the issuer is Let's Encrypt, and the SAN is `rustfs.<domain>`. Note the expiry date.
|
||||
|
||||
3. Open `https://rustfs.<domain>:30293/rustfs/console/` and log in as `rustfs-admin` with the Secret Key.
|
||||
|
||||
**Checkpoint:** the login works, and there's no certificate warning. Bookmark this link.
|
||||
|
||||
After the certificate renews, run step 2 again. If it still shows the old expiry date, RustFS hasn't loaded the new certificate. Restart the app, then check again.
|
||||
|
||||
## 8. Create the backup bucket and user
|
||||
|
||||
Object lock can only be turned on when a bucket is created. OpenBao's backup job uploads with an upload-only key, so it can't read, list, delete or unlock backups.
|
||||
|
||||
1. On your workstation, set up the AWS CLI in Docker. Paste the RustFS admin login when prompted. Nothing appears as you paste.
|
||||
|
||||
```bash
|
||||
mkdir -p ~/rustfs && cd ~/rustfs
|
||||
EP=https://rustfs.<domain>:30292
|
||||
s3() { docker run --rm -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_REGION=us-east-1 -e AWS_ENDPOINT_URL="$EP" -v "$PWD:/aws:Z" docker.io/amazon/aws-cli:latest "$@"; }
|
||||
read -rsp 'RustFS admin account name: ' A_ID; echo
|
||||
read -rsp 'RustFS admin secret key: ' A_KEY; echo
|
||||
admin() ( export AWS_ACCESS_KEY_ID="$A_ID" AWS_SECRET_ACCESS_KEY="$A_KEY"; s3 "$@" )
|
||||
```
|
||||
|
||||
The functions and keys only exist in this terminal. In a new terminal, run this step again. RustFS expects the region `us-east-1`.
|
||||
|
||||
2. Create the bucket with a default lock of 30 days:
|
||||
|
||||
```bash
|
||||
admin s3api create-bucket --bucket openbao-backups --object-lock-enabled-for-bucket
|
||||
admin s3api put-object-lock-configuration --bucket openbao-backups --object-lock-configuration '{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"GOVERNANCE","Days":30}}}'
|
||||
admin s3api get-bucket-versioning --bucket openbao-backups
|
||||
admin s3api get-object-lock-configuration --bucket openbao-backups
|
||||
```
|
||||
|
||||
**Checkpoint:** versioning shows `Enabled`, and the lock shows `GOVERNANCE` with `30` days. `GOVERNANCE` means the backup user can't remove the lock. Unlike `COMPLIANCE`, an admin can still remove it to fix a mistake.
|
||||
|
||||
3. In the RustFS console, go to **Identity > Policies** and create `openbao-backups-upload`:
|
||||
|
||||
```json
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:PutObject"],"Resource":["arn:aws:s3:::openbao-backups/*"]}]}
|
||||
```
|
||||
|
||||
4. Go to **Identity > Users** and create the backup user:
|
||||
|
||||
| Setting | Value |
|
||||
|---|---|
|
||||
| Name / access key | `openbao-snapshot` |
|
||||
| Secret key | 40 random letters and numbers, saved in Bitwarden |
|
||||
| Groups | **None.** A group would add its own policies. |
|
||||
| Policies | **Only** `openbao-backups-upload`. Don't use built-in policies such as `writeonly` or `readwrite`, because they cover every bucket. |
|
||||
|
||||
5. Check the user's access:
|
||||
|
||||
```bash
|
||||
read -rsp 'openbao-snapshot secret key: ' P_KEY; echo
|
||||
prod() ( export AWS_ACCESS_KEY_ID=openbao-snapshot AWS_SECRET_ACCESS_KEY="$P_KEY"; s3 "$@" )
|
||||
echo check > check.txt; prod s3api put-object --bucket openbao-backups --key setup-check.txt --body check.txt
|
||||
prod s3api list-objects-v2 --bucket openbao-backups
|
||||
prod s3api delete-object --bucket openbao-backups --key setup-check.txt
|
||||
```
|
||||
|
||||
**Checkpoint:** the upload works, and listing and deleting both fail with `AccessDenied`. The test file stays locked for 30 days.
|
||||
|
||||
6. Protect the RustFS data with ZFS snapshots. Go to **Data Protection > Periodic Snapshot Tasks** and check that a task covers `<pool>/rustfs`, either directly or through a recursive task on its parent. Keep snapshots for at least 30 days. They protect backups if someone misuses the RustFS admin login. They don't protect against losing the pool.
|
||||
|
||||
Old backups aren't cleaned up automatically yet. The bucket keeps growing until a cleanup rule has been tested and added.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problem | What to do |
|
||||
|---|---|
|
||||
| TrueNAS links to `0.0.0.0` | This means RustFS listens on all addresses. It isn't an address you can open. Use the full console link from step 7, and leave **Host IPs** empty. |
|
||||
| An `http://` link doesn't open | RustFS uses HTTPS on both ports. Use `https://`. |
|
||||
| `https://rustfs.<domain>:30293/` shows `403` | Add the console path: `/rustfs/console/` |
|
||||
| The browser shows a certificate warning | Use the hostname, not the IP. Then check that the app uses `rustfs-le` and that the SAN is correct. |
|
||||
| The hostname doesn't work | Check the pfSense host override. If you've just added it, close and reopen the browser. You don't need to reinstall RustFS. |
|
||||
| The certificate request fails | Check that **Common Name** and **SAN** are the same full hostname. Then check the Cloudflare token's permissions and domain. |
|
||||
| `s3cmd` fails with `invalid credential region: "US"` | Add `--region=us-east-1`. The backup job already sets it. |
|
||||
| Podman fails with `mkdir /run/user/<id>: permission denied` | Podman may have saved an old user ID. Use Docker instead, or fix Podman separately. |
|
||||
|
||||
## References
|
||||
|
||||
- [TrueNAS: RustFS app](https://apps.truenas.com/catalog/rustfs_community/)
|
||||
- [TrueNAS: app setup](https://apps.truenas.com/getting-started/initial-setup)
|
||||
- [RustFS: TLS](https://docs.rustfs.com/en/integration/tls-configured)
|
||||
- [OpenBao: snapshot agent for Kubernetes](https://github.com/openbao/openbao-snapshot-agent/tree/main/kubernetes)
|
||||
Reference in new issue
Block a user