Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
250bbab65c |
No files matched your search
@@ -1,10 +1,10 @@
|
||||
name: 'Keycloak Terraform'
|
||||
name: 'Terraform'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
paths:
|
||||
- 'terraform/keycloak/**'
|
||||
- 'terraform/authentik/**'
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
@@ -29,31 +29,119 @@ jobs:
|
||||
with:
|
||||
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
|
||||
|
||||
- name: Setup kubeconfig
|
||||
env:
|
||||
CI_KUBECONFIG: ${{ secrets.KUBECONFIG }}
|
||||
run: |
|
||||
mkdir -p ~/.kube
|
||||
printf '%s' "$CI_KUBECONFIG" > ~/.kube/config
|
||||
chmod 600 ~/.kube/config
|
||||
|
||||
- name: Terraform Init
|
||||
env:
|
||||
TF_VAR_authentik_token: ${{ secrets.AUTHENTIK_TOKEN }}
|
||||
run: terraform init
|
||||
working-directory: ./terraform/keycloak
|
||||
working-directory: ./terraform/authentik
|
||||
|
||||
- name: Terraform Format
|
||||
env:
|
||||
TF_VAR_authentik_token: ${{ secrets.AUTHENTIK_TOKEN }}
|
||||
run: terraform fmt -check
|
||||
continue-on-error: true
|
||||
working-directory: ./terraform/keycloak
|
||||
working-directory: ./terraform/authentik
|
||||
|
||||
- name: Terraform Apply
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
env:
|
||||
TF_VAR_keycloak_client_secret: ${{ secrets.KEYCLOAK_CLIENT_SECRET }}
|
||||
TF_VAR_google_client_id: ${{ secrets.GOOGLE_CLIENT_ID }}
|
||||
TF_VAR_google_client_secret: ${{ secrets.GOOGLE_CLIENT_SECRET }}
|
||||
BW_CLIENTID: ${{ secrets.BW_CLIENTID }}
|
||||
BW_CLIENTSECRET: ${{ secrets.BW_CLIENTSECRET }}
|
||||
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
|
||||
TF_VAR_authentik_token: ${{ secrets.AUTHENTIK_TOKEN }}
|
||||
run: terraform apply -input=false -auto-approve -parallelism=100
|
||||
working-directory: ./terraform/keycloak
|
||||
working-directory: ./terraform/authentik
|
||||
|
||||
- name: Generate Wiki Content
|
||||
if: success()
|
||||
continue-on-error: true
|
||||
env:
|
||||
TF_VAR_authentik_token: ${{ secrets.AUTHENTIK_TOKEN }}
|
||||
run: |
|
||||
echo "📋 Starting Wiki generation..."
|
||||
cd ./terraform/authentik
|
||||
|
||||
# Get terraform output
|
||||
echo "🔍 Generating Terraform output..."
|
||||
terraform output -json applications_for_wiki > terraform-raw-output.json 2>&1
|
||||
|
||||
# Process output to extract clean JSON
|
||||
echo "📤 Processing Terraform output..."
|
||||
python3 ../../.gitea/scripts/process-terraform-output.py terraform-raw-output.json terraform-output.json
|
||||
|
||||
# Run wiki generation
|
||||
echo "📊 Running wiki generation script..."
|
||||
if python3 ../../.gitea/scripts/generate-apps-wiki.py terraform-output.json; then
|
||||
echo "✅ Wiki content generated successfully"
|
||||
else
|
||||
echo "⚠️ Wiki generation failed, retrying with debug..."
|
||||
python3 ../../.gitea/scripts/generate-apps-wiki.py terraform-output.json --debug || echo "⚠️ Wiki generation failed"
|
||||
fi
|
||||
|
||||
# Check results
|
||||
if [ -f "Applications.md" ]; then
|
||||
echo "✅ Wiki file created: $(wc -l < Applications.md) lines"
|
||||
else
|
||||
echo "⚠️ Wiki content not generated"
|
||||
exit 0
|
||||
fi
|
||||
working-directory: ./
|
||||
|
||||
- name: Upload Wiki to Gitea
|
||||
if: success()
|
||||
continue-on-error: true
|
||||
run: |
|
||||
cd ./terraform/authentik
|
||||
|
||||
# Set variables
|
||||
GITEA_URL="${{ secrets.GT_URL }}"
|
||||
GITEA_TOKEN="${{ secrets.GT_WIKI_TOKEN }}"
|
||||
GITEA_OWNER="${{ secrets.GT_OWNER }}"
|
||||
GITEA_REPO="${{ secrets.GT_REPO }}"
|
||||
|
||||
# Debug variables (without exposing token)
|
||||
echo "🔍 Checking variables..."
|
||||
echo "GITEA_URL: ${GITEA_URL:-NOT SET}"
|
||||
echo "GITEA_OWNER: ${GITEA_OWNER:-NOT SET}"
|
||||
echo "GITEA_REPO: ${GITEA_REPO:-NOT SET}"
|
||||
echo "GITEA_TOKEN: $(if [ -n "$GITEA_TOKEN" ]; then echo "SET"; else echo "NOT SET"; fi)"
|
||||
|
||||
# Check if file exists
|
||||
if [ ! -f "Applications.md" ]; then
|
||||
echo "⚠️ Applications.md not found, skipping wiki update"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "📤 Uploading to Gitea Wiki..."
|
||||
|
||||
# Encode content to base64
|
||||
CONTENT=$(base64 -w 0 Applications.md)
|
||||
|
||||
# Check if wiki page exists
|
||||
WIKI_PAGE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/page/Applications" || echo "000")
|
||||
|
||||
if [ "$WIKI_PAGE_EXISTS" = "200" ]; then
|
||||
echo "📝 Updating existing wiki page..."
|
||||
curl -X PATCH \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"Applications\",
|
||||
\"content_base64\": \"$CONTENT\",
|
||||
\"message\": \"Update applications list from CI/CD [$(date)]\"
|
||||
}" \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/page/Applications" || echo "⚠️ Wiki update failed"
|
||||
else
|
||||
echo "📄 Creating new wiki page..."
|
||||
curl -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"Applications\",
|
||||
\"content_base64\": \"$CONTENT\",
|
||||
\"message\": \"Create applications list from CI/CD [$(date)]\"
|
||||
}" \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/new" || echo "⚠️ Wiki creation failed"
|
||||
fi
|
||||
|
||||
echo "✅ Wiki update process completed"
|
||||
working-directory: ./
|
||||
|
||||
@@ -59,6 +59,3 @@ tags
|
||||
[._]*.un~
|
||||
|
||||
.DS_Store
|
||||
|
||||
# Helm charts pulled by kustomize (--enable-helm) when rendering locally
|
||||
k8s-ng/**/charts/
|
||||
@@ -13,19 +13,15 @@ ArgoCD homelab project
|
||||
| Application | Status |
|
||||
| :--- | :---: |
|
||||
| **argocd** | [](https://ag.hexor.cy/applications/argocd/argocd) |
|
||||
| **auth-proxy** | [](https://ag.hexor.cy/applications/argocd/auth-proxy) |
|
||||
| **authentik** | [](https://ag.hexor.cy/applications/argocd/authentik) |
|
||||
| **cert-manager** | [](https://ag.hexor.cy/applications/argocd/cert-manager) |
|
||||
| **external-secrets** | [](https://ag.hexor.cy/applications/argocd/external-secrets) |
|
||||
| **gpu** | [](https://ag.hexor.cy/applications/argocd/gpu) |
|
||||
| **kanidm** | [](https://ag.hexor.cy/applications/argocd/kanidm) |
|
||||
| **keycloak** | [](https://ag.hexor.cy/applications/argocd/keycloak) |
|
||||
| **kube-system-custom** | [](https://ag.hexor.cy/applications/argocd/kube-system-custom) |
|
||||
| **kubernetes-dashboard** | [](https://ag.hexor.cy/applications/argocd/kubernetes-dashboard) |
|
||||
| **longhorn** | [](https://ag.hexor.cy/applications/argocd/longhorn) |
|
||||
| **postgresql** | [](https://ag.hexor.cy/applications/argocd/postgresql) |
|
||||
| **prom-stack** | [](https://ag.hexor.cy/applications/argocd/prom-stack) |
|
||||
| **reloader** | [](https://ag.hexor.cy/applications/argocd/reloader) |
|
||||
| **system-upgrade** | [](https://ag.hexor.cy/applications/argocd/system-upgrade) |
|
||||
|
||||
### Games
|
||||
@@ -43,7 +39,8 @@ ArgoCD homelab project
|
||||
| Application | Status |
|
||||
| :--- | :---: |
|
||||
| **comfyui** | [](https://ag.hexor.cy/applications/argocd/comfyui) |
|
||||
| **furumi** | [](https://ag.hexor.cy/applications/argocd/furumi) |
|
||||
| **furumi-dev** | [](https://ag.hexor.cy/applications/argocd/furumi-dev) |
|
||||
| **furumi-server** | [](https://ag.hexor.cy/applications/argocd/furumi-server) |
|
||||
| **gitea** | [](https://ag.hexor.cy/applications/argocd/gitea) |
|
||||
| **greece-notifier** | [](https://ag.hexor.cy/applications/argocd/greece-notifier) |
|
||||
| **hexound** | [](https://ag.hexor.cy/applications/argocd/hexound) |
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
# F-Droid repository
|
||||
|
||||
Open `https://fdroid.hexor.cy/` to browse the apps and scan the QR code to
|
||||
add the repository in F-Droid. The QR code includes the signing certificate
|
||||
fingerprint. The public catalog is generated from the signed index at
|
||||
`https://fdroid.hexor.cy/fdroid/repo/`. Gitea and GitHub Releases supply
|
||||
the signed Android APKs. Every five minutes the publisher
|
||||
checks the latest stable release and publishes a signed index when the inputs
|
||||
change. Both the publisher and BusyBox HTTP server run on the node labelled
|
||||
`kubernetes.io/hostname=master`. Data lives in `/data/k8s/fdroidserver`.
|
||||
Traefik terminates TLS and routes requests to the read-only HTTP server.
|
||||
|
||||
## Set up the repository signing key once
|
||||
|
||||
Create a Bitwarden item named exactly `k8s/fdroidserver/secrets` in the vault
|
||||
collection readable by the External Secrets bot. Add these **Hidden** custom fields:
|
||||
|
||||
| Field | Value |
|
||||
| --- | --- |
|
||||
| `keystorepass` | A generated 32-character alphanumeric password |
|
||||
| `keystore-base64` | The entire PKCS#12 file, base64-encoded on one line |
|
||||
|
||||
In a private directory on a trusted machine with a JDK, generate the key and
|
||||
enter the password from Bitwarden when prompted:
|
||||
|
||||
```sh
|
||||
umask 077
|
||||
keytool -genkeypair -storetype PKCS12 -keystore fdroid-repo.p12 \
|
||||
-alias fdroidrepo -keyalg RSA -keysize 3072 -sigalg SHA256withRSA \
|
||||
-validity 10000 -dname 'CN=F-Droid Repository'
|
||||
```
|
||||
|
||||
On macOS, copy the field value directly to the clipboard:
|
||||
|
||||
```sh
|
||||
openssl base64 -A -in fdroid-repo.p12 | pbcopy
|
||||
```
|
||||
|
||||
Keep a protected backup of the keystore and its password. Clients identify
|
||||
the repository by this key. To restore the exact file on macOS, copy the
|
||||
`keystore-base64` field and run the following in a private directory:
|
||||
|
||||
```sh
|
||||
umask 077
|
||||
pbpaste | openssl base64 -d -A -out restored.p12
|
||||
```
|
||||
|
||||
To get the SHA-256 fingerprint for sharing with
|
||||
users, run `keytool -list -v -keystore fdroid-repo.p12 -alias fdroidrepo`.
|
||||
The APK signing keys stay with the projects' release pipelines.
|
||||
|
||||
## Add an application
|
||||
|
||||
1. Add its GitHub or Gitea repository URL (with or without a trailing
|
||||
`/releases`), Android package name and release signing certificate SHA-256 to
|
||||
`sources.json`. Use `assetPattern` when a release contains multiple APK
|
||||
variants. Obtain the fingerprint from a trusted release with
|
||||
`apksigner verify --print-certs app.apk`.
|
||||
2. Add `metadata/<packageName>.yml` and list it in the metadata ConfigMap
|
||||
generator in `kustomization.yaml`. Set `AllowedAPKSigningKeys` to the same
|
||||
fingerprint.
|
||||
3. Publish a signed APK as a release asset. Increase the Android `versionCode`
|
||||
for each new binary. Argo CD applies the configuration and the next
|
||||
scheduled job picks up the release.
|
||||
@@ -1,150 +0,0 @@
|
||||
"""Render the public landing page from the published F-Droid v2 index."""
|
||||
|
||||
import re
|
||||
from html import escape, unescape
|
||||
from textwrap import shorten
|
||||
from urllib.parse import quote, urlsplit, urlunsplit
|
||||
|
||||
|
||||
def english(value):
|
||||
if not isinstance(value, dict):
|
||||
return None
|
||||
locales = ("en-US", "en", *(key for key in value if key.lower().startswith("en-")))
|
||||
return next((value[key] for key in locales if value.get(key)), None)
|
||||
|
||||
|
||||
def asset_url(file):
|
||||
name = (file or {}).get("name", "").removeprefix("/")
|
||||
if not name or any(part in ("", ".", "..") for part in name.split("/")):
|
||||
return None
|
||||
return "/fdroid/repo/" + quote(name, safe="/")
|
||||
|
||||
|
||||
def app_card(package_id, package):
|
||||
metadata = package["metadata"]
|
||||
name = english(metadata.get("name")) or package_id
|
||||
summary = english(metadata.get("summary"))
|
||||
if not summary:
|
||||
description = english(metadata.get("description")) or ""
|
||||
summary = shorten(unescape(re.sub(r"<[^>]+>", " ", description)), 180, placeholder="…")
|
||||
icons = metadata.get("icon") or {}
|
||||
icon = asset_url(english(icons) or next(iter(icons.values()), None))
|
||||
if icon:
|
||||
icon_html = f'<img class="app-icon" src="{icon}" width="48" height="48" alt="">'
|
||||
else:
|
||||
icon_html = f'<span class="monogram" aria-hidden="true">{escape(name[:1].upper())}</span>'
|
||||
|
||||
versions = package.get("versions", {}).values()
|
||||
latest = max(versions, key=lambda it: it["manifest"]["versionCode"], default={})
|
||||
manifest = latest.get("manifest", {})
|
||||
version = manifest.get("versionName")
|
||||
if not version or not version.isascii():
|
||||
version = manifest.get("versionCode")
|
||||
version_html = f'<p class="version">Version {escape(str(version))}</p>' if version else ""
|
||||
file = latest.get("file", {})
|
||||
download = asset_url(file)
|
||||
download_html = ""
|
||||
if download:
|
||||
size = file.get("size")
|
||||
size_text = f" · {size / 1_000_000:.1f} MB" if size else ""
|
||||
download_html = f'<a class="download" href="{download}" download>Download APK{size_text}</a>'
|
||||
|
||||
return f"""<article>
|
||||
<header>{icon_html}<div><h3>{escape(name)}</h3>{version_html}</div></header>
|
||||
<p class="summary">{escape(summary)}</p>
|
||||
{download_html}
|
||||
</article>"""
|
||||
|
||||
|
||||
STYLE = """
|
||||
:root { color-scheme: light; --ink: #15291f; --muted: #4e6257; --green: #165c3a; }
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; background: #f7f9f5; color: var(--ink); font: 16px/1.55 Inter, system-ui, sans-serif; }
|
||||
main { width: min(940px, calc(100% - 32px)); margin: clamp(20px, 6vw, 72px) auto; }
|
||||
.intro { background: #e5efe3; border: 1px solid #cddccc; border-radius: 24px; padding: clamp(24px, 5vw, 56px);
|
||||
display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 198px); align-items: start; gap: 32px; }
|
||||
.type { color: var(--green); margin: 0; font-weight: 650; }
|
||||
h1, h2, h3 { line-height: 1.12; margin: 0; overflow-wrap: anywhere; }
|
||||
h1 { font-size: clamp(42px, 7vw, 72px); letter-spacing: -.055em; margin: .14em 0 .3em; }
|
||||
.instruction { margin: 0 0 22px; max-width: 49ch; }
|
||||
a { color: var(--green); text-underline-offset: .22em; }
|
||||
a:focus-visible, summary:focus-visible { outline: 3px solid #137050; outline-offset: 4px; }
|
||||
.open { display: inline-block; padding: 11px 18px; background: var(--green); color: white;
|
||||
font-weight: 650; border-radius: 9px; text-decoration: none; }
|
||||
.open:hover { background: #10462d; }
|
||||
.qr { background: white; padding: 9px; width: 100%; max-width: 198px; border-radius: 12px; justify-self: end; }
|
||||
.qr img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
|
||||
details { margin-top: 15px; font-size: .875rem; color: var(--muted); }
|
||||
summary { width: fit-content; cursor: pointer; color: var(--green); }
|
||||
details p { margin: 10px 0 4px; }
|
||||
.address { overflow-wrap: anywhere; font: .84rem/1.55 ui-monospace, monospace; user-select: all; }
|
||||
section { margin-top: clamp(30px, 5vw, 50px); }
|
||||
h2 { font-size: clamp(25px, 4vw, 34px); letter-spacing: -.035em; }
|
||||
.grid { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
|
||||
article { display: flex; flex-direction: column; align-items: flex-start; border-radius: 17px;
|
||||
border: 1px solid #d9e2d9; padding: 24px; background: white; min-width: 0; }
|
||||
header { display: flex; align-items: center; gap: 14px; }
|
||||
.app-icon, .monogram { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 10px; }
|
||||
.app-icon { object-fit: contain; }
|
||||
.monogram { display: grid; place-items: center; color: var(--green); background: #e9f1e8; font-size: 25px; font-weight: 650; }
|
||||
h3 { font-size: 1.35rem; letter-spacing: -.025em; }
|
||||
.version { margin: 3px 0 0; color: var(--muted); font-size: .84rem; }
|
||||
.summary { color: var(--muted); margin: 15px 0; overflow-wrap: anywhere; }
|
||||
.download { margin-top: auto; font-size: .91rem; font-weight: 600; }
|
||||
@media (max-width: 610px) {
|
||||
.intro, .grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.intro { gap: 20px; }
|
||||
.qr { max-width: 152px; justify-self: start; }
|
||||
article { padding: 20px; }
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def write_catalog(repo, listing, fingerprint):
|
||||
address = urlsplit(listing["repo"]["address"].rstrip("/"))
|
||||
if address.scheme != "https" or not address.hostname or address.query or address.fragment:
|
||||
raise ValueError("Expected a canonical HTTPS F-Droid repository URL")
|
||||
if not re.fullmatch(r"[0-9a-fA-F]{64}", fingerprint):
|
||||
raise ValueError("Invalid F-Droid repository fingerprint")
|
||||
query = "fingerprint=" + fingerprint.upper()
|
||||
https_link = escape(urlunsplit(address._replace(query=query)))
|
||||
app_link = escape(urlunsplit(address._replace(scheme="fdroidrepos", query=query)))
|
||||
title = escape(english(listing["repo"].get("name")) or address.hostname)
|
||||
packages = listing["packages"]
|
||||
ordered = sorted(packages, key=lambda key: (english(packages[key]["metadata"].get("name")) or key).casefold())
|
||||
cards = "\n".join(app_card(key, packages[key]) for key in ordered)
|
||||
catalog = f'<div class="grid">{cards}</div>' if cards else "<p>No apps yet.</p>"
|
||||
|
||||
page = f"""<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>{title} — F-Droid repository</title>
|
||||
<style>{STYLE}</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="intro">
|
||||
<div>
|
||||
<p class="type">F-Droid repository</p>
|
||||
<h1>{title}</h1>
|
||||
<p class="instruction">Scan the QR code or open this page on your phone.
|
||||
Then add the repository in F-Droid to get app updates.</p>
|
||||
<a class="open" href="{app_link}">Open in F-Droid</a>
|
||||
<details><summary>Add manually</summary>
|
||||
<p>In F-Droid, open Settings → Repositories, tap + and paste this address.</p>
|
||||
<a class="address" href="{https_link}">{https_link}</a>
|
||||
</details>
|
||||
</div>
|
||||
<div class="qr"><img src="/fdroid/repo/index.png" width="180" height="180" alt="Scan to add this repository to F-Droid"></div>
|
||||
</div>
|
||||
<section aria-labelledby="apps">
|
||||
<h2 id="apps">Apps</h2>
|
||||
{catalog}
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
(repo / "index.html").write_text(page, encoding="utf-8")
|
||||
@@ -1,23 +0,0 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: fdroidserver-signing
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
name: vaultwarden-fields
|
||||
kind: ClusterSecretStore
|
||||
target:
|
||||
name: fdroidserver-signing
|
||||
creationPolicy: Owner
|
||||
deletionPolicy: Retain
|
||||
data:
|
||||
- secretKey: keystore.p12
|
||||
remoteRef:
|
||||
key: k8s/fdroidserver/secrets
|
||||
property: keystore-base64
|
||||
decodingStrategy: Base64
|
||||
- secretKey: keystorepass
|
||||
remoteRef:
|
||||
key: k8s/fdroidserver/secrets
|
||||
property: keystorepass
|
||||
@@ -1,31 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: fdroidserver
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: fdroid.hexor.cy
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Exact
|
||||
backend:
|
||||
service:
|
||||
name: fdroidserver-web
|
||||
port:
|
||||
name: http
|
||||
- path: /fdroid/repo
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: fdroidserver-web
|
||||
port:
|
||||
name: http
|
||||
tls:
|
||||
- hosts:
|
||||
- fdroid.hexor.cy
|
||||
secretName: fdroidserver-tls
|
||||
@@ -1,20 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: fdroidserver
|
||||
resources:
|
||||
- storage.yaml
|
||||
- external-secret.yaml
|
||||
- publisher.yaml
|
||||
- web.yaml
|
||||
- ingress.yaml
|
||||
configMapGenerator:
|
||||
- name: fdroidserver-config
|
||||
files:
|
||||
- sources.json
|
||||
- repo.yml
|
||||
- sync_releases.py
|
||||
- catalog.py
|
||||
- name: fdroidserver-metadata
|
||||
files:
|
||||
- metadata/cy.hexor.furumi.yml
|
||||
- metadata/cy.hexor.tsunagi.yml
|
||||
@@ -1,7 +0,0 @@
|
||||
License: WTFPL
|
||||
SourceCode: https://gt.hexor.cy/Furumi/furumi_android
|
||||
IssueTracker: https://gt.hexor.cy/Furumi/furumi_android/issues
|
||||
Name: Furumi
|
||||
Summary: Play music from a Furumi server
|
||||
Description: Stream your music library and download tracks for offline listening.
|
||||
AllowedAPKSigningKeys: a30d218d74337e47ddd3ff4e464f4b507183111502e74e88d7fdac6e84943763
|
||||
@@ -1,7 +0,0 @@
|
||||
License: WTFPL
|
||||
SourceCode: https://github.com/house-of-vanity/tsunagi
|
||||
IssueTracker: https://github.com/house-of-vanity/tsunagi/issues
|
||||
Name: tsunagi
|
||||
Summary: Connect your devices over a mesh VPN
|
||||
Description: Join a private mesh network using a network name and a shared secret.
|
||||
AllowedAPKSigningKeys: 83751404a5a66089700aa310d4433756b992f08320007077a1e292f3a0d7a18f
|
||||
@@ -1,87 +0,0 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: fdroidserver-publish
|
||||
spec:
|
||||
schedule: "*/5 * * * *"
|
||||
concurrencyPolicy: Forbid
|
||||
successfulJobsHistoryLimit: 1
|
||||
failedJobsHistoryLimit: 3
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 1
|
||||
activeDeadlineSeconds: 1800
|
||||
template:
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
restartPolicy: Never
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: master
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
fsGroup: 1000
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: publish
|
||||
image: registry.gitlab.com/fdroid/docker-executable-fdroidserver@sha256:70c3761a76bd30c63911ff1af4f3857573ac43891e6ecf72eac76b19c931e4c0
|
||||
command: [python3, /config/sync_releases.py]
|
||||
workingDir: /data
|
||||
env:
|
||||
- name: HOME
|
||||
value: /tmp
|
||||
- name: ANDROID_HOME
|
||||
value: /opt/android-sdk
|
||||
- name: PATH
|
||||
value: /home/vagrant/fdroidserver:/usr/local/bin:/usr/bin:/bin:/opt/android-sdk/build-tools/32.0.0
|
||||
# fdroid update records its upstream Git revision in its status output.
|
||||
- name: GIT_CONFIG_COUNT
|
||||
value: "1"
|
||||
- name: GIT_CONFIG_KEY_0
|
||||
value: safe.directory
|
||||
- name: GIT_CONFIG_VALUE_0
|
||||
value: /home/vagrant/fdroidserver
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
memory: 1Gi
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
- name: config
|
||||
mountPath: /config
|
||||
readOnly: true
|
||||
- name: metadata
|
||||
mountPath: /config/metadata
|
||||
readOnly: true
|
||||
- name: signing
|
||||
mountPath: /secrets
|
||||
readOnly: true
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /data/k8s/fdroidserver
|
||||
type: Directory
|
||||
- name: config
|
||||
configMap:
|
||||
name: fdroidserver-config
|
||||
- name: metadata
|
||||
configMap:
|
||||
name: fdroidserver-metadata
|
||||
- name: signing
|
||||
secret:
|
||||
secretName: fdroidserver-signing
|
||||
defaultMode: 0440
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
@@ -1,5 +0,0 @@
|
||||
repo_url: https://fdroid.hexor.cy/fdroid/repo
|
||||
repo_name: Hexor
|
||||
repo_description: Android releases from Hexor's projects.
|
||||
repo_keyalias: fdroidrepo
|
||||
archive_older: 0
|
||||
@@ -1,14 +0,0 @@
|
||||
[
|
||||
{
|
||||
"url": "https://gt.hexor.cy/Furumi/furumi_android/",
|
||||
"packageName": "cy.hexor.furumi",
|
||||
"signerSha256": "a30d218d74337e47ddd3ff4e464f4b507183111502e74e88d7fdac6e84943763",
|
||||
"assetPattern": "furumi-android-*.apk"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/house-of-vanity/tsunagi/releases",
|
||||
"packageName": "cy.hexor.tsunagi",
|
||||
"signerSha256": "83751404a5a66089700aa310d4433756b992f08320007077a1e292f3a0d7a18f",
|
||||
"assetPattern": "tsunagi-android-*-arm64-v8a.apk"
|
||||
}
|
||||
]
|
||||
@@ -1,47 +0,0 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: fdroidserver-storage-prepare
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation,HookSucceeded
|
||||
spec:
|
||||
backoffLimit: 2
|
||||
template:
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
restartPolicy: Never
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: master
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: prepare
|
||||
image: docker.io/library/busybox:1.37.0@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec
|
||||
command:
|
||||
- sh
|
||||
- -ec
|
||||
- |
|
||||
mkdir -p /data/public
|
||||
chown 1000:1000 /data /data/public
|
||||
chmod 0700 /data
|
||||
chmod 0755 /data/public
|
||||
if [ "$(readlink /data/public/index.html)" != fdroid/repo/index.html ]; then
|
||||
ln -sfn fdroid/repo/index.html /data/public/index.html
|
||||
fi
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
add: [CHOWN, DAC_OVERRIDE, FOWNER]
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /data/k8s/fdroidserver
|
||||
type: DirectoryOrCreate
|
||||
@@ -1,227 +0,0 @@
|
||||
"""Import signed release APKs and atomically publish an F-Droid repository."""
|
||||
|
||||
import fcntl
|
||||
import fnmatch
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import ssl
|
||||
import subprocess
|
||||
import sys
|
||||
from urllib.error import HTTPError, URLError
|
||||
from urllib.parse import urlsplit
|
||||
from urllib.request import Request, urlopen
|
||||
import uuid
|
||||
|
||||
import qrcode
|
||||
|
||||
from catalog import write_catalog
|
||||
|
||||
|
||||
DATA = Path(os.environ.get("FDROID_DATA_ROOT", "/data")).resolve()
|
||||
CONFIG = Path(os.environ.get("FDROID_CONFIG_DIR", "/config")).resolve()
|
||||
SECRETS = Path(os.environ.get("FDROID_SECRET_DIR", "/secrets")).resolve()
|
||||
PRIVATE = DATA / ".fdroid"
|
||||
SNAPSHOTS = DATA / "public/snapshots"
|
||||
CURRENT = DATA / "public/fdroid/repo"
|
||||
|
||||
|
||||
def latest_url(page):
|
||||
url = urlsplit(page)
|
||||
match = re.fullmatch(r"/([\w.-]+)/([\w.-]+)(?:/releases)?/?", url.path, re.ASCII)
|
||||
if (url.scheme != "https" or not url.hostname or url.username or url.password
|
||||
or url.query or url.fragment or not match
|
||||
or any(part in {".", ".."} for part in match.groups())):
|
||||
raise ValueError(f"Expected an HTTPS repository or releases page: {page}")
|
||||
api = ("https://api.github.com" if url.netloc.lower() == "github.com"
|
||||
else f"https://{url.netloc}/api/v1")
|
||||
owner, project = match.groups()
|
||||
return f"{api}/repos/{owner}/{project}/releases/latest"
|
||||
|
||||
|
||||
def fetch(url):
|
||||
if urlsplit(url).scheme != "https":
|
||||
raise ValueError(f"Expected an HTTPS download: {url}")
|
||||
return urlopen(Request(url, headers={"User-Agent": "homelab-fdroid-sync"}), timeout=60)
|
||||
|
||||
|
||||
def releases(sources, previous):
|
||||
assets = {}
|
||||
unavailable = []
|
||||
for source in sources:
|
||||
package = source["packageName"]
|
||||
if not re.fullmatch(r"[a-zA-Z][\w]*(?:\.[a-zA-Z][\w]*)+", package, re.ASCII):
|
||||
raise ValueError(f"Invalid Android package name: {package}")
|
||||
signer = source["signerSha256"].replace(":", "").lower()
|
||||
if not re.fullmatch(r"[a-f0-9]{64}", signer) or package in assets:
|
||||
raise ValueError(f"Invalid signer or duplicate source for {package}")
|
||||
url = latest_url(source["url"])
|
||||
try:
|
||||
with fetch(url) as response:
|
||||
release = json.load(response)
|
||||
except (HTTPError, URLError, TimeoutError) as exc:
|
||||
print(f"Cannot read latest release for {package}: {exc}", file=sys.stderr)
|
||||
unavailable.append(package)
|
||||
cached = previous.get(package, {})
|
||||
assets[package] = (cached if cached.get("signer") == signer
|
||||
else {"signer": signer, "tag": None, "files": []})
|
||||
continue
|
||||
selected = []
|
||||
for asset in release["assets"]:
|
||||
name = asset["name"]
|
||||
if name.endswith(".apk") and fnmatch.fnmatchcase(name, source.get("assetPattern", "*.apk")):
|
||||
selected.append({k: asset.get(k) for k in (
|
||||
"name", "id", "size", "browser_download_url", "updated_at", "uuid", "digest"
|
||||
)})
|
||||
if release["draft"] or release["prerelease"]:
|
||||
raise ValueError(f"Unexpected non-stable release for {package}")
|
||||
if not selected:
|
||||
print(f"No matching APK in latest release for {package}", file=sys.stderr)
|
||||
assets[package] = {
|
||||
"tag": release["tag_name"], "signer": signer,
|
||||
"files": sorted(selected, key=lambda a: a["name"]),
|
||||
}
|
||||
return assets, unavailable
|
||||
|
||||
|
||||
def config_hash():
|
||||
digest = hashlib.sha256()
|
||||
inputs = [CONFIG / "repo.yml", CONFIG / "sources.json", SECRETS / "keystore.p12",
|
||||
Path(__file__), Path(__file__).with_name("catalog.py")]
|
||||
metadata = CONFIG / "metadata"
|
||||
for root, dirs, files in os.walk(metadata, followlinks=True):
|
||||
# Kubernetes projected volumes also expose hidden links to rotating revisions.
|
||||
dirs[:] = sorted(name for name in dirs if not name.startswith("."))
|
||||
inputs.extend(Path(root) / name for name in sorted(files) if not name.startswith("."))
|
||||
for file in inputs:
|
||||
digest.update(str(file.relative_to(CONFIG) if file.is_relative_to(CONFIG) else file.name).encode())
|
||||
digest.update(b"\0" + hashlib.sha256(file.read_bytes()).digest())
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def verify(apk, package, signer):
|
||||
certs = subprocess.check_output(
|
||||
["apksigner", "verify", "--print-certs", str(apk)], text=True, errors="replace")
|
||||
fingerprints = re.findall(r"^Signer #\d+ certificate SHA-256 digest: ([\da-fA-F]+)$", certs, re.M)
|
||||
if [fp.lower() for fp in fingerprints] != [signer]:
|
||||
raise ValueError(f"Unexpected APK signing certificate for {package}")
|
||||
badging = subprocess.check_output(
|
||||
["aapt", "dump", "badging", str(apk)], text=True, errors="replace")
|
||||
manifest = re.search(r"^package: name='([^']+)' versionCode='(\d+)'", badging, re.M)
|
||||
if not manifest or manifest[1] != package:
|
||||
raise ValueError(f"APK manifest does not identify {package}")
|
||||
return manifest[2]
|
||||
|
||||
|
||||
def import_apk(file, package, signer, work, known):
|
||||
apk = work / "download.apk"
|
||||
digest = hashlib.sha256()
|
||||
with fetch(file["browser_download_url"]) as response, apk.open("wb") as output:
|
||||
while block := response.read(1024 * 1024):
|
||||
digest.update(block)
|
||||
output.write(block)
|
||||
sha = digest.hexdigest()
|
||||
if apk.stat().st_size != file["size"] or (file["digest"] and file["digest"] != "sha256:" + sha):
|
||||
raise ValueError(f"Release asset size or digest mismatch: {file['name']}")
|
||||
version = verify(apk, package, signer)
|
||||
name = f"{package}_{version}.apk"
|
||||
if name in known and known[name] != sha:
|
||||
raise ValueError(f"{name} already has different content; publish a higher versionCode")
|
||||
if name not in known:
|
||||
apk.rename(work / "repo" / name)
|
||||
known[name] = sha
|
||||
print(f"Verified {file['name']} as {name}", flush=True)
|
||||
|
||||
|
||||
def index(work, known):
|
||||
shutil.copytree(CONFIG / "metadata", work / "metadata", ignore=shutil.ignore_patterns(".*"))
|
||||
config = (CONFIG / "repo.yml").read_text().rstrip() + "\n"
|
||||
config += f"keystore: {json.dumps(str(SECRETS / 'keystore.p12'))}\n"
|
||||
config += "keystorepass: {env: FDROID_PASS}\nkeypass: {env: FDROID_PASS}\n"
|
||||
path = work / "config.yml"
|
||||
path.write_text(config)
|
||||
path.chmod(0o600)
|
||||
password = (SECRETS / "keystorepass").read_text().rstrip("\r\n")
|
||||
subprocess.run(["fdroid", "update"], cwd=work, check=True, env={**os.environ, "FDROID_PASS": password})
|
||||
repo = work / "repo"
|
||||
listing = json.loads((repo / "index-v2.json").read_text())
|
||||
published = {version["file"]["name"].lstrip("/"): version["file"]["sha256"]
|
||||
for package in listing["packages"].values() for version in package["versions"].values()}
|
||||
if known != published:
|
||||
raise ValueError("Generated F-Droid index does not contain the verified APK set")
|
||||
certs = subprocess.check_output(
|
||||
["keytool", "-printcert", "-rfc", "-jarfile", str(repo / "entry.jar")], text=True)
|
||||
leaf = re.search(r"-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----", certs, re.S)
|
||||
if not leaf:
|
||||
raise ValueError("Missing signing certificate in F-Droid entry.jar")
|
||||
fingerprint = hashlib.sha256(ssl.PEM_cert_to_DER_cert(leaf[0])).hexdigest().upper()
|
||||
address = listing["repo"]["address"].rstrip("/")
|
||||
qrcode.make(f"{address}?fingerprint={fingerprint}").save(repo / "index.png")
|
||||
write_catalog(repo, listing, fingerprint)
|
||||
|
||||
|
||||
def sync():
|
||||
current = CURRENT.resolve(strict=True) if CURRENT.is_symlink() else None
|
||||
state = json.loads((PRIVATE / f"{current.name}.json").read_text()) if current else {}
|
||||
previous_assets = state.get("assets", {})
|
||||
assets, unavailable = releases(json.loads((CONFIG / "sources.json").read_text()), previous_assets)
|
||||
if not current and not any(release["files"] for release in assets.values()):
|
||||
raise RuntimeError("No release APK is available for initial publication")
|
||||
config = config_hash()
|
||||
if state.get("assets") == assets and state.get("config") == config:
|
||||
print("Published releases and repository configuration are up to date")
|
||||
return unavailable
|
||||
|
||||
# A killed Job can leave a private staging directory behind. The lock excludes live writers.
|
||||
work = PRIVATE / "work"
|
||||
if work.exists():
|
||||
shutil.rmtree(work)
|
||||
work.mkdir(mode=0o700)
|
||||
repo = work / "repo"
|
||||
repo.mkdir()
|
||||
try:
|
||||
# Preserve previous versions only while their source and signing certificate are trusted.
|
||||
trusted = {package for package, release in assets.items()
|
||||
if previous_assets.get(package, {}).get("signer") == release["signer"]}
|
||||
known = {name: sha for name, sha in state.get("apks", {}).items()
|
||||
if name.rsplit("_", 1)[0] in trusted}
|
||||
for name in known:
|
||||
os.link(current / name, repo / name)
|
||||
if current:
|
||||
# fdroid reads the previous v2 index to preserve first-seen timestamps.
|
||||
shutil.copyfile(current / "index-v2.json", repo / "index-v2.json")
|
||||
for package, release in assets.items():
|
||||
previous = previous_assets.get(package, {})
|
||||
for file in release["files"]:
|
||||
if previous.get("signer") != release["signer"] or file not in previous.get("files", []):
|
||||
import_apk(file, package, release["signer"], work, known)
|
||||
index(work, known)
|
||||
generation = uuid.uuid4().hex
|
||||
next_state = {"assets": assets, "config": config, "apks": known}
|
||||
(PRIVATE / f"{generation}.json").write_text(json.dumps(next_state))
|
||||
repo.rename(SNAPSHOTS / generation)
|
||||
link = work / "next"
|
||||
link.symlink_to(f"../snapshots/{generation}", target_is_directory=True)
|
||||
os.replace(link, CURRENT)
|
||||
print(f"Published {len(known)} APK(s) to /fdroid/repo", flush=True)
|
||||
for old in SNAPSHOTS.iterdir():
|
||||
if old.name != generation and (current is None or old.name != current.name):
|
||||
shutil.rmtree(old)
|
||||
(PRIVATE / f"{old.name}.json").unlink(missing_ok=True)
|
||||
finally:
|
||||
shutil.rmtree(work)
|
||||
return unavailable
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
PRIVATE.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
SNAPSHOTS.mkdir(parents=True, exist_ok=True)
|
||||
CURRENT.parent.mkdir(parents=True, exist_ok=True)
|
||||
with (PRIVATE / "lock").open("a") as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX)
|
||||
unavailable = sync()
|
||||
if unavailable:
|
||||
sys.exit("Release APIs unavailable, will retry: " + ", ".join(unavailable))
|
||||
@@ -1,68 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: fdroidserver-web
|
||||
spec:
|
||||
replicas: 1
|
||||
progressDeadlineSeconds: 1800
|
||||
selector:
|
||||
matchLabels:
|
||||
app: fdroidserver-web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: fdroidserver-web
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: master
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
runAsGroup: 65534
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: httpd
|
||||
image: docker.io/library/busybox:1.37.0@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec
|
||||
command: [httpd, -f, -p, "8080", -h, /www]
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /fdroid/repo/entry.jar
|
||||
port: http
|
||||
periodSeconds: 10
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 8Mi
|
||||
limits:
|
||||
memory: 32Mi
|
||||
volumeMounts:
|
||||
- name: public
|
||||
mountPath: /www
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: public
|
||||
hostPath:
|
||||
path: /data/k8s/fdroidserver/public
|
||||
type: Directory
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: fdroidserver-web
|
||||
spec:
|
||||
selector:
|
||||
app: fdroidserver-web
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: http
|
||||
@@ -1,50 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: furumi-player
|
||||
labels:
|
||||
app: furumi-player
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate # the library is a hostPath on a single node
|
||||
selector:
|
||||
matchLabels:
|
||||
app: furumi-player
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: furumi-player
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
spec:
|
||||
# The music library lives on this node's /data (LVM raid, not replicated).
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: music
|
||||
containers:
|
||||
- name: furumi-player
|
||||
image: ultradesu/furumusic:latest
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: FURU_DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: furumi-creds
|
||||
key: PG_STRING
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8000
|
||||
volumeMounts:
|
||||
- name: library
|
||||
mountPath: /media
|
||||
- name: inbox
|
||||
mountPath: /inbox
|
||||
volumes:
|
||||
- name: library
|
||||
hostPath:
|
||||
path: /data/furumi/library
|
||||
type: Directory
|
||||
- name: inbox
|
||||
hostPath:
|
||||
path: /data/furumi/inbox
|
||||
type: Directory
|
||||
@@ -1,24 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: furumi
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: music.hexor.cy
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: furumi-player
|
||||
port:
|
||||
number: 8000
|
||||
tls:
|
||||
- secretName: furumi-tls
|
||||
hosts:
|
||||
- music.hexor.cy
|
||||
@@ -1,9 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- secrets.yaml
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- servicemonitor.yaml
|
||||
- ingress.yaml
|
||||
@@ -1,47 +0,0 @@
|
||||
# Read-only access to the furumi-db Secret in the psql namespace
|
||||
# (see postgresql/databases/furumi.yaml for the other half).
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: db-credentials-reader
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: SecretStore
|
||||
metadata:
|
||||
name: psql-credentials
|
||||
spec:
|
||||
provider:
|
||||
kubernetes:
|
||||
remoteNamespace: psql
|
||||
server:
|
||||
caProvider:
|
||||
type: ConfigMap
|
||||
name: kube-root-ca.crt
|
||||
key: ca.crt
|
||||
auth:
|
||||
serviceAccount:
|
||||
name: db-credentials-reader
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: furumi-creds
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
kind: SecretStore
|
||||
name: psql-credentials
|
||||
target:
|
||||
name: furumi-creds
|
||||
template:
|
||||
data:
|
||||
PG_STRING: "postgresql://{{ .username }}:{{ .password }}@main-rw.psql.svc:5432/furumi"
|
||||
data:
|
||||
- secretKey: username
|
||||
remoteRef:
|
||||
key: furumi-db
|
||||
property: username
|
||||
- secretKey: password
|
||||
remoteRef:
|
||||
key: furumi-db
|
||||
property: password
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: furumi-player
|
||||
labels:
|
||||
app: furumi-player
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: furumi-player
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
port: 8000
|
||||
targetPort: 8000
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: furumi-player
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: furumi-player
|
||||
endpoints:
|
||||
- port: http
|
||||
path: /metrics
|
||||
interval: 30s
|
||||
scrapeTimeout: 10s
|
||||
@@ -1,12 +0,0 @@
|
||||
# k8s-secrets
|
||||
|
||||
The `k8s-secrets` Argo CD Application reads this directory through
|
||||
`core-state/values.yaml` and deploys into namespace `k8s-secret`.
|
||||
|
||||
External Secrets loads the `k8s/openai/creds` Vaultwarden item into
|
||||
`openai-creds`. The reader at `pass.hexor.cy` can only read that Secret and is
|
||||
protected by the Keycloak forward-auth proxy. Its access policy is managed in
|
||||
`terraform/keycloak/terraform.tfvars`.
|
||||
|
||||
The Kubernetes resource names and namespace match the former deployment so
|
||||
Argo CD can switch the source path without replacing the service or certificate.
|
||||
@@ -1,32 +0,0 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: openai-creds
|
||||
spec:
|
||||
refreshInterval: 5m
|
||||
secretStoreRef:
|
||||
name: vaultwarden-login
|
||||
kind: ClusterSecretStore
|
||||
target:
|
||||
name: openai-creds
|
||||
creationPolicy: Owner
|
||||
deletionPolicy: Retain
|
||||
template:
|
||||
type: Opaque
|
||||
data:
|
||||
USER: "{{ .user }}"
|
||||
PASS: "{{ .pass }}"
|
||||
TOTP: "{{ .totp }}"
|
||||
data:
|
||||
- secretKey: user
|
||||
remoteRef:
|
||||
key: k8s/openai/creds
|
||||
property: login.username
|
||||
- secretKey: pass
|
||||
remoteRef:
|
||||
key: k8s/openai/creds
|
||||
property: login.password
|
||||
- secretKey: totp
|
||||
remoteRef:
|
||||
key: k8s/openai/creds
|
||||
property: login.totp
|
||||
@@ -1,38 +0,0 @@
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: auth-proxy
|
||||
spec:
|
||||
forwardAuth:
|
||||
address: http://auth-proxy.keycloak.svc:80/auth
|
||||
trustForwardHeader: false
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: secret-reader
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`pass.hexor.cy`)
|
||||
kind: Rule
|
||||
middlewares:
|
||||
- name: auth-proxy
|
||||
services:
|
||||
- name: secret-reader
|
||||
port: 80
|
||||
tls:
|
||||
secretName: secret-reader-tls
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: secret-reader-tls
|
||||
spec:
|
||||
secretName: secret-reader-tls
|
||||
issuerRef:
|
||||
name: letsencrypt
|
||||
kind: ClusterIssuer
|
||||
dnsNames:
|
||||
- pass.hexor.cy
|
||||
@@ -1,7 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: k8s-secret
|
||||
resources:
|
||||
- external-secret.yaml
|
||||
- reader.yaml
|
||||
- ingress.yaml
|
||||
@@ -1,109 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: secret-reader
|
||||
labels:
|
||||
app: secret-reader
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: secret-reader
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
resourceNames: ["openai-creds"]
|
||||
verbs: ["get"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: secret-reader
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: secret-reader
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: secret-reader
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: secret-reader
|
||||
labels:
|
||||
app: secret-reader
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: secret-reader
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: secret-reader
|
||||
spec:
|
||||
serviceAccountName: secret-reader
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: secret-reader
|
||||
image: ultradesu/k8s-secrets:0.2.2@sha256:f206942d21ca9dcd131d6e19ba26cc17671815919217aef657b30a9f85854778
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- --secrets
|
||||
- openai-creds
|
||||
- --namespace
|
||||
- k8s-secret
|
||||
- --port
|
||||
- "3000"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
env:
|
||||
- name: RUST_LOG
|
||||
value: info
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
cpu: 150m
|
||||
memory: 128Mi
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: secret-reader
|
||||
labels:
|
||||
app: secret-reader
|
||||
spec:
|
||||
selector:
|
||||
app: secret-reader
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: http
|
||||
@@ -1,18 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: llamacpp-config
|
||||
data:
|
||||
LLAMA_CACHE: /models
|
||||
LLAMA_ARG_HOST: 0.0.0.0
|
||||
LLAMA_ARG_PORT: "8080"
|
||||
# The model is chosen here: <hf-user>/<repo>:<quant>. It is downloaded into
|
||||
# /models on first start; changing it restarts the pod (reloader).
|
||||
#LLAMA_ARG_HF_REPO: "unsloth/Qwen3.8-27B-GGUF:UD-Q6_K"
|
||||
LLAMA_ARG_HF_REPO: "unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q6_K"
|
||||
LLAMA_ARG_CTX_SIZE: "131072"
|
||||
LLAMA_ARG_N_GPU_LAYERS: all
|
||||
LLAMA_ARG_FLASH_ATTN: "on"
|
||||
LLAMA_ARG_FIT: "on"
|
||||
# Strix Halo: mmap-ed weights hang or corrupt on ROCm; read them directly.
|
||||
LLAMA_ARG_LOAD_MODE: dio
|
||||
@@ -1,76 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: llamacpp
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
labels:
|
||||
app: llamacpp
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate # one GPU, one pod
|
||||
selector:
|
||||
matchLabels:
|
||||
app: llamacpp
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: llamacpp
|
||||
spec:
|
||||
dnsPolicy: Default
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: internal
|
||||
workload/ai: "true"
|
||||
tolerations:
|
||||
- key: workload
|
||||
operator: Equal
|
||||
value: ai
|
||||
effect: NoSchedule
|
||||
containers:
|
||||
- name: llamacpp
|
||||
image: ghcr.io/ggml-org/llama.cpp:server-rocm-b11434
|
||||
imagePullPolicy: IfNotPresent
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: llamacpp-config
|
||||
env:
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: llamacpp-hf-token
|
||||
key: token
|
||||
optional: true
|
||||
# hipBLASLt gives the biggest prompt-processing gain on ROCm 7.x.
|
||||
- name: ROCBLAS_USE_HIPBLASLT
|
||||
value: "1"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
protocol: TCP
|
||||
resources:
|
||||
limits:
|
||||
amd.com/gpu: 1
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
failureThreshold: 180 # first start downloads the model
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
volumeMounts:
|
||||
- name: models
|
||||
mountPath: /models
|
||||
volumes:
|
||||
- name: models
|
||||
hostPath:
|
||||
path: /var/lib/llamacpp/models
|
||||
type: DirectoryOrCreate
|
||||
@@ -1,7 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- configmap.yaml
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -1,15 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: llamacpp
|
||||
labels:
|
||||
app: llamacpp
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: llamacpp
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
@@ -1,561 +0,0 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nginx-config
|
||||
namespace: minecraft
|
||||
data:
|
||||
nginx.conf: |
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
# Custom 502 error page with auto-refresh
|
||||
error_page 502 /502.html;
|
||||
location = /502.html {
|
||||
internal;
|
||||
return 200 '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Server Loading</title><style>body{font-family:Arial,sans-serif;text-align:center;margin-top:100px;background:#f0f0f0}h1{color:#333}p{color:#666;font-size:18px}</style></head><body><h1>Server is loading probably...</h1><p>Please wait a moment and try refreshing the page.</p><script>setTimeout(function(){window.location.reload();}, 10000);</script></body></html>';
|
||||
add_header Content-Type text/html;
|
||||
}
|
||||
|
||||
# Main location - proxy to Minecraft Dynmap
|
||||
location / {
|
||||
# Proxy configuration for Dynmap server
|
||||
proxy_pass http://localhost:8123;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Inject user authentication meta tag into HTML head
|
||||
sub_filter '<head>' '<head><meta name="remote-user" content="$http_x_authentik_username">';
|
||||
|
||||
# Replace default Dynmap title with custom server name
|
||||
sub_filter 'Minecraft Dynamic Map' "Hexor's MC server";
|
||||
|
||||
# Inject custom script before closing body tag
|
||||
sub_filter "</body>" '<script src="/clients/inject.js"></script></body>';
|
||||
|
||||
# Apply sub_filter replacements globally (not just once)
|
||||
sub_filter_once off;
|
||||
}
|
||||
|
||||
# Serve inject.js and .ps1 scripts inline (no forced download)
|
||||
location = /clients/inject.js {
|
||||
alias /mc/clients/inject.js;
|
||||
default_type application/javascript;
|
||||
}
|
||||
|
||||
location ~ ^/clients/(.+\.ps1)$ {
|
||||
alias /mc/clients/$1;
|
||||
default_type text/plain;
|
||||
}
|
||||
|
||||
# Static file serving for client downloads
|
||||
location /clients/ {
|
||||
alias /mc/clients/;
|
||||
sendfile on; # Enable efficient file serving
|
||||
add_header Content-Disposition "attachment"; # Force download
|
||||
autoindex on; # Enable directory listing
|
||||
gzip off; # Disable compression for downloads
|
||||
chunked_transfer_encoding off; # Disable chunked encoding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: client-scripts
|
||||
namespace: minecraft
|
||||
data:
|
||||
inject.js: |
|
||||
(function() {
|
||||
function getUsername() {
|
||||
var metas = document.querySelectorAll("meta");
|
||||
for (var i = 0; i < metas.length; i++) {
|
||||
if (metas[i].getAttribute("name") === "remote-user") {
|
||||
return metas[i].getAttribute("content");
|
||||
}
|
||||
}
|
||||
var jwt = document.cookie.split("; ").find(function(row) {
|
||||
return row.startsWith("authentik_session=");
|
||||
});
|
||||
if (jwt) {
|
||||
try {
|
||||
var token = jwt.split("=")[1];
|
||||
var payload = JSON.parse(atob(token.split(".")[1]));
|
||||
return payload.sub || payload.username || "web-user";
|
||||
} catch(e) {}
|
||||
}
|
||||
return "web-user";
|
||||
}
|
||||
|
||||
var username = getUsername();
|
||||
console.log("Username found:", username);
|
||||
|
||||
if (username && username !== "web-user" &&
|
||||
window.location.search.indexOf("playername=") === -1) {
|
||||
var currentUrl = new URL(window.location.href);
|
||||
currentUrl.searchParams.set("playername", username);
|
||||
console.log("Redirecting to:", currentUrl.href);
|
||||
window.location.href = currentUrl.href;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// User block
|
||||
var userBlock = document.createElement("div");
|
||||
userBlock.style.cssText = "background-color:#CEC6CB;color:black;padding:8px;text-align:center;font-size:medium;border-radius:4px;position:absolute;top:10px;right:150px;max-width:200px;";
|
||||
userBlock.innerHTML = "Logged in as: <b>" + username + "</b>";
|
||||
document.body.appendChild(userBlock);
|
||||
|
||||
// Info block
|
||||
var infoBlock = document.createElement("p");
|
||||
infoBlock.style.cssText = "background-color:#CEC6CB;color:black;padding:10px;text-align:center;font-size:large;display:inline-block;border-radius:4px;position:absolute;top:10px;left:150px;";
|
||||
infoBlock.innerHTML = 'GEYMERSKIY SOYUZ Server<br>'
|
||||
+ 'Get <a href="https://github.com/PrismLauncher/PrismLauncher/releases/tag/8.4">Prism Launcher</a> '
|
||||
+ 'and <a href="/clients/1.12.2.zip">client.zip</a> for this server. '
|
||||
+ 'Server address <b>minecraft.hexor.cy:30565</b><br>'
|
||||
+ 'Requires <a href="https://www.java.com/en/download/manual.jsp">Java 8</a><br><br>'
|
||||
+ '<a href="#" id="showInstallBtn" style="color:black;text-decoration:underline;">Windows Install Script</a>';
|
||||
document.body.appendChild(infoBlock);
|
||||
|
||||
// Modal
|
||||
var modal = document.createElement("div");
|
||||
modal.id = "installModal";
|
||||
modal.style.cssText = "display:none;position:fixed;z-index:1000;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,0.5);";
|
||||
modal.innerHTML = '<div style="background-color:#CEC6CB;margin:15% auto;padding:10px;border-radius:4px;width:70%;max-width:500px;text-align:center;color:black;font-size:large;">'
|
||||
+ '<h3 style="margin-top:0;color:black;">Windows Installation</h3>'
|
||||
+ '<p style="color:black;">Copy and paste this command into PowerShell:</p>'
|
||||
+ '<textarea id="scriptCommand" readonly style="width:90%;height:60px;font-family:monospace;padding:8px;border:1px solid #888;border-radius:4px;resize:none;background-color:white;color:black;"></textarea>'
|
||||
+ '<br><br>'
|
||||
+ '<button id="copyButton" style="background-color:#CEC6CB;color:black;padding:10px 15px;border:1px solid #888;border-radius:4px;cursor:pointer;margin-right:10px;font-size:large;">Copy</button>'
|
||||
+ '<button id="closeButton" style="background-color:#CEC6CB;color:black;padding:10px 15px;border:1px solid #888;border-radius:4px;cursor:pointer;font-size:large;">Close</button>'
|
||||
+ '</div>';
|
||||
document.body.appendChild(modal);
|
||||
|
||||
// Generate PowerShell command with username
|
||||
function buildPsCommand() {
|
||||
var d = "$";
|
||||
var q = "'";
|
||||
return d + 'f="' + d + 'env:TEMP\\mc-install.ps1"; iwr -useb https://minecraft.hexor.cy/clients/win-install.ps1 -OutFile '
|
||||
+ d + 'f; powershell -ExecutionPolicy Bypass -File ' + d + 'f -Username ' + q + username + q + '; Remove-Item ' + d + 'f';
|
||||
}
|
||||
|
||||
document.getElementById("showInstallBtn").addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
modal.style.display = "block";
|
||||
document.getElementById("scriptCommand").value = buildPsCommand();
|
||||
});
|
||||
|
||||
document.getElementById("closeButton").addEventListener("click", function() {
|
||||
modal.style.display = "none";
|
||||
});
|
||||
|
||||
document.getElementById("copyButton").addEventListener("click", function() {
|
||||
var textarea = document.getElementById("scriptCommand");
|
||||
textarea.select();
|
||||
textarea.setSelectionRange(0, 99999);
|
||||
document.execCommand("copy");
|
||||
var btn = document.getElementById("copyButton");
|
||||
btn.style.borderColor = "#4CAF50";
|
||||
setTimeout(function() { btn.style.borderColor = "#888"; }, 2000);
|
||||
});
|
||||
|
||||
modal.addEventListener("click", function(event) {
|
||||
if (event.target === modal) {
|
||||
modal.style.display = "none";
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
win-install.ps1: |
|
||||
# Game Setup Script for PrismLauncher and Minecraft Client
|
||||
# This script downloads and configures PrismLauncher with Hexor client
|
||||
|
||||
param(
|
||||
[string]$Username = "",
|
||||
[string]$InstallPath = "$env:USERPROFILE\Games\PrismLauncher"
|
||||
)
|
||||
|
||||
# Enable TLS 1.2 for downloads
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
# Function to write colored log messages
|
||||
function Write-Log {
|
||||
param(
|
||||
[string]$Message,
|
||||
[string]$Level = "INFO"
|
||||
)
|
||||
|
||||
switch ($Level) {
|
||||
"INFO" {
|
||||
Write-Host "[" -NoNewline
|
||||
Write-Host "INFO" -ForegroundColor Blue -NoNewline
|
||||
Write-Host "] $Message"
|
||||
}
|
||||
"WARN" {
|
||||
Write-Host "[" -NoNewline
|
||||
Write-Host "WARN" -ForegroundColor Yellow -NoNewline
|
||||
Write-Host "] $Message"
|
||||
}
|
||||
"ERROR" {
|
||||
Write-Host "[" -NoNewline
|
||||
Write-Host "ERROR" -ForegroundColor Red -NoNewline
|
||||
Write-Host "] $Message"
|
||||
}
|
||||
"SUCCESS" {
|
||||
Write-Host "[" -NoNewline
|
||||
Write-Host "SUCCESS" -ForegroundColor Green -NoNewline
|
||||
Write-Host "] $Message"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Function to download file with progress
|
||||
function Download-File {
|
||||
param(
|
||||
[string]$Url,
|
||||
[string]$OutputPath
|
||||
)
|
||||
|
||||
try {
|
||||
Write-Log "Downloading from: $Url"
|
||||
Write-Log "Saving to: $OutputPath"
|
||||
|
||||
if (Test-Path $OutputPath) {
|
||||
Remove-Item $OutputPath -Force
|
||||
Write-Log "Removed existing file to avoid corruption" "WARN"
|
||||
}
|
||||
|
||||
$webClient = New-Object System.Net.WebClient
|
||||
$webClient.DownloadFile($Url, $OutputPath)
|
||||
|
||||
if (Test-Path $OutputPath) {
|
||||
$fileSize = (Get-Item $OutputPath).Length
|
||||
Write-Log "Download completed successfully ($fileSize bytes)" "SUCCESS"
|
||||
return $true
|
||||
} else {
|
||||
Write-Log "Download failed - file not found" "ERROR"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Log "Download failed: $($_.Exception.Message)" "ERROR"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Function to extract ZIP archive
|
||||
function Extract-Archive {
|
||||
param(
|
||||
[string]$ArchivePath,
|
||||
[string]$DestinationPath
|
||||
)
|
||||
|
||||
try {
|
||||
Write-Log "Extracting archive: $ArchivePath"
|
||||
Write-Log "Destination: $DestinationPath"
|
||||
|
||||
if (!(Test-Path $ArchivePath)) {
|
||||
Write-Log "Archive file not found: $ArchivePath" "ERROR"
|
||||
return $false
|
||||
}
|
||||
|
||||
$fileSize = (Get-Item $ArchivePath).Length
|
||||
if ($fileSize -lt 1000) {
|
||||
Write-Log "Archive file too small ($fileSize bytes), probably corrupted" "ERROR"
|
||||
return $false
|
||||
}
|
||||
|
||||
if (!(Test-Path $DestinationPath)) {
|
||||
New-Item -ItemType Directory -Path $DestinationPath -Force | Out-Null
|
||||
}
|
||||
|
||||
$existingFiles = Get-ChildItem -Path $DestinationPath -File | Where-Object { $_.Extension -ne ".zip" }
|
||||
$existingDirs = Get-ChildItem -Path $DestinationPath -Directory
|
||||
|
||||
if ($existingFiles.Count -gt 0 -or $existingDirs.Count -gt 0) {
|
||||
Write-Log "Clearing existing files in destination directory" "WARN"
|
||||
$existingFiles | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||
$existingDirs | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
try {
|
||||
$zip = [System.IO.Compression.ZipFile]::OpenRead($ArchivePath)
|
||||
$entryCount = $zip.Entries.Count
|
||||
$zip.Dispose()
|
||||
Write-Log "ZIP file validated ($entryCount entries)" "SUCCESS"
|
||||
}
|
||||
catch {
|
||||
Write-Log "ZIP file validation failed: $($_.Exception.Message)" "ERROR"
|
||||
return $false
|
||||
}
|
||||
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($ArchivePath, $DestinationPath)
|
||||
|
||||
Write-Log "Archive extracted successfully" "SUCCESS"
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Log "Archive extraction failed: $($_.Exception.Message)" "ERROR"
|
||||
|
||||
if (Test-Path $ArchivePath) {
|
||||
Write-Log "Removing potentially corrupted archive file" "WARN"
|
||||
Remove-Item $ArchivePath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Function to check Java installation
|
||||
function Check-JavaInstallation {
|
||||
try {
|
||||
$javaVersion = java -version 2>&1 | Select-String "version"
|
||||
if ($javaVersion) {
|
||||
Write-Log "Java is installed: $($javaVersion.ToString().Trim())" "SUCCESS"
|
||||
return $true
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Log "Java is not installed or not in PATH" "WARN"
|
||||
Write-Log "Please download Java from: https://www.java.com/en/download/manual.jsp" "WARN"
|
||||
Write-Log "Look for 'Windows Offline (64-bit)' version" "WARN"
|
||||
|
||||
$response = Read-Host "Do you want to continue without Java? (y/n)"
|
||||
if ($response -eq 'y' -or $response -eq 'Y') {
|
||||
Write-Log "Continuing without Java verification" "WARN"
|
||||
return $true
|
||||
} else {
|
||||
Write-Log "Installation cancelled. Please install Java first." "ERROR"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Function to generate a random hex string (UUID-like without dashes)
|
||||
function New-RandomHexId {
|
||||
param([int]$Length = 32)
|
||||
$bytes = New-Object byte[] ($Length / 2)
|
||||
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
|
||||
$rng.GetBytes($bytes)
|
||||
$rng.Dispose()
|
||||
return ($bytes | ForEach-Object { $_.ToString("x2") }) -join ''
|
||||
}
|
||||
|
||||
# Function to create accounts.json file with offline account
|
||||
function Create-AccountsFile {
|
||||
param(
|
||||
[string]$TargetPath,
|
||||
[string]$PlayerName
|
||||
)
|
||||
|
||||
$accountsPath = Join-Path $TargetPath "accounts.json"
|
||||
$profileId = New-RandomHexId -Length 32
|
||||
$clientToken = New-RandomHexId -Length 32
|
||||
$iat = [int][double]::Parse((Get-Date -UFormat %s))
|
||||
|
||||
$accountsObj = @{
|
||||
accounts = @(
|
||||
@{
|
||||
entitlement = @{
|
||||
canPlayMinecraft = $true
|
||||
ownsMinecraft = $true
|
||||
}
|
||||
"msa-client-id" = ""
|
||||
type = "MSA"
|
||||
},
|
||||
@{
|
||||
active = $true
|
||||
entitlement = @{
|
||||
canPlayMinecraft = $true
|
||||
ownsMinecraft = $true
|
||||
}
|
||||
profile = @{
|
||||
capes = @()
|
||||
id = $profileId
|
||||
name = $PlayerName
|
||||
skin = @{
|
||||
id = ""
|
||||
url = ""
|
||||
variant = ""
|
||||
}
|
||||
}
|
||||
type = "Offline"
|
||||
ygg = @{
|
||||
extra = @{
|
||||
clientToken = $clientToken
|
||||
userName = $PlayerName
|
||||
}
|
||||
iat = $iat
|
||||
token = "0"
|
||||
}
|
||||
}
|
||||
)
|
||||
formatVersion = 3
|
||||
}
|
||||
|
||||
try {
|
||||
$accountsObj | ConvertTo-Json -Depth 10 | Out-File -FilePath $accountsPath -Encoding UTF8
|
||||
Write-Log "Created accounts.json at: $accountsPath" "SUCCESS"
|
||||
Write-Log "Player name: $PlayerName" "SUCCESS"
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Log "Failed to create accounts.json: $($_.Exception.Message)" "ERROR"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Main installation process
|
||||
Write-Log "Starting PrismLauncher and Minecraft client setup"
|
||||
Write-Log "Player name: $Username"
|
||||
Write-Log "Installation path: $InstallPath"
|
||||
|
||||
# Create installation directory and clear if exists (but keep ZIP files)
|
||||
if (Test-Path $InstallPath) {
|
||||
Write-Log "Installation directory exists, clearing contents" "WARN"
|
||||
$existingFiles = Get-ChildItem -Path $InstallPath -File | Where-Object { $_.Extension -ne ".zip" }
|
||||
$existingDirs = Get-ChildItem -Path $InstallPath -Directory
|
||||
|
||||
$existingFiles | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||
$existingDirs | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||
} else {
|
||||
New-Item -ItemType Directory -Path $InstallPath -Force | Out-Null
|
||||
Write-Log "Created installation directory: $InstallPath"
|
||||
}
|
||||
|
||||
# Step 1: Download PrismLauncher
|
||||
Write-Log "Step 1: Downloading PrismLauncher..."
|
||||
$launcherUrl = "https://github.com/PrismLauncher/PrismLauncher/releases/download/8.4/PrismLauncher-Windows-MSVC-Portable-8.4.zip"
|
||||
$launcherZip = Join-Path $InstallPath "PrismLauncher-8.4.zip"
|
||||
$launcherExtractPath = Join-Path $InstallPath "PrismLauncher-Windows-MSVC-Portable-8.4"
|
||||
|
||||
if (!(Download-File -Url $launcherUrl -OutputPath $launcherZip)) {
|
||||
Write-Log "Failed to download PrismLauncher. Exiting." "ERROR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 2: Extract PrismLauncher
|
||||
Write-Log "Step 2: Extracting PrismLauncher..."
|
||||
if (!(Extract-Archive -ArchivePath $launcherZip -DestinationPath $InstallPath)) {
|
||||
Write-Log "Failed to extract PrismLauncher. Exiting." "ERROR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Find the actual extracted directory
|
||||
$extractedDirs = Get-ChildItem -Path $InstallPath -Directory | Where-Object { $_.Name -like "*PrismLauncher*" }
|
||||
if ($extractedDirs.Count -gt 0) {
|
||||
$launcherExtractPath = $extractedDirs[0].FullName
|
||||
Write-Log "Found PrismLauncher directory: $launcherExtractPath" "SUCCESS"
|
||||
} else {
|
||||
Write-Log "Could not find extracted PrismLauncher directory. Checking for direct extraction..." "WARN"
|
||||
$prismExe = Join-Path $InstallPath "prismlauncher.exe"
|
||||
if (Test-Path $prismExe) {
|
||||
$launcherExtractPath = $InstallPath
|
||||
Write-Log "PrismLauncher extracted directly to: $launcherExtractPath" "SUCCESS"
|
||||
} else {
|
||||
Write-Log "Failed to locate PrismLauncher files. Exiting." "ERROR"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Step 3: Create accounts.json in InstallPath (only if username provided)
|
||||
if ($Username -and $Username -ne "web-user") {
|
||||
Write-Log "Step 3: Creating accounts configuration for $Username..."
|
||||
if (!(Create-AccountsFile -TargetPath $InstallPath -PlayerName $Username)) {
|
||||
Write-Log "Failed to create accounts.json. Exiting." "ERROR"
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Log "Step 3: No username provided, skipping accounts.json creation" "WARN"
|
||||
}
|
||||
|
||||
# Step 4: Check Java installation
|
||||
Write-Log "Step 4: Checking Java installation..."
|
||||
if (!(Check-JavaInstallation)) {
|
||||
Write-Log "Java check failed. Exiting." "ERROR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 5: Download Minecraft client
|
||||
Write-Log "Step 5: Downloading Minecraft client..."
|
||||
$minecraftUrl = "https://minecraft.hexor.cy/clients/1.12.2.zip"
|
||||
$minecraftZip = Join-Path $InstallPath "minecraft-1.12.2.zip"
|
||||
$instancesPath = Join-Path $launcherExtractPath "instances"
|
||||
$hexorPath = Join-Path $instancesPath "Hexor"
|
||||
|
||||
if (!(Download-File -Url $minecraftUrl -OutputPath $minecraftZip)) {
|
||||
Write-Log "Failed to download Minecraft client. Exiting." "ERROR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 6: Create instances directory and extract Minecraft client
|
||||
Write-Log "Step 6: Setting up Minecraft client..."
|
||||
if (!(Test-Path $instancesPath)) {
|
||||
New-Item -ItemType Directory -Path $instancesPath -Force | Out-Null
|
||||
Write-Log "Created instances directory"
|
||||
}
|
||||
|
||||
if (!(Test-Path $hexorPath)) {
|
||||
New-Item -ItemType Directory -Path $hexorPath -Force | Out-Null
|
||||
Write-Log "Created Hexor instance directory"
|
||||
}
|
||||
|
||||
if (!(Extract-Archive -ArchivePath $minecraftZip -DestinationPath $hexorPath)) {
|
||||
Write-Log "Failed to extract Minecraft client. Exiting." "ERROR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 7: Cleanup temporary files
|
||||
Write-Log "Step 7: Cleaning up temporary files..."
|
||||
try {
|
||||
Remove-Item $launcherZip -Force
|
||||
Remove-Item $minecraftZip -Force
|
||||
Write-Log "Temporary files cleaned up" "SUCCESS"
|
||||
}
|
||||
catch {
|
||||
Write-Log "Could not remove temporary files: $($_.Exception.Message)" "WARN"
|
||||
}
|
||||
|
||||
# Final success message
|
||||
Write-Log "=== INSTALLATION COMPLETED SUCCESSFULLY ===" "SUCCESS"
|
||||
Write-Log "PrismLauncher location: $launcherExtractPath" "SUCCESS"
|
||||
Write-Log "Executable: $(Join-Path $launcherExtractPath 'prismlauncher.exe')" "SUCCESS"
|
||||
Write-Log "Minecraft client installed in: $hexorPath" "SUCCESS"
|
||||
if ($Username -and $Username -ne "web-user") {
|
||||
Write-Log "Player name configured: $Username" "SUCCESS"
|
||||
Write-Log "Accounts file: $(Join-Path $InstallPath 'accounts.json')" "SUCCESS"
|
||||
}
|
||||
Write-Log ""
|
||||
Write-Log "You can now run PrismLauncher and the Hexor instance should be available!"
|
||||
Write-Log "If Java was not installed, please download it from: https://www.java.com/en/download/manual.jsp"
|
||||
|
||||
# Ask if user wants to launch the game
|
||||
$launchResponse = Read-Host "Do you want to launch PrismLauncher now? (y/n)"
|
||||
if ($launchResponse -eq 'y' -or $launchResponse -eq 'Y') {
|
||||
$launcherExe = Join-Path $launcherExtractPath "prismlauncher.exe"
|
||||
if (Test-Path $launcherExe) {
|
||||
Write-Log "Launching PrismLauncher..." "INFO"
|
||||
Start-Process -FilePath $launcherExe -WorkingDirectory $launcherExtractPath
|
||||
} else {
|
||||
Write-Log "Launcher executable not found!" "ERROR"
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: minecraft
|
||||
namespace: minecraft
|
||||
labels:
|
||||
app: minecraft
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: minecraft
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: minecraft
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: music
|
||||
volumes:
|
||||
- name: storage
|
||||
hostPath:
|
||||
path: /data/k8s/mc-server/
|
||||
type: Directory
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: nginx-config
|
||||
- name: client-scripts
|
||||
configMap:
|
||||
name: client-scripts
|
||||
|
||||
terminationGracePeriodSeconds: 180
|
||||
containers:
|
||||
- name: minecraft
|
||||
image: eclipse-temurin:8-jdk-ubi10-minimal@sha256:85c943a7093a276b0f6ae13dee2ffecb98e390ab6a32fc7e4b8b1fc6bb103dd7
|
||||
command: ["java"]
|
||||
args:
|
||||
- -Xms4G
|
||||
- -Xmx4G
|
||||
- -XX:+UseG1GC
|
||||
- -XX:+ParallelRefProcEnabled
|
||||
- -XX:MaxGCPauseMillis=200
|
||||
- -XX:+UnlockExperimentalVMOptions
|
||||
- -XX:+DisableExplicitGC
|
||||
- -XX:+AlwaysPreTouch
|
||||
- -XX:G1NewSizePercent=30
|
||||
- -XX:G1MaxNewSizePercent=40
|
||||
- -XX:G1HeapRegionSize=8M
|
||||
- -XX:G1ReservePercent=20
|
||||
- -XX:G1HeapWastePercent=5
|
||||
- -XX:G1MixedGCCountTarget=4
|
||||
- -XX:InitiatingHeapOccupancyPercent=15
|
||||
- -XX:G1MixedGCLiveThresholdPercent=90
|
||||
- -XX:G1RSetUpdatingPauseTimePercent=5
|
||||
- -XX:SurvivorRatio=32
|
||||
- -XX:+PerfDisableSharedMem
|
||||
- -XX:MaxTenuringThreshold=1
|
||||
- -jar
|
||||
- forge-1.12.2-14.23.5.2854.jar
|
||||
- nogui
|
||||
workingDir: /mc/
|
||||
resources:
|
||||
requests:
|
||||
memory: "8Gi"
|
||||
cpu: "2000m"
|
||||
limits:
|
||||
memory: "12Gi"
|
||||
cpu: "4000m"
|
||||
ports:
|
||||
- name: game
|
||||
containerPort: 25565
|
||||
protocol: TCP
|
||||
- name: dynmap
|
||||
containerPort: 8123
|
||||
protocol: TCP
|
||||
- name: webstatus-mod
|
||||
containerPort: 8080
|
||||
protocol: TCP
|
||||
startupProbe:
|
||||
tcpSocket:
|
||||
port: game
|
||||
periodSeconds: 10
|
||||
failureThreshold: 90
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: game
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: game
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
volumeMounts:
|
||||
- name: storage
|
||||
mountPath: /mc
|
||||
- name: nginx
|
||||
image: nginx@sha256:f9ea18bfa4fad859e1ed38259d711da7ccad2c3516e875cec3351a57c859f571
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "200m"
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumeMounts:
|
||||
- name: nginx-config
|
||||
mountPath: /etc/nginx/nginx.conf
|
||||
subPath: nginx.conf
|
||||
- name: storage
|
||||
mountPath: /mc
|
||||
- name: client-scripts
|
||||
mountPath: /mc/clients/win-install.ps1
|
||||
subPath: win-install.ps1
|
||||
- name: client-scripts
|
||||
mountPath: /mc/clients/inject.js
|
||||
subPath: inject.js
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: minecraft-exporter
|
||||
namespace: minecraft
|
||||
spec:
|
||||
selector:
|
||||
app: minecraft
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 19565
|
||||
targetPort: 19565
|
||||
@@ -1,24 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: minecraft
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: minecraft.hexor.cy
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: minecraft-dynmap
|
||||
port:
|
||||
number: 80
|
||||
tls:
|
||||
- secretName: minecraft-tls
|
||||
hosts:
|
||||
- minecraft.hexor.cy
|
||||
@@ -1,8 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: minecraft
|
||||
resources:
|
||||
- deployments.yaml
|
||||
- configmaps.yaml
|
||||
- services.yaml
|
||||
- ingress.yaml
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: minecraft-dynmap
|
||||
spec:
|
||||
selector:
|
||||
app: minecraft
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: minecraft-webstatus-mod
|
||||
spec:
|
||||
selector:
|
||||
app: minecraft
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: minecraft-game
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: Cluster
|
||||
ports:
|
||||
- port: 30565
|
||||
targetPort: 25565
|
||||
selector:
|
||||
app: minecraft
|
||||
@@ -1,23 +0,0 @@
|
||||
# MTProxy
|
||||
|
||||
Argo CD deploys this directory through the `mtproxy` entry in
|
||||
`core-state/values.yaml`. Two telemt DaemonSets run on every node labeled
|
||||
`homelab.hexor.cy/exposure=external`: classic MTProxy on 30443/TCP and
|
||||
fake-TLS on 30444/TCP. The classic listener replaces the old amd64-only
|
||||
`telegrammessenger/proxy` image so the arm64 `spb` node is covered.
|
||||
|
||||
Vaultwarden item `k8s/mtproxy/secret` must contain a custom field named
|
||||
`Secret` with the existing 32-character hexadecimal MTProxy secret. External
|
||||
Secrets renders both configurations from that field. Reloader restarts the
|
||||
DaemonSets when it changes. Changing this value invalidates existing links.
|
||||
|
||||
`mtproxy-link-reconciler` lists external nodes every five minutes and creates
|
||||
`mtproxy-links` and `telemt-links` Secrets. A node's public DNS name must be
|
||||
`<node>.hexor.cy` and must point to that node. The reader at `proxy.hexor.cy`
|
||||
has read-only access to those two Secrets and is protected by Keycloak's
|
||||
forward auth; its access policy is in `terraform/keycloak/terraform.tfvars`.
|
||||
The proxy Pods have no Kubernetes API access.
|
||||
|
||||
Before traffic is switched over, allow inbound 30443/TCP and 30444/TCP on
|
||||
every external node and verify both DNS and connectivity on each node.
|
||||
Neither the cluster nor host firewall is changed by these manifests.
|
||||
@@ -1,149 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: mtproxy-classic
|
||||
labels:
|
||||
app: mtproxy-classic
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mtproxy-classic
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mtproxy-classic
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
spec:
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/exposure: external
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65532
|
||||
runAsGroup: 65532
|
||||
fsGroup: 65532
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: telemt
|
||||
image: ghcr.io/telemt/telemt@sha256:b311c20596213a3941dcd11f499be982de74f554eecfffe57fab51c1bf80d50a
|
||||
imagePullPolicy: IfNotPresent
|
||||
workingDir: /run/telemt
|
||||
args: ["/app/config.toml"]
|
||||
ports:
|
||||
- name: proxy
|
||||
containerPort: 30443
|
||||
hostPort: 30443
|
||||
protocol: TCP
|
||||
- name: metrics
|
||||
containerPort: 9090
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: proxy
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
memory: 256Mi
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /app/config.toml
|
||||
subPath: classic.toml
|
||||
readOnly: true
|
||||
- name: workdir
|
||||
mountPath: /run/telemt
|
||||
volumes:
|
||||
- name: config
|
||||
secret:
|
||||
secretName: mtproxy-config
|
||||
defaultMode: 0444
|
||||
items:
|
||||
- key: classic.toml
|
||||
path: classic.toml
|
||||
- name: workdir
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 4Mi
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: mtproxy-tls
|
||||
labels:
|
||||
app: mtproxy-tls
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mtproxy-tls
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mtproxy-tls
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
spec:
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/exposure: external
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65532
|
||||
runAsGroup: 65532
|
||||
fsGroup: 65532
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: telemt
|
||||
image: ghcr.io/telemt/telemt@sha256:b311c20596213a3941dcd11f499be982de74f554eecfffe57fab51c1bf80d50a
|
||||
imagePullPolicy: IfNotPresent
|
||||
workingDir: /run/telemt
|
||||
args: ["/app/config.toml"]
|
||||
ports:
|
||||
- name: proxy
|
||||
containerPort: 30444
|
||||
hostPort: 30444
|
||||
protocol: TCP
|
||||
- name: metrics
|
||||
containerPort: 9090
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: proxy
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
memory: 256Mi
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /app/config.toml
|
||||
subPath: tls.toml
|
||||
readOnly: true
|
||||
- name: workdir
|
||||
mountPath: /run/telemt
|
||||
volumes:
|
||||
- name: config
|
||||
secret:
|
||||
secretName: mtproxy-config
|
||||
defaultMode: 0444
|
||||
items:
|
||||
- key: tls.toml
|
||||
path: tls.toml
|
||||
- name: workdir
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 4Mi
|
||||
@@ -1,74 +0,0 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: mtproxy-config
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
name: vaultwarden-fields
|
||||
kind: ClusterSecretStore
|
||||
target:
|
||||
name: mtproxy-config
|
||||
creationPolicy: Owner
|
||||
deletionPolicy: Retain
|
||||
template:
|
||||
type: Opaque
|
||||
data:
|
||||
SECRET: "{{ .secret }}"
|
||||
classic.toml: |
|
||||
[general]
|
||||
use_middle_proxy = true
|
||||
log_level = "normal"
|
||||
|
||||
[general.modes]
|
||||
classic = true
|
||||
secure = false
|
||||
tls = false
|
||||
|
||||
[server]
|
||||
port = 30443
|
||||
metrics_port = 9090
|
||||
metrics_whitelist = ["0.0.0.0/0"]
|
||||
|
||||
[server.api]
|
||||
enabled = false
|
||||
|
||||
[[server.listeners]]
|
||||
ip = "0.0.0.0"
|
||||
|
||||
[access.users]
|
||||
user = "{{ .secret }}"
|
||||
tls.toml: |
|
||||
[general]
|
||||
use_middle_proxy = true
|
||||
log_level = "normal"
|
||||
|
||||
[general.modes]
|
||||
classic = false
|
||||
secure = false
|
||||
tls = true
|
||||
|
||||
[server]
|
||||
port = 30444
|
||||
metrics_port = 9090
|
||||
metrics_whitelist = ["0.0.0.0/0"]
|
||||
|
||||
[server.api]
|
||||
enabled = false
|
||||
|
||||
[[server.listeners]]
|
||||
ip = "0.0.0.0"
|
||||
|
||||
[censorship]
|
||||
tls_domain = "ya.ru"
|
||||
mask = true
|
||||
tls_emulation = true
|
||||
tls_front_dir = "tlsfront"
|
||||
|
||||
[access.users]
|
||||
user = "{{ .secret }}"
|
||||
data:
|
||||
- secretKey: secret
|
||||
remoteRef:
|
||||
key: k8s/mtproxy/secret
|
||||
property: Secret
|
||||
@@ -1,38 +0,0 @@
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: mtproxy-auth
|
||||
spec:
|
||||
forwardAuth:
|
||||
address: http://auth-proxy.keycloak.svc:80/auth
|
||||
trustForwardHeader: false
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: mtproxy-links
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`proxy.hexor.cy`)
|
||||
kind: Rule
|
||||
middlewares:
|
||||
- name: mtproxy-auth
|
||||
services:
|
||||
- name: mtproxy-link-reader
|
||||
port: 80
|
||||
tls:
|
||||
secretName: mtproxy-links-tls
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: mtproxy-links-tls
|
||||
spec:
|
||||
secretName: mtproxy-links-tls
|
||||
issuerRef:
|
||||
name: letsencrypt
|
||||
kind: ClusterIssuer
|
||||
dnsNames:
|
||||
- proxy.hexor.cy
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: mtproxy
|
||||
resources:
|
||||
- external-secrets.yaml
|
||||
- daemonsets.yaml
|
||||
- metrics.yaml
|
||||
- links.yaml
|
||||
- reader.yaml
|
||||
- ingress.yaml
|
||||
configMapGenerator:
|
||||
- name: mtproxy-link-reconciler
|
||||
files:
|
||||
- reconcile.py=link-reconciler.py
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
@@ -1,75 +0,0 @@
|
||||
"""Publish client links for every external node, using its public DNS name."""
|
||||
|
||||
import base64
|
||||
import json
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
|
||||
API = "https://kubernetes.default.svc"
|
||||
NAMESPACE = open("/var/run/secrets/kubernetes.io/serviceaccount/namespace", encoding="utf-8").read().strip()
|
||||
TOKEN = open("/var/run/secrets/kubernetes.io/serviceaccount/token", encoding="utf-8").read().strip()
|
||||
CA = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
|
||||
|
||||
|
||||
def request(method, path, body=None):
|
||||
import ssl
|
||||
|
||||
data = json.dumps(body).encode() if body is not None else None
|
||||
req = urllib.request.Request(
|
||||
API + path,
|
||||
data=data,
|
||||
method=method,
|
||||
headers={
|
||||
"Authorization": "Bearer " + TOKEN,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
)
|
||||
with urllib.request.urlopen(req, context=ssl.create_default_context(cafile=CA), timeout=15) as response:
|
||||
return json.load(response)
|
||||
|
||||
|
||||
def publish(name, links):
|
||||
path = f"/api/v1/namespaces/{NAMESPACE}/secrets"
|
||||
data = {node: base64.b64encode(link.encode()).decode() for node, link in links.items()}
|
||||
try:
|
||||
current = request("GET", f"{path}/{name}")
|
||||
except urllib.error.HTTPError as error:
|
||||
if error.code != 404:
|
||||
raise
|
||||
request("POST", path, {"apiVersion": "v1", "kind": "Secret", "metadata": {"name": name}, "type": "Opaque", "data": data})
|
||||
return
|
||||
if current.get("data", {}) == data:
|
||||
return
|
||||
# PUT replaces the data map, removing links for nodes that are no longer external.
|
||||
request("PUT", f"{path}/{name}", {
|
||||
"apiVersion": "v1",
|
||||
"kind": "Secret",
|
||||
"metadata": {"name": name, "resourceVersion": current["metadata"]["resourceVersion"]},
|
||||
"type": "Opaque",
|
||||
"data": data,
|
||||
})
|
||||
|
||||
|
||||
secret = open("/config/SECRET", encoding="utf-8").read().strip()
|
||||
if len(secret) != 32 or any(char not in "0123456789abcdefABCDEF" for char in secret):
|
||||
raise ValueError("Vaultwarden Secret must be 32 hexadecimal characters")
|
||||
|
||||
selector = urllib.parse.quote("homelab.hexor.cy/exposure=external", safe="")
|
||||
nodes = request("GET", f"/api/v1/nodes?labelSelector={selector}")["items"]
|
||||
if not nodes:
|
||||
raise ValueError("No external nodes found")
|
||||
|
||||
classic = {}
|
||||
tls = {}
|
||||
for node in nodes:
|
||||
name = node["metadata"]["name"]
|
||||
# DNS is maintained outside the cluster; no public IP needs to be stored on a Node.
|
||||
host = f"{name}.hexor.cy"
|
||||
classic[name] = f"tg://proxy?server={host}&port=30443&secret={secret}"
|
||||
tls[name] = f"tg://proxy?server={host}&port=30444&secret=ee{secret}79612e7275"
|
||||
|
||||
publish("mtproxy-links", classic)
|
||||
publish("telemt-links", tls)
|
||||
print(f"Published MTProxy links for {len(nodes)} external nodes")
|
||||
@@ -1,108 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: mtproxy-link-reconciler
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: mtproxy-external-node-reader
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["nodes"]
|
||||
verbs: ["list"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: mtproxy-external-node-reader
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: mtproxy-external-node-reader
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: mtproxy-link-reconciler
|
||||
namespace: mtproxy
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: mtproxy-link-writer
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["create"]
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
resourceNames: ["mtproxy-links", "telemt-links"]
|
||||
verbs: ["get", "update"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: mtproxy-link-writer
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: mtproxy-link-writer
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: mtproxy-link-reconciler
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: mtproxy-link-reconciler
|
||||
spec:
|
||||
schedule: "*/5 * * * *"
|
||||
concurrencyPolicy: Forbid
|
||||
successfulJobsHistoryLimit: 1
|
||||
failedJobsHistoryLimit: 2
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 2
|
||||
template:
|
||||
spec:
|
||||
serviceAccountName: mtproxy-link-reconciler
|
||||
restartPolicy: OnFailure
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/exposure: external
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
runAsGroup: 65534
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: reconcile
|
||||
image: python:3.13-alpine3.22@sha256:e81548ac35b07a3bd4805f275107592ef458b1e893c0e04d45aedaa19416cca5
|
||||
command: ["python", "/scripts/reconcile.py"]
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 128Mi
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
volumeMounts:
|
||||
- name: scripts
|
||||
mountPath: /scripts
|
||||
readOnly: true
|
||||
- name: config
|
||||
mountPath: /config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: scripts
|
||||
configMap:
|
||||
name: mtproxy-link-reconciler
|
||||
- name: config
|
||||
secret:
|
||||
secretName: mtproxy-config
|
||||
items:
|
||||
- key: SECRET
|
||||
path: SECRET
|
||||
@@ -1,65 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mtproxy-classic-metrics
|
||||
labels:
|
||||
app: mtproxy-classic
|
||||
spec:
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: mtproxy-classic
|
||||
ports:
|
||||
- name: metrics
|
||||
port: 9090
|
||||
targetPort: metrics
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mtproxy-tls-metrics
|
||||
labels:
|
||||
app: mtproxy-tls
|
||||
spec:
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: mtproxy-tls
|
||||
ports:
|
||||
- name: metrics
|
||||
port: 9090
|
||||
targetPort: metrics
|
||||
---
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: mtproxy-classic
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mtproxy-classic
|
||||
endpoints:
|
||||
- port: metrics
|
||||
path: /metrics
|
||||
interval: 30s
|
||||
scrapeTimeout: 10s
|
||||
relabelings:
|
||||
- action: replace
|
||||
sourceLabels: [__meta_kubernetes_pod_node_name]
|
||||
targetLabel: node
|
||||
---
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: mtproxy-tls
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mtproxy-tls
|
||||
endpoints:
|
||||
- port: metrics
|
||||
path: /metrics
|
||||
interval: 30s
|
||||
scrapeTimeout: 10s
|
||||
relabelings:
|
||||
- action: replace
|
||||
sourceLabels: [__meta_kubernetes_pod_node_name]
|
||||
targetLabel: node
|
||||
@@ -1,96 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: mtproxy-link-reader
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: mtproxy-link-reader
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
resourceNames: ["mtproxy-links", "telemt-links"]
|
||||
verbs: ["get"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: mtproxy-link-reader
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: mtproxy-link-reader
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: mtproxy-link-reader
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mtproxy-link-reader
|
||||
labels:
|
||||
app: mtproxy-link-reader
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mtproxy-link-reader
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mtproxy-link-reader
|
||||
spec:
|
||||
serviceAccountName: mtproxy-link-reader
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/exposure: external
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: reader
|
||||
image: ultradesu/k8s-secrets:0.2.2@sha256:f206942d21ca9dcd131d6e19ba26cc17671815919217aef657b30a9f85854778
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- --secrets
|
||||
- mtproxy-links,telemt-links
|
||||
- --namespace
|
||||
- mtproxy
|
||||
- --port
|
||||
- "3000"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
memory: 128Mi
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mtproxy-link-reader
|
||||
spec:
|
||||
selector:
|
||||
app: mtproxy-link-reader
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: http
|
||||
@@ -1,42 +0,0 @@
|
||||
import json
|
||||
from http.cookiejar import CookieJar
|
||||
from pathlib import Path
|
||||
from urllib.request import HTTPCookieProcessor, Request, build_opener
|
||||
|
||||
|
||||
server = "https://repo.hexor.cy"
|
||||
cookies = CookieJar()
|
||||
session = build_opener(HTTPCookieProcessor(cookies))
|
||||
headers = {"Content-Type": "application/json", "Origin": server}
|
||||
|
||||
|
||||
def post(path, body):
|
||||
request = Request(server + "/api/v1/" + path, json.dumps(body).encode(), headers)
|
||||
with session.open(request, timeout=30) as response:
|
||||
return response.read()
|
||||
|
||||
|
||||
manifest = Path("/config/sso.yaml").read_text()
|
||||
credentials = Path("/credentials")
|
||||
client_secret = (credentials / "client-secret").read_text()
|
||||
post("auth/login", {"username": "admin", "password": (credentials / "admin-password").read_text()})
|
||||
try:
|
||||
headers["X-CSRF-Token"] = next(cookie.value for cookie in cookies if cookie.name == "oa_csrf")
|
||||
result = json.loads(post("admin/declarative/apply", {
|
||||
"manifest": manifest,
|
||||
"force_secrets": True,
|
||||
"secrets": {"OIDC_CLIENT_SECRET": client_secret},
|
||||
}))
|
||||
[provider] = result["items"]
|
||||
if provider["name"] != "keycloak" or provider["result"] != "applied":
|
||||
raise RuntimeError("OpenArtifact did not apply the Keycloak provider")
|
||||
print("Keycloak SSO provider applied")
|
||||
publisher = json.loads(post("admin/declarative/apply", {
|
||||
"manifest": Path("/config/winget-publisher.yaml").read_text(),
|
||||
}))
|
||||
items = publisher["items"]
|
||||
if len(items) != 3 or any(item["result"] != "applied" for item in items):
|
||||
raise RuntimeError("OpenArtifact did not apply the WinGet publisher policy")
|
||||
print("WinGet publisher policy applied")
|
||||
finally:
|
||||
post("auth/logout", {})
|
||||
@@ -1,41 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: db-credentials-reader
|
||||
namespace: openartifact
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: SecretStore
|
||||
metadata:
|
||||
name: psql-credentials
|
||||
namespace: openartifact
|
||||
spec:
|
||||
provider:
|
||||
kubernetes:
|
||||
remoteNamespace: psql
|
||||
server:
|
||||
caProvider:
|
||||
type: ConfigMap
|
||||
name: kube-root-ca.crt
|
||||
key: ca.crt
|
||||
auth:
|
||||
serviceAccount:
|
||||
name: db-credentials-reader
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: openartifact-db
|
||||
namespace: openartifact
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
kind: SecretStore
|
||||
name: psql-credentials
|
||||
target:
|
||||
name: openartifact-db
|
||||
data:
|
||||
- secretKey: password
|
||||
remoteRef:
|
||||
key: openartifact-db
|
||||
property: password
|
||||
@@ -1,18 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: openartifact
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
volumes:
|
||||
- name: data
|
||||
emptyDir: null
|
||||
hostPath:
|
||||
path: /data/k8s/openartifact/artifacts
|
||||
type: DirectoryOrCreate
|
||||
- name: backups
|
||||
emptyDir: null
|
||||
hostPath:
|
||||
path: /data/k8s/openartifact/backups
|
||||
type: DirectoryOrCreate
|
||||
@@ -1,28 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: openartifact
|
||||
|
||||
resources:
|
||||
- db-secret.yaml
|
||||
- secrets.yaml
|
||||
- oidc-client.yaml
|
||||
- sso-job.yaml
|
||||
|
||||
configMapGenerator:
|
||||
- name: openartifact-sso
|
||||
files:
|
||||
- sso.yaml
|
||||
- apply-sso.py
|
||||
- winget-publisher.yaml
|
||||
|
||||
helmCharts:
|
||||
- name: openartifact
|
||||
repo: https://openartifact.github.io/helm-charts
|
||||
version: 0.22.0
|
||||
releaseName: openartifact
|
||||
namespace: openartifact
|
||||
valuesFile: values.yaml
|
||||
skipTests: true
|
||||
|
||||
patches:
|
||||
- path: hostpath.yaml
|
||||
@@ -1,18 +0,0 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: openartifact-oidc-client
|
||||
spec:
|
||||
refreshInterval: 5m
|
||||
secretStoreRef:
|
||||
kind: ClusterSecretStore
|
||||
name: vaultwarden-login
|
||||
target:
|
||||
name: openartifact-oidc-client
|
||||
creationPolicy: Owner
|
||||
deletionPolicy: Retain
|
||||
data:
|
||||
- secretKey: client-secret
|
||||
remoteRef:
|
||||
key: keycloak/openartifact
|
||||
property: login.password
|
||||
@@ -1,57 +0,0 @@
|
||||
apiVersion: generators.external-secrets.io/v1alpha1
|
||||
kind: Password
|
||||
metadata:
|
||||
name: openartifact-random
|
||||
spec:
|
||||
length: 64
|
||||
digits: 14
|
||||
symbols: 0
|
||||
allowRepeat: true
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: openartifact-keys
|
||||
spec:
|
||||
refreshPolicy: CreatedOnce
|
||||
target:
|
||||
name: openartifact-keys
|
||||
creationPolicy: Orphan
|
||||
dataFrom:
|
||||
- sourceRef:
|
||||
generatorRef:
|
||||
apiVersion: generators.external-secrets.io/v1alpha1
|
||||
kind: Password
|
||||
name: openartifact-random
|
||||
rewrite:
|
||||
- regexp:
|
||||
source: "^password$"
|
||||
target: AUTH_HMAC_KEY
|
||||
- sourceRef:
|
||||
generatorRef:
|
||||
apiVersion: generators.external-secrets.io/v1alpha1
|
||||
kind: Password
|
||||
name: openartifact-random
|
||||
rewrite:
|
||||
- regexp:
|
||||
source: "^password$"
|
||||
target: OPENARTIFACT_SECRET_KEY
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: openartifact-admin
|
||||
spec:
|
||||
refreshPolicy: CreatedOnce
|
||||
target:
|
||||
name: openartifact-admin
|
||||
creationPolicy: Orphan
|
||||
template:
|
||||
data:
|
||||
admin-password: "{{ .password }}"
|
||||
dataFrom:
|
||||
- sourceRef:
|
||||
generatorRef:
|
||||
apiVersion: generators.external-secrets.io/v1alpha1
|
||||
kind: Password
|
||||
name: openartifact-random
|
||||
@@ -1,52 +0,0 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: openartifact-apply-sso
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PostSync
|
||||
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation,HookSucceeded
|
||||
spec:
|
||||
backoffLimit: 2
|
||||
activeDeadlineSeconds: 300
|
||||
template:
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
restartPolicy: Never
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: master
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 10001
|
||||
runAsGroup: 10001
|
||||
fsGroup: 10001
|
||||
seccompProfile: {type: RuntimeDefault}
|
||||
containers:
|
||||
- name: apply
|
||||
image: python:3.13-alpine3.22@sha256:e81548ac35b07a3bd4805f275107592ef458b1e893c0e04d45aedaa19416cca5
|
||||
command: [python, -B, /config/apply-sso.py]
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities: {drop: [ALL]}
|
||||
resources:
|
||||
requests: {cpu: 10m, memory: 24Mi}
|
||||
limits: {memory: 64Mi}
|
||||
volumeMounts:
|
||||
- {name: config, mountPath: /config, readOnly: true}
|
||||
- {name: credentials, mountPath: /credentials, readOnly: true}
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openartifact-sso
|
||||
- name: credentials
|
||||
projected:
|
||||
defaultMode: 0440
|
||||
sources:
|
||||
- secret:
|
||||
name: openartifact-admin
|
||||
items:
|
||||
- {key: admin-password, path: admin-password}
|
||||
- secret:
|
||||
name: openartifact-oidc-client
|
||||
items:
|
||||
- {key: client-secret, path: client-secret}
|
||||
@@ -1,21 +0,0 @@
|
||||
apiVersion: openartifact.io/v1
|
||||
kind: SSOProvider
|
||||
metadata:
|
||||
name: keycloak
|
||||
spec:
|
||||
kind: oidc
|
||||
display_name: Keycloak
|
||||
enabled: true
|
||||
auto_provision_users: true
|
||||
link_by_email: false
|
||||
oidc_config:
|
||||
issuer: https://auth.hexor.cy/auth/realms/hexor
|
||||
client_id: openartifact
|
||||
client_secret:
|
||||
secretRef: {env: OIDC_CLIENT_SECRET}
|
||||
scopes: [openid, email, profile]
|
||||
groups_claim: groups
|
||||
group_mapping:
|
||||
/hexor-admin: keycloak-hexor-admin
|
||||
permission_mapping:
|
||||
keycloak-hexor-admin: admin-all
|
||||
@@ -1,61 +0,0 @@
|
||||
baseUrl: https://repo.hexor.cy
|
||||
env:
|
||||
OPENARTIFACT_ALLOW_PRIVATE_UPSTREAMS: "true"
|
||||
replicaCount: 1
|
||||
updateStrategy:
|
||||
type: Recreate
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: master
|
||||
persistence:
|
||||
enabled: false
|
||||
|
||||
database:
|
||||
external:
|
||||
host: main-rw.psql.svc.cluster.local
|
||||
name: openartifact
|
||||
user: openartifact
|
||||
existingSecret: openartifact-db
|
||||
|
||||
secrets:
|
||||
existingSecret: openartifact-keys
|
||||
bootstrap:
|
||||
existingSecret: openartifact-admin
|
||||
|
||||
extraInitContainers:
|
||||
- name: prepare-storage
|
||||
image: docker.io/library/busybox:1.37.0@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec
|
||||
command:
|
||||
- sh
|
||||
- -ec
|
||||
- |
|
||||
chown 10001:10001 /artifacts /backups
|
||||
chmod 0700 /artifacts /backups
|
||||
securityContext:
|
||||
runAsNonRoot: false
|
||||
runAsUser: 0
|
||||
runAsGroup: 0
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
add: [CHOWN, FOWNER]
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /artifacts
|
||||
- name: backups
|
||||
mountPath: /backups
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: traefik
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
hosts:
|
||||
- host: repo.hexor.cy
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
tls:
|
||||
- hosts: [repo.hexor.cy]
|
||||
secretName: openartifact-tls
|
||||
@@ -1,39 +0,0 @@
|
||||
apiVersion: openartifact.io/v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: github-winget
|
||||
spec:
|
||||
description: Publishes the Hexor WinGet catalog from GitHub Actions
|
||||
---
|
||||
apiVersion: openartifact.io/v1
|
||||
kind: PermissionTarget
|
||||
metadata:
|
||||
name: github-winget-publish
|
||||
spec:
|
||||
repository_filter: '^hexor-winget$'
|
||||
path_pattern: '.*'
|
||||
actions: [read, write]
|
||||
assignments:
|
||||
users: [github-winget]
|
||||
---
|
||||
apiVersion: openartifact.io/v1
|
||||
kind: OIDCTrustPolicy
|
||||
metadata:
|
||||
name: github-winget-publish
|
||||
spec:
|
||||
issuer: https://token.actions.githubusercontent.com
|
||||
audience: https://repo.hexor.cy
|
||||
service_account: github-winget
|
||||
token_ttl_seconds: 900
|
||||
enabled: true
|
||||
conditions:
|
||||
- claim: repository_owner_id
|
||||
patterns: ['4666566']
|
||||
- claim: repository_id
|
||||
patterns: ['678451959']
|
||||
- claim: event_name
|
||||
patterns: [repository_dispatch, workflow_dispatch]
|
||||
- claim: ref
|
||||
patterns: ['refs/heads/main']
|
||||
- claim: workflow_ref
|
||||
patterns: ['house-of-vanity/arch_repo/.github/workflows/publish-winget.yml@refs/heads/main']
|
||||
@@ -1,151 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: rustdesk-hbbs
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
labels:
|
||||
app: rustdesk-hbbs
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: rustdesk-hbbs
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: rustdesk-hbbs
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: music
|
||||
containers:
|
||||
- name: hbbs
|
||||
image: rustdesk/rustdesk-server@sha256:8ecdab65deb7c84652a626380e31d11a8f1fbafd97916d57f95c20628f943c00
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "750m"
|
||||
command: ["hbbs"]
|
||||
args:
|
||||
- "--relay-servers"
|
||||
- "rd.hexor.cy:21117"
|
||||
- "--port"
|
||||
- "21116"
|
||||
ports:
|
||||
- name: registry
|
||||
containerPort: 21116
|
||||
protocol: TCP
|
||||
- name: registry-udp
|
||||
containerPort: 21116
|
||||
protocol: UDP
|
||||
- name: nat
|
||||
containerPort: 21115
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: registry
|
||||
volumeMounts:
|
||||
- name: keys
|
||||
mountPath: /data
|
||||
readOnly: true
|
||||
- name: data
|
||||
mountPath: /data-persistent
|
||||
env:
|
||||
- name: RUST_LOG
|
||||
value: "info"
|
||||
- name: DB_URL
|
||||
value: "/data-persistent/db_v2.sqlite3"
|
||||
workingDir: /data
|
||||
volumes:
|
||||
- name: keys
|
||||
secret:
|
||||
secretName: rustdesk-keys
|
||||
items:
|
||||
- key: id_ed25519
|
||||
path: id_ed25519
|
||||
mode: 0600
|
||||
- key: id_ed25519.pub
|
||||
path: id_ed25519.pub
|
||||
mode: 0644
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /data/k8s/rustdesk/hbbs
|
||||
type: Directory
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: rustdesk-hbbr
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
labels:
|
||||
app: rustdesk-hbbr
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: rustdesk-hbbr
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: rustdesk-hbbr
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: music
|
||||
containers:
|
||||
- name: hbbr
|
||||
image: rustdesk/rustdesk-server@sha256:8ecdab65deb7c84652a626380e31d11a8f1fbafd97916d57f95c20628f943c00
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "750m"
|
||||
command: ["hbbr"]
|
||||
args:
|
||||
- "--port"
|
||||
- "21117"
|
||||
ports:
|
||||
- name: relay
|
||||
containerPort: 21117
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: relay
|
||||
volumeMounts:
|
||||
- name: keys
|
||||
mountPath: /data
|
||||
readOnly: true
|
||||
- name: data
|
||||
mountPath: /data-persistent
|
||||
env:
|
||||
- name: RUST_LOG
|
||||
value: "info"
|
||||
workingDir: /data
|
||||
volumes:
|
||||
- name: keys
|
||||
secret:
|
||||
secretName: rustdesk-keys
|
||||
items:
|
||||
- key: id_ed25519
|
||||
path: id_ed25519
|
||||
mode: 0600
|
||||
- key: id_ed25519.pub
|
||||
path: id_ed25519.pub
|
||||
mode: 0644
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /data/k8s/rustdesk/hbbr
|
||||
type: Directory
|
||||
@@ -1,27 +0,0 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: rustdesk-keys
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
name: vaultwarden-fields
|
||||
kind: ClusterSecretStore
|
||||
target:
|
||||
name: rustdesk-keys
|
||||
creationPolicy: Owner
|
||||
deletionPolicy: Retain
|
||||
template:
|
||||
type: Opaque
|
||||
data:
|
||||
id_ed25519: "{{ .private_key }}"
|
||||
id_ed25519.pub: "{{ .public_key }}"
|
||||
data:
|
||||
- secretKey: private_key
|
||||
remoteRef:
|
||||
key: k8s/rustdesk/secrets
|
||||
property: Cert
|
||||
- secretKey: public_key
|
||||
remoteRef:
|
||||
key: k8s/rustdesk/secrets
|
||||
property: Key
|
||||
@@ -1,8 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: rustdesk
|
||||
resources:
|
||||
- external-secrets.yaml
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- network-policy.yaml
|
||||
@@ -1,73 +0,0 @@
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: rustdesk-network-policy
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: rustdesk-hbbs
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
# Allow all incoming connections to RustDesk ports
|
||||
- from: []
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 21115
|
||||
- protocol: TCP
|
||||
port: 21116
|
||||
- protocol: UDP
|
||||
port: 21116
|
||||
egress:
|
||||
# Allow DNS
|
||||
- to: []
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
# Allow communication between HBBS and HBBR
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: rustdesk-hbbr
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 21117
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: rustdesk-hbbr-network-policy
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: rustdesk-hbbr
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
# Allow all incoming connections to relay port
|
||||
- from: []
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 21117
|
||||
# Allow connections from HBBS
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: rustdesk-hbbs
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 21117
|
||||
egress:
|
||||
# Allow DNS
|
||||
- to: []
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
@@ -1,59 +0,0 @@
|
||||
# Preserve client source IPs for RustDesk NAT detection. Public DNS points to music,
|
||||
# where both servers and their persistent data live.
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: rustdesk-hbbs
|
||||
labels:
|
||||
app: rustdesk-hbbs
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: Local
|
||||
selector:
|
||||
app: rustdesk-hbbs
|
||||
ports:
|
||||
- name: registry-tcp
|
||||
port: 21116
|
||||
targetPort: 21116
|
||||
protocol: TCP
|
||||
- name: nat
|
||||
port: 21115
|
||||
targetPort: 21115
|
||||
protocol: TCP
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: rustdesk-hbbs-udp
|
||||
labels:
|
||||
app: rustdesk-hbbs
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: Local
|
||||
selector:
|
||||
app: rustdesk-hbbs
|
||||
ports:
|
||||
- name: registry-udp
|
||||
port: 21116
|
||||
targetPort: 21116
|
||||
protocol: UDP
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: rustdesk-hbbr
|
||||
labels:
|
||||
app: rustdesk-hbbr
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: Local
|
||||
selector:
|
||||
app: rustdesk-hbbr
|
||||
ports:
|
||||
- name: relay
|
||||
port: 21117
|
||||
targetPort: 21117
|
||||
protocol: TCP
|
||||
@@ -1,18 +0,0 @@
|
||||
# Shadowsocks on spb
|
||||
|
||||
One shadowsocks-rust pod runs on `spb`, exposing `8388/TCP` and `8388/UDP`
|
||||
through host ports. Client settings:
|
||||
|
||||
- Server: `spb.hexor.cy`
|
||||
- Port: `8388`
|
||||
- Method: `chacha20-ietf-poly1305`
|
||||
- Password: the `Password` custom field of the Vaultwarden item named
|
||||
`k8s/shadowsocks/secrets` (exact name, not an item UUID).
|
||||
|
||||
Create that item in the server secrets vault accessible to the External Secrets
|
||||
bot. Use a long random password, for example generated with `openssl rand -base64 32`.
|
||||
External Secrets creates `shadowsocks-config`; Reloader restarts the deployment
|
||||
when the Secret changes. No persistent storage is required.
|
||||
|
||||
The spb NixOS configuration opens port 8388 for both protocols. Apply that
|
||||
configuration when deploying this application for the first time.
|
||||
@@ -1,71 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: shadowsocks
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
labels:
|
||||
app: shadowsocks
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: shadowsocks
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: shadowsocks
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: spb
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
runAsGroup: 65534
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: shadowsocks
|
||||
# shadowsocks-rust v1.25.0; multi-arch image includes linux/arm64.
|
||||
image: ghcr.io/shadowsocks/ssserver-rust:v1.25.0@sha256:22240c07d8ce3a36421ede770bd775dcc5fc56d5d829943196957b05452dc36f
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/usr/bin/ssserver"]
|
||||
args:
|
||||
- --log-without-time
|
||||
- -c
|
||||
- /etc/shadowsocks-rust/config.json
|
||||
ports:
|
||||
- name: proxy-tcp
|
||||
containerPort: 8388
|
||||
hostPort: 8388
|
||||
protocol: TCP
|
||||
- name: proxy-udp
|
||||
containerPort: 8388
|
||||
hostPort: 8388
|
||||
protocol: UDP
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: proxy-tcp
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 256Mi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/shadowsocks-rust
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
secret:
|
||||
secretName: shadowsocks-config
|
||||
defaultMode: 0444
|
||||
@@ -1,29 +0,0 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: shadowsocks-config
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
name: vaultwarden-fields
|
||||
kind: ClusterSecretStore
|
||||
target:
|
||||
name: shadowsocks-config
|
||||
creationPolicy: Owner
|
||||
deletionPolicy: Retain
|
||||
template:
|
||||
type: Opaque
|
||||
data:
|
||||
config.json: |
|
||||
{
|
||||
"server": "0.0.0.0",
|
||||
"server_port": 8388,
|
||||
"method": "chacha20-ietf-poly1305",
|
||||
"password": {{ .password | toJson }},
|
||||
"mode": "tcp_and_udp"
|
||||
}
|
||||
data:
|
||||
- secretKey: password
|
||||
remoteRef:
|
||||
key: k8s/shadowsocks/secrets
|
||||
property: Password
|
||||
@@ -1,6 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: shadowsocks
|
||||
resources:
|
||||
- external-secrets.yaml
|
||||
- deployment.yaml
|
||||
@@ -1,54 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: web-petting
|
||||
labels:
|
||||
app: web-petting
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: web-petting
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: web-petting
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
spec:
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
containers:
|
||||
- name: web-petting
|
||||
image: ultradesu/web-petting:latest
|
||||
imagePullPolicy: Always
|
||||
args:
|
||||
- web-petting
|
||||
- -l
|
||||
- 0.0.0.0:3000
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
env:
|
||||
- name: RUST_LOG
|
||||
value: info
|
||||
- name: WEB_PETTING_DEBUG
|
||||
value: "false"
|
||||
- name: WEB_PETTING_DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: web-petting-secrets
|
||||
key: WEB_PETTING_DATABASE_URL
|
||||
# Everything persistent is in PostgreSQL and R2; /data is scratch space only.
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
resources:
|
||||
requests:
|
||||
memory: 256Mi
|
||||
limits:
|
||||
memory: 1Gi
|
||||
volumes:
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
@@ -1,37 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: web-petting
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: pet.hexor.cy
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: web-petting
|
||||
port:
|
||||
number: 80
|
||||
- host: xn--l1acako8eb.xn--p1ai
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: web-petting
|
||||
port:
|
||||
number: 80
|
||||
tls:
|
||||
- secretName: web-petting-tls
|
||||
hosts:
|
||||
- pet.hexor.cy
|
||||
- secretName: web-petting-murnyanya-tls
|
||||
hosts:
|
||||
- xn--l1acako8eb.xn--p1ai
|
||||
@@ -1,8 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- secrets.yaml
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- ingress.yaml
|
||||
@@ -1,47 +0,0 @@
|
||||
# Read-only access to the web-petting-db Secret in the psql namespace
|
||||
# (see postgresql/databases/web-petting.yaml for the other half).
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: db-credentials-reader
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: SecretStore
|
||||
metadata:
|
||||
name: psql-credentials
|
||||
spec:
|
||||
provider:
|
||||
kubernetes:
|
||||
remoteNamespace: psql
|
||||
server:
|
||||
caProvider:
|
||||
type: ConfigMap
|
||||
name: kube-root-ca.crt
|
||||
key: ca.crt
|
||||
auth:
|
||||
serviceAccount:
|
||||
name: db-credentials-reader
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: web-petting-secrets
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
kind: SecretStore
|
||||
name: psql-credentials
|
||||
target:
|
||||
name: web-petting-secrets
|
||||
template:
|
||||
data:
|
||||
WEB_PETTING_DATABASE_URL: "postgresql://{{ .username }}:{{ .password }}@main-rw.psql.svc:5432/web_petting"
|
||||
data:
|
||||
- secretKey: username
|
||||
remoteRef:
|
||||
key: web-petting-db
|
||||
property: username
|
||||
- secretKey: password
|
||||
remoteRef:
|
||||
key: web-petting-db
|
||||
property: password
|
||||
@@ -1,15 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web-petting
|
||||
labels:
|
||||
app: web-petting
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: web-petting
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
protocol: TCP
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Brings the whole core state up on an empty cluster:
|
||||
# k8s-ng/bootstrap/bootstrap.sh <kube-context>
|
||||
# Installs Argo CD (the only thing that cannot install itself) and applies the
|
||||
# root application; Argo CD then pulls every core application in wave order.
|
||||
set -euo pipefail
|
||||
|
||||
ctx=${1:?usage: bootstrap.sh <kube-context>}
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
k="kubectl --context $ctx"
|
||||
|
||||
# Render in a scratch copy so kustomize does not leave downloaded charts in the repo.
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
cp -r "$here/../core/argocd" "$tmp/argocd"
|
||||
kubectl kustomize --enable-helm "$tmp/argocd" > "$tmp/argocd.yaml"
|
||||
|
||||
$k create namespace argocd --dry-run=client -o yaml | $k apply -f -
|
||||
# CRDs must exist before the Argo CD objects that use them: apply twice.
|
||||
$k apply --server-side --force-conflicts -f "$tmp/argocd.yaml" >/dev/null 2>&1 || true
|
||||
sleep 8
|
||||
$k apply --server-side --force-conflicts -f "$tmp/argocd.yaml"
|
||||
$k -n argocd rollout status deploy --timeout=300s
|
||||
$k -n argocd rollout status statefulset --timeout=300s
|
||||
|
||||
$k apply --server-side --force-conflicts -f "$here/root.yaml"
|
||||
echo "Core state requested. Watch it with: $k -n argocd get app"
|
||||
@@ -1,29 +0,0 @@
|
||||
# Root of the core state. Applying this one object makes Argo CD pull every core
|
||||
# application in wave order (see k8s-ng/core-state/values.yaml).
|
||||
# Note: there are deliberately no finalizers; deleting this Application keeps all
|
||||
# deployed services and data.
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: core-state
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: core
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: argocd
|
||||
source:
|
||||
repoURL: https://gt.hexor.cy/ab/homelab.git
|
||||
targetRevision: main
|
||||
path: k8s-ng/core-state
|
||||
helm:
|
||||
# Per-cluster overrides of core-state/values.yaml, for example:
|
||||
# valuesObject:
|
||||
# targetRevision: some-branch
|
||||
valuesObject: {}
|
||||
syncPolicy:
|
||||
automated:
|
||||
selfHeal: true
|
||||
prune: true
|
||||
syncOptions:
|
||||
- ServerSideApply=true
|
||||
@@ -1,4 +0,0 @@
|
||||
apiVersion: v2
|
||||
name: core-state
|
||||
description: App of apps for the core services of the cluster
|
||||
version: 0.1.0
|
||||
@@ -1,32 +0,0 @@
|
||||
{{- range .Values.apps }}
|
||||
---
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: {{ .name }}
|
||||
namespace: argocd
|
||||
annotations:
|
||||
argocd.argoproj.io/sync-wave: {{ .wave | quote }}
|
||||
spec:
|
||||
project: {{ .project | default $.Values.project }}
|
||||
destination:
|
||||
server: {{ $.Values.destinationServer }}
|
||||
namespace: {{ .namespace }}
|
||||
source:
|
||||
repoURL: {{ $.Values.repoURL }}
|
||||
targetRevision: {{ $.Values.targetRevision }}
|
||||
path: {{ .path }}
|
||||
syncPolicy:
|
||||
automated:
|
||||
selfHeal: true
|
||||
prune: {{ if hasKey . "prune" }}{{ .prune }}{{ else }}true{{ end }}
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
- ServerSideApply=true
|
||||
{{- if and (hasKey . "validate") (not .validate) }}
|
||||
- Validate=false
|
||||
{{- end }}
|
||||
{{- if .skipDryRunOnMissingResource }}
|
||||
- SkipDryRunOnMissingResource=true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -1,146 +0,0 @@
|
||||
# Per-cluster variables. Override them in k8s-ng/bootstrap/root.yaml
|
||||
# (spec.source.helm.valuesObject) when the state is deployed to another cluster.
|
||||
repoURL: https://gt.hexor.cy/ab/homelab.git
|
||||
targetRevision: main
|
||||
destinationServer: https://kubernetes.default.svc
|
||||
project: core
|
||||
|
||||
# Core applications. Lower waves are synced first and must be Healthy before the
|
||||
# next wave starts. Every path is a kustomize (or plain manifest) directory.
|
||||
# wave 0: Argo CD itself and its projects
|
||||
# wave 1: operators (their CRDs are used by the later waves)
|
||||
# wave 2: the database cluster and its databases/users
|
||||
# wave 3: services that need the database and secrets
|
||||
apps:
|
||||
- name: argocd
|
||||
path: k8s-ng/core/argocd
|
||||
namespace: argocd
|
||||
wave: 0
|
||||
- name: cnpg
|
||||
path: k8s-ng/core/cnpg
|
||||
namespace: cnpg-system
|
||||
wave: 1
|
||||
- name: traefik-config
|
||||
path: k8s-ng/core/traefik-config
|
||||
namespace: kube-system
|
||||
wave: 1
|
||||
- name: coredns-config
|
||||
path: k8s-ng/core/coredns-config
|
||||
namespace: kube-system
|
||||
wave: 1
|
||||
validate: false # partial Deployment: only the fields we manage
|
||||
- name: reloader
|
||||
path: k8s-ng/core/reloader
|
||||
namespace: reloader
|
||||
wave: 1
|
||||
- name: gpu-system
|
||||
path: k8s-ng/core/gpu
|
||||
namespace: gpu-system
|
||||
wave: 1
|
||||
- name: cert-manager
|
||||
path: k8s-ng/core/cert-manager
|
||||
namespace: cert-manager
|
||||
wave: 1
|
||||
skipDryRunOnMissingResource: true # ClusterIssuers need the cert-manager CRDs
|
||||
- name: external-secrets
|
||||
path: k8s-ng/core/external-secrets
|
||||
namespace: external-secrets
|
||||
wave: 1
|
||||
- name: postgresql
|
||||
path: k8s-ng/core/postgresql
|
||||
namespace: psql
|
||||
wave: 2
|
||||
prune: false # never delete databases because of a manifest change
|
||||
skipDryRunOnMissingResource: true # CRDs come from the cnpg and external-secrets apps
|
||||
- name: vaultwarden
|
||||
path: k8s-ng/core/vaultwarden
|
||||
namespace: vaultwarden
|
||||
wave: 3
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: keycloak
|
||||
path: k8s-ng/core/keycloak
|
||||
namespace: keycloak
|
||||
wave: 3
|
||||
skipDryRunOnMissingResource: true # ExternalSecret/Certificate CRDs come from earlier waves
|
||||
# Not a core service: lives in k8s-ng/apps and belongs to the "apps" project.
|
||||
- name: furumi
|
||||
project: apps
|
||||
path: k8s-ng/apps/furumi
|
||||
namespace: furumi
|
||||
wave: 6 # after prom-stack installs the ServiceMonitor CRD
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: web-petting
|
||||
project: apps
|
||||
path: k8s-ng/apps/web-petting
|
||||
namespace: web-petting
|
||||
wave: 5
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: k8s-secrets
|
||||
project: apps
|
||||
path: k8s-ng/apps/k8s-secrets
|
||||
namespace: k8s-secret
|
||||
wave: 5 # after secret-stores and auth-proxy; independent of prom-stack health
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: llamacpp
|
||||
project: apps
|
||||
path: k8s-ng/apps/llamacpp
|
||||
namespace: llamacpp
|
||||
wave: 5 # pinned to the ai node (GPU); must not hold back the other waves
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: secret-stores
|
||||
path: k8s-ng/core/secret-stores
|
||||
namespace: external-secrets
|
||||
wave: 4 # reads the Vaultwarden vault, so it comes after vaultwarden
|
||||
skipDryRunOnMissingResource: true # ClusterSecretStore CRD comes from the external-secrets app
|
||||
- name: gitea
|
||||
path: k8s-ng/core/gitea
|
||||
namespace: gitea
|
||||
wave: 5 # after secret-stores (its secrets come from the vault); pinned to the music node; the runner to the ai node
|
||||
prune: false # never delete the instance because of a manifest change
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: prom-stack
|
||||
path: k8s-ng/core/prom-stack
|
||||
namespace: prometheus
|
||||
wave: 5 # after secret-stores; installs monitoring before application workloads
|
||||
skipDryRunOnMissingResource: true # monitoring, cert-manager and ExternalSecret CRDs
|
||||
- name: immich-db
|
||||
path: k8s-ng/core/immich-db
|
||||
namespace: immich
|
||||
wave: 2
|
||||
prune: false
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: minecraft
|
||||
project: games
|
||||
path: k8s-ng/apps/minecraft
|
||||
namespace: minecraft
|
||||
wave: 6
|
||||
- name: rustdesk
|
||||
project: apps
|
||||
path: k8s-ng/apps/rustdesk
|
||||
namespace: rustdesk
|
||||
wave: 6
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: shadowsocks
|
||||
project: apps
|
||||
path: k8s-ng/apps/shadowsocks
|
||||
namespace: shadowsocks
|
||||
wave: 6
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: mtproxy
|
||||
project: apps
|
||||
path: k8s-ng/apps/mtproxy
|
||||
namespace: mtproxy
|
||||
wave: 6 # after secret-stores and prom-stack
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: fdroidserver
|
||||
project: apps
|
||||
path: k8s-ng/apps/fdroidserver
|
||||
namespace: fdroidserver
|
||||
wave: 6 # after Gitea and secret-stores
|
||||
skipDryRunOnMissingResource: true
|
||||
- name: openartifact
|
||||
project: apps
|
||||
path: k8s-ng/apps/openartifact
|
||||
namespace: openartifact
|
||||
wave: 6
|
||||
skipDryRunOnMissingResource: true
|
||||
@@ -1,66 +0,0 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: AppProject
|
||||
metadata:
|
||||
name: core
|
||||
namespace: argocd
|
||||
spec:
|
||||
clusterResourceWhitelist:
|
||||
- group: '*'
|
||||
kind: '*'
|
||||
description: Hexor Home Lab Core
|
||||
destinations:
|
||||
- namespace: '*'
|
||||
server: https://kubernetes.default.svc
|
||||
sourceRepos:
|
||||
- https://gt.hexor.cy/ab/homelab.git
|
||||
|
||||
---
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: AppProject
|
||||
metadata:
|
||||
name: apps
|
||||
namespace: argocd
|
||||
spec:
|
||||
clusterResourceWhitelist:
|
||||
- group: '*'
|
||||
kind: '*'
|
||||
description: Hexor Home Lab Apps
|
||||
destinations:
|
||||
- namespace: '*'
|
||||
server: https://kubernetes.default.svc
|
||||
sourceRepos:
|
||||
- https://gt.hexor.cy/ab/homelab.git
|
||||
|
||||
---
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: AppProject
|
||||
metadata:
|
||||
name: games
|
||||
namespace: argocd
|
||||
spec:
|
||||
clusterResourceWhitelist:
|
||||
- group: '*'
|
||||
kind: '*'
|
||||
description: Hexor Home Lab Games
|
||||
destinations:
|
||||
- namespace: '*'
|
||||
server: https://kubernetes.default.svc
|
||||
sourceRepos:
|
||||
- https://gt.hexor.cy/ab/homelab.git
|
||||
|
||||
---
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: AppProject
|
||||
metadata:
|
||||
name: desktop
|
||||
namespace: argocd
|
||||
spec:
|
||||
clusterResourceWhitelist:
|
||||
- group: '*'
|
||||
kind: '*'
|
||||
description: Hexor Home Lab Desktop Apps
|
||||
destinations:
|
||||
- namespace: '*'
|
||||
server: https://kubernetes.default.svc
|
||||
sourceRepos:
|
||||
- https://gt.hexor.cy/ab/homelab.git
|
||||
@@ -1,26 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: argocd-dex-server
|
||||
namespace: argocd
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: dex-server
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: 5556
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 3
|
||||
successThreshold: 1
|
||||
failureThreshold: 3
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: 5556
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 3
|
||||
successThreshold: 1
|
||||
failureThreshold: 3
|
||||
@@ -1,25 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: argocd
|
||||
namespace: argocd
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- ag.btwiusearch.net
|
||||
secretName: argocd-server-tls
|
||||
rules:
|
||||
- host: ag.btwiusearch.net
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: argocd-server
|
||||
port:
|
||||
number: 80
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ingress.yaml
|
||||
- appprojects.yaml
|
||||
|
||||
helmCharts:
|
||||
- name: argo-cd
|
||||
repo: https://argoproj.github.io/argo-helm
|
||||
version: 10.6.0
|
||||
releaseName: argocd
|
||||
namespace: argocd
|
||||
valuesFile: values.yaml
|
||||
includeCRDs: true
|
||||
|
||||
patches:
|
||||
- path: dex-probes-patch.yaml
|
||||
@@ -1,116 +0,0 @@
|
||||
# Argo CD Helm Chart Values (k8s-ng cluster)
|
||||
|
||||
global:
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
domain: ag.btwiusearch.net
|
||||
logging:
|
||||
format: text
|
||||
level: info
|
||||
|
||||
crds:
|
||||
install: true
|
||||
keep: true # Recommended to keep true so CRDs are not deleted on uninstall
|
||||
|
||||
configs:
|
||||
params:
|
||||
server.insecure: "true" # TLS is terminated by the ingress
|
||||
cm:
|
||||
create: true
|
||||
exec.enabled: true
|
||||
kustomize.buildOptions: --enable-helm
|
||||
application.instanceLabelKey: argocd.argoproj.io/instance
|
||||
# Use Keycloak SSO only; disable the built-in password-based admin login.
|
||||
admin.enabled: false
|
||||
statusbadge.enabled: true
|
||||
timeout.reconciliation: 60s
|
||||
# Lets sync waves in an app of apps wait for child Applications to be Healthy.
|
||||
resource.customizations.health.argoproj.io_Application: |
|
||||
hs = {}
|
||||
hs.status = "Progressing"
|
||||
hs.message = ""
|
||||
if obj.status ~= nil then
|
||||
if obj.status.health ~= nil then
|
||||
hs.status = obj.status.health.status
|
||||
if obj.status.health.message ~= nil then
|
||||
hs.message = obj.status.health.message
|
||||
end
|
||||
end
|
||||
end
|
||||
return hs
|
||||
# SSO through Dex -> Keycloak. The client id/secret come from the oidc-creds
|
||||
# Secret (labelled app.kubernetes.io/part-of=argocd), created by hand until
|
||||
# Vaultwarden + External Secrets are the source.
|
||||
dex.config: |
|
||||
connectors:
|
||||
- type: oidc
|
||||
id: keycloak
|
||||
name: Keycloak
|
||||
config:
|
||||
issuer: https://auth.hexor.cy/auth/realms/hexor
|
||||
clientID: $oidc-creds:id
|
||||
clientSecret: $oidc-creds:secret
|
||||
insecureEnableGroups: true
|
||||
scopes:
|
||||
- openid
|
||||
- profile
|
||||
- email
|
||||
- offline_access
|
||||
getUserInfo: true
|
||||
rbac:
|
||||
create: true
|
||||
policy.default: ""
|
||||
policy.csv: |
|
||||
g, game-servers-managers, GameServersManagersRole
|
||||
# Role permissions
|
||||
p, GameServersManagersRole, applications, get, games/*, allow
|
||||
p, GameServersManagersRole, applications, update, games/*, allow
|
||||
p, GameServersManagersRole, applications, sync, games/*, allow
|
||||
p, GameServersManagersRole, applications, override, games/*, allow
|
||||
p, GameServersManagersRole, applications, action/*, games/*, allow
|
||||
p, GameServersManagersRole, exec, create, games/*, allow
|
||||
p, GameServersManagersRole, logs, get, games/*, allow
|
||||
p, GameServersManagersRole, applications, delete, games/*, deny
|
||||
|
||||
# Admin policy
|
||||
g, argocd-admins, role:admin
|
||||
secret:
|
||||
createSecret: true
|
||||
|
||||
controller:
|
||||
replicas: 1
|
||||
|
||||
# Dex OIDC provider (Keycloak connector configured in configs.cm.dex.config)
|
||||
dex:
|
||||
replicas: 1
|
||||
enabled: true
|
||||
|
||||
redis:
|
||||
enabled: true
|
||||
|
||||
redis-ha:
|
||||
enabled: false
|
||||
|
||||
server:
|
||||
replicas: 1
|
||||
ingress:
|
||||
enabled: false
|
||||
certificate:
|
||||
enabled: false
|
||||
certificateSecret:
|
||||
enabled: false
|
||||
|
||||
repoServer:
|
||||
replicas: 1
|
||||
livenessProbe:
|
||||
timeoutSeconds: 10
|
||||
periodSeconds: 60
|
||||
|
||||
applicationSet:
|
||||
enabled: true
|
||||
replicas: 1
|
||||
|
||||
notifications:
|
||||
enabled: true
|
||||
replicas: 1
|
||||
@@ -1,44 +0,0 @@
|
||||
# Public certificates through DNS-01 for the zones below and HTTP-01 (Traefik) for
|
||||
# every other domain, e.g. the .рф one. The credential Secrets are created by hand
|
||||
# (they will move to Vaultwarden + External Secrets):
|
||||
# kubectl -n cert-manager create secret generic cloudflare-api-token --from-literal=apiToken=<token>
|
||||
# (Zone:DNS:Edit on the btwiusearch.net zone)
|
||||
# kubectl -n cert-manager create secret generic aws-api-key-secret \
|
||||
# --from-literal=accessKey=<id> --from-literal=secretKey=<secret>
|
||||
# (Route53 access to the hexor.cy zone)
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: letsencrypt
|
||||
spec:
|
||||
acme:
|
||||
server: https://acme-v02.api.letsencrypt.org/directory
|
||||
email: k8s-master@hexor.cy
|
||||
privateKeySecretRef:
|
||||
name: letsencrypt-account-key
|
||||
solvers:
|
||||
- selector:
|
||||
dnsZones:
|
||||
- btwiusearch.net
|
||||
dns01:
|
||||
cloudflare:
|
||||
apiTokenSecretRef:
|
||||
name: cloudflare-api-token
|
||||
key: apiToken
|
||||
- selector:
|
||||
dnsZones:
|
||||
- hexor.cy
|
||||
dns01:
|
||||
route53:
|
||||
region: eu-north-1
|
||||
accessKeyIDSecretRef:
|
||||
name: aws-api-key-secret
|
||||
key: accessKey
|
||||
secretAccessKeySecretRef:
|
||||
name: aws-api-key-secret
|
||||
key: secretKey
|
||||
# Fallback for domains outside the zones above: their A records must point
|
||||
# at the cluster nodes (Traefik answers on port 80 everywhere).
|
||||
- http01:
|
||||
ingress:
|
||||
ingressClassName: traefik
|
||||
@@ -1,15 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- issuer.yaml
|
||||
- self-signed.yaml
|
||||
|
||||
helmCharts:
|
||||
- name: cert-manager
|
||||
repo: https://charts.jetstack.io
|
||||
version: 1.21.1
|
||||
releaseName: cert-manager
|
||||
namespace: cert-manager
|
||||
valuesFile: values.yaml
|
||||
includeCRDs: true
|
||||
@@ -1,29 +0,0 @@
|
||||
# Private CA for internal services: issuer "hexor-lab".
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: selfsigned
|
||||
spec:
|
||||
selfSigned: {}
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: hexor-ca-root
|
||||
namespace: cert-manager
|
||||
spec:
|
||||
isCA: true
|
||||
duration: 87600h # 10y
|
||||
commonName: hexor-ca
|
||||
secretName: hexor-ca-root-secret
|
||||
issuerRef:
|
||||
name: selfsigned
|
||||
kind: ClusterIssuer
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: hexor-lab
|
||||
spec:
|
||||
ca:
|
||||
secretName: hexor-ca-root-secret
|
||||
@@ -1,12 +0,0 @@
|
||||
crds:
|
||||
enabled: true
|
||||
|
||||
nodeSelector: &externalCore
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
webhook:
|
||||
nodeSelector: *externalCore
|
||||
cainjector:
|
||||
nodeSelector: *externalCore
|
||||
startupapicheck:
|
||||
nodeSelector: *externalCore
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
helmCharts:
|
||||
- name: cloudnative-pg
|
||||
repo: https://cloudnative-pg.github.io/charts
|
||||
version: 0.29.1
|
||||
releaseName: cnpg
|
||||
namespace: cnpg-system
|
||||
valuesFile: values.yaml
|
||||
includeCRDs: true
|
||||
@@ -1,8 +0,0 @@
|
||||
# CloudNativePG operator (chart 0.29.x = operator 1.30.x)
|
||||
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
|
||||
crds:
|
||||
create: true
|
||||
@@ -1,33 +0,0 @@
|
||||
# K3s owns the CoreDNS Deployment. Apply only the fields customized here so
|
||||
# upstream image, probes, Corefile mounts and topology spread stay intact.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: coredns
|
||||
namespace: kube-system
|
||||
annotations:
|
||||
argocd.argoproj.io/sync-options: Prune=false,Delete=false
|
||||
spec:
|
||||
replicas: 3
|
||||
template:
|
||||
spec:
|
||||
tolerations:
|
||||
- key: CriticalAddonsOnly
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
# DNS also belongs on the internal core node used by Actions jobs.
|
||||
- key: workload
|
||||
operator: Equal
|
||||
value: ai
|
||||
effect: NoSchedule
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: homelab.hexor.cy/pool
|
||||
operator: In
|
||||
values:
|
||||
- core
|
||||
@@ -1,6 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -1,11 +0,0 @@
|
||||
# Keep DNS on the caller's node when it has a healthy CoreDNS replica. K3s owns
|
||||
# the rest of this Service; server-side apply preserves its ports and selector.
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: kube-dns
|
||||
namespace: kube-system
|
||||
annotations:
|
||||
argocd.argoproj.io/sync-options: Prune=false,Delete=false
|
||||
spec:
|
||||
trafficDistribution: PreferSameNode
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
# The Vaultwarden bridge and the ClusterSecretStores are in ../secret-stores (they need Vaultwarden).
|
||||
|
||||
helmCharts:
|
||||
- name: external-secrets
|
||||
repo: https://charts.external-secrets.io
|
||||
version: 2.11.0
|
||||
releaseName: external-secrets
|
||||
namespace: external-secrets
|
||||
valuesFile: values.yaml
|
||||
includeCRDs: true
|
||||
@@ -1,9 +0,0 @@
|
||||
installCRDs: true
|
||||
|
||||
nodeSelector: &externalCore
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
webhook:
|
||||
nodeSelector: *externalCore
|
||||
certController:
|
||||
nodeSelector: *externalCore
|
||||
@@ -1,72 +0,0 @@
|
||||
# Gitea with SQLite; everything (repositories, database, SSH host keys) lives in
|
||||
# /var/lib/gitea on the music node.
|
||||
# `replicas` is deliberately not set: Argo CD does not manage it, so the instance
|
||||
# can be scaled to 0 with kubectl during a data migration without being healed back.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gitea
|
||||
labels:
|
||||
app: gitea
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gitea
|
||||
strategy:
|
||||
type: Recreate # two instances must never open the same SQLite database
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gitea
|
||||
spec:
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
kubernetes.io/hostname: music
|
||||
volumes:
|
||||
- name: storage
|
||||
hostPath:
|
||||
path: /var/lib/gitea
|
||||
type: DirectoryOrCreate
|
||||
containers:
|
||||
- name: gitea
|
||||
image: gitea/gitea:28.0.0
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: "1"
|
||||
limits:
|
||||
memory: 4Gi
|
||||
cpu: "4"
|
||||
env:
|
||||
- name: GITEA__service__REGISTER_MANUAL_CONFIRM
|
||||
value: "true"
|
||||
- name: GITEA__service__ENABLE_CAPTCHA
|
||||
value: "true"
|
||||
- name: GITEA__service__REQUIRE_CAPTCHA_FOR_LOGIN
|
||||
value: "false"
|
||||
- name: GITEA__service__REQUIRE_EXTERNAL_REGISTRATION_CAPTCHA
|
||||
value: "true"
|
||||
- name: GITEA__service__CAPTCHA_TYPE
|
||||
value: cfturnstile
|
||||
- name: GITEA__security__ALLOWED_HOST_LIST
|
||||
value: "*"
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: gitea-runner-act-runner-secrets
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
protocol: TCP
|
||||
- name: ssh
|
||||
containerPort: 22
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/healthz
|
||||
port: http
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
volumeMounts:
|
||||
- name: storage
|
||||
mountPath: /data
|
||||
@@ -1,44 +0,0 @@
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: gitea-runner-token
|
||||
spec:
|
||||
refreshInterval: 1m
|
||||
target:
|
||||
name: gitea-runner-act-runner-secrets
|
||||
deletionPolicy: Delete
|
||||
template:
|
||||
type: Opaque
|
||||
data:
|
||||
token: |-
|
||||
{{ .password }}
|
||||
GITEA__service__CF_TURNSTILE_SITEKEY: |-
|
||||
{{ .CF_TURNSTILE_SITEKEY }}
|
||||
GITEA__service__CF_TURNSTILE_SECRET: |-
|
||||
{{ .CF_TURNSTILE_SECRET }}
|
||||
data:
|
||||
- secretKey: password
|
||||
sourceRef:
|
||||
storeRef:
|
||||
name: vaultwarden-login
|
||||
kind: ClusterSecretStore
|
||||
remoteRef:
|
||||
key: k8s/gitea/secrets
|
||||
property: login.password
|
||||
- secretKey: CF_TURNSTILE_SITEKEY
|
||||
sourceRef:
|
||||
storeRef:
|
||||
name: vaultwarden-login
|
||||
kind: ClusterSecretStore
|
||||
remoteRef:
|
||||
key: k8s/gitea/secrets
|
||||
property: fields[0].value
|
||||
- secretKey: CF_TURNSTILE_SECRET
|
||||
sourceRef:
|
||||
storeRef:
|
||||
name: vaultwarden-login
|
||||
kind: ClusterSecretStore
|
||||
remoteRef:
|
||||
key: k8s/gitea/secrets
|
||||
property: fields[1].value
|
||||
@@ -1,23 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: gitea
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
spec:
|
||||
rules:
|
||||
- host: gt.hexor.cy
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: gitea
|
||||
port:
|
||||
number: 80
|
||||
tls:
|
||||
- secretName: gitea-tls
|
||||
hosts:
|
||||
- gt.hexor.cy
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- external-secrets.yaml
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- ingress.yaml
|
||||
- runner.yaml
|
||||
- runner-rbac.yaml
|
||||
- user-unban-cronjob.yaml
|
||||
@@ -1,41 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: gitea-runner
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: gitea-runner-kubernetes-token
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: gitea-runner
|
||||
type: kubernetes.io/service-account-token
|
||||
---
|
||||
# CI may edit the routes of the auth proxy (the ConfigMap lives in the keycloak namespace here).
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: auth-proxy-routes-manager
|
||||
namespace: keycloak
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: [configmaps]
|
||||
resourceNames: [auth-proxy-routes]
|
||||
verbs: [get, update, patch]
|
||||
- apiGroups: [""]
|
||||
resources: [configmaps]
|
||||
verbs: [create]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: gitea-runner-auth-proxy-routes
|
||||
namespace: keycloak
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: auth-proxy-routes-manager
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: gitea-runner
|
||||
namespace: gitea
|
||||
@@ -1,86 +0,0 @@
|
||||
# Gitea Actions runner on the ai node. Jobs run as containers in the host's Docker
|
||||
# (virtualisation.docker in hosts/ai of the nix repo) through the mounted socket.
|
||||
# `replicas` is not set (see deployment.yaml): scale it with kubectl when needed.
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: gitea-runner-config
|
||||
data:
|
||||
config.yaml: |
|
||||
runner:
|
||||
capacity: 8 # jobs in parallel; the ai node has 32 threads and 124 GiB
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gitea-runner
|
||||
labels:
|
||||
app: gitea-runner
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gitea-runner
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gitea-runner
|
||||
spec:
|
||||
serviceAccountName: gitea-runner
|
||||
dnsConfig:
|
||||
options:
|
||||
- name: ndots
|
||||
value: "2"
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: internal
|
||||
workload/ai: "true"
|
||||
tolerations:
|
||||
- key: workload
|
||||
operator: Equal
|
||||
value: ai
|
||||
effect: NoSchedule
|
||||
volumes:
|
||||
- name: docker-sock
|
||||
hostPath:
|
||||
path: /var/run/docker.sock
|
||||
type: Socket
|
||||
- name: runner-data
|
||||
emptyDir:
|
||||
sizeLimit: 30Gi
|
||||
- name: config
|
||||
configMap:
|
||||
name: gitea-runner-config
|
||||
containers:
|
||||
- name: gitea-runner
|
||||
image: gitea/act_runner:nightly
|
||||
volumeMounts:
|
||||
- name: docker-sock
|
||||
mountPath: /var/run/docker.sock
|
||||
- name: runner-data
|
||||
mountPath: /data
|
||||
- name: config
|
||||
mountPath: /config.yaml
|
||||
subPath: config.yaml
|
||||
env:
|
||||
- name: CONFIG_FILE
|
||||
value: /config.yaml
|
||||
- name: GITEA_INSTANCE_URL
|
||||
# Job containers run outside the cluster network, so they need the public URL.
|
||||
value: https://gt.hexor.cy
|
||||
- name: GITEA_RUNNER_REGISTRATION_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gitea-runner-act-runner-secrets
|
||||
key: token
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: GITEA_RUNNER_NAME
|
||||
value: $(NODE_NAME)
|
||||
- name: GITEA_RUNNER_LABELS
|
||||
value: ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-latest,ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-22.04,ubuntu-20.04:docker://ghcr.io/catthehacker/ubuntu:act-20.04
|
||||
@@ -1,24 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gitea
|
||||
spec:
|
||||
selector:
|
||||
app: gitea
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
---
|
||||
# Git over SSH on every node (servicelb); the node firewall opens 30022 (nix repo, k3s-base.nix).
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gitea-ssh
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- port: 30022
|
||||
targetPort: 22
|
||||
selector:
|
||||
app: gitea
|
||||
@@ -1,61 +0,0 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: gitea-user-unban
|
||||
labels:
|
||||
app: gitea-user-unban
|
||||
spec:
|
||||
schedule: "*/10 * * * *"
|
||||
concurrencyPolicy: Forbid
|
||||
successfulJobsHistoryLimit: 3
|
||||
failedJobsHistoryLimit: 3
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gitea-user-unban
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
nodeSelector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: external
|
||||
kubernetes.io/hostname: music
|
||||
volumes:
|
||||
- name: storage
|
||||
hostPath:
|
||||
path: /var/lib/gitea
|
||||
type: Directory
|
||||
containers:
|
||||
- name: sqlite-unban
|
||||
image: gitea/gitea:28.0.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
resources:
|
||||
requests:
|
||||
memory: 32Mi
|
||||
cpu: 10m
|
||||
limits:
|
||||
memory: 128Mi
|
||||
cpu: 100m
|
||||
command:
|
||||
- /bin/sh
|
||||
- -ec
|
||||
- |
|
||||
sqlite3 -cmd ".timeout 30000" /data/gitea/gitea.db "
|
||||
UPDATE \"user\"
|
||||
SET is_active = 1,
|
||||
prohibit_login = 0,
|
||||
updated_unix = unixepoch()
|
||||
WHERE lower(email) = lower('ab@hexor.cy')
|
||||
AND (is_active <> 1 OR prohibit_login <> 0);
|
||||
|
||||
SELECT printf(
|
||||
'gitea user watchdog: id=%d login=%s email=%s is_active=%d prohibit_login=%d updated_unix=%d',
|
||||
id, lower_name, email, is_active, prohibit_login, updated_unix
|
||||
)
|
||||
FROM \"user\"
|
||||
WHERE lower(email) = lower('ab@hexor.cy');
|
||||
"
|
||||
volumeMounts:
|
||||
- name: storage
|
||||
mountPath: /data
|
||||
@@ -1,28 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
helmCharts:
|
||||
- name: amd-gpu
|
||||
repo: https://rocm.github.io/k8s-device-plugin/
|
||||
version: 0.22.0
|
||||
releaseName: amd-gpu-device-plugin
|
||||
namespace: gpu-system
|
||||
valuesFile: values.yaml
|
||||
includeCRDs: true
|
||||
|
||||
# The chart always adds the NFD label feature.node.kubernetes.io/pci-0300_1002.present
|
||||
# to the selector; NFD is not installed (and would not match this iGPU), so replace it.
|
||||
patches:
|
||||
- target:
|
||||
group: apps
|
||||
version: v1
|
||||
kind: DaemonSet
|
||||
name: amd-gpu-device-plugin-daemonset
|
||||
patch: |-
|
||||
- op: replace
|
||||
path: /spec/template/spec/nodeSelector
|
||||
value:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: internal
|
||||
kubernetes.io/arch: amd64
|
||||
workload/ai: "true"
|
||||
@@ -1,37 +0,0 @@
|
||||
# AMD GPU device plugin: exposes the Strix Halo iGPU of the "ai" node as the
|
||||
# amd.com/gpu resource (and injects /dev/kfd and /dev/dri into the pod).
|
||||
nfd:
|
||||
enabled: false
|
||||
|
||||
labeller:
|
||||
enabled: false
|
||||
|
||||
dp:
|
||||
image:
|
||||
repository: docker.io/rocm/k8s-device-plugin
|
||||
tag: "1.31.0.9"
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
|
||||
# The ai node carries the label workload/ai=true and the taint workload=ai:NoSchedule
|
||||
# (hosts/ai in the nix repo).
|
||||
tolerations:
|
||||
- key: workload
|
||||
operator: Equal
|
||||
value: ai
|
||||
effect: NoSchedule
|
||||
|
||||
node_selector_enabled: true
|
||||
node_selector:
|
||||
homelab.hexor.cy/pool: core
|
||||
homelab.hexor.cy/exposure: internal
|
||||
kubernetes.io/arch: amd64
|
||||
workload/ai: "true"
|
||||
Loaded 100 of 345 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user