Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions kubernetes/apps/selfhosted/resume/app/blog-builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
# Builds derekmackley.com/blog from pushed articles. Every few minutes it hashes
# blog-content/articles; when they (or the builder image) changed it runs `astro build`
# in scratch space, copies the result to blog-content/site/releases/<stamp>-<hash> and
# switches site/current to it with one rename, keeping the newest three releases. When
# nothing changed it exits in about a second.
#
# It never sees the Obsidian vault: the only volume is blog-content. Articles arrive
# there from the private-side push; the resume pod serves site/current read-only.
# Image: developer-portfolio's blog/Dockerfile (ghcr.io/dapperdivers/developer-portfolio-blog).
# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/main/charts/other/app-template/schemas/helmrelease-helm-v2.schema.json
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: blog-builder
spec:
interval: 30m
chartRef:
kind: OCIRepository
name: app-template
install:
remediation:
retries: 3
upgrade:
cleanupOnFail: true
remediation:
strategy: rollback
retries: 3
values:
defaultPodOptions:
securityContext:
runAsUser: 1000
runAsGroup: 1000
runAsNonRoot: true
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
seccompProfile:
type: RuntimeDefault
controllers:
blog-builder:
type: cronjob
cronjob:
schedule: "*/5 * * * *"
concurrencyPolicy: Forbid
activeDeadlineSeconds: 900
successfulJobsHistory: 1
failedJobsHistory: 2
containers:
app:
image:
repository: ghcr.io/dapperdivers/developer-portfolio-blog
# Pin to the first published image's tag@digest before merging (see the PR)
tag: latest
env:
ARTICLES_DIR: /content/articles
SITE_DIR: /content/site
KEEP_RELEASES: "3"
resources:
requests:
cpu: 50m
memory: 256Mi
limits:
memory: 1Gi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
persistence:
content:
existingClaim: blog-content
globalMounts:
- path: /content
tmp:
type: emptyDir
sizeLimit: 1Gi
globalMounts:
- path: /tmp
12 changes: 12 additions & 0 deletions kubernetes/apps/selfhosted/resume/app/helmrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ spec:
# would put every visitor in one bucket. Rate limit at the
# Cloudflare edge instead.
RATE_LIMIT_MAX: "0"
# The live blog release: blog-builder points site/current at the newest
# build with an atomic symlink switch, so no restart is needed
BLOG_PATH: /app/blog-static/site/current
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
Expand Down Expand Up @@ -89,6 +92,15 @@ spec:
app:
- path: /tmp
readOnly: false
# The blog volume (PVC from ../ks.yaml), read-only. The app serves only site/current
# (BLOG_PATH); articles/ is the builder's input and is never served.
blog:
existingClaim: blog-content
advancedMounts:
resume:
app:
- path: /app/blog-static
readOnly: true
service:
app:
controller: *app
Expand Down
1 change: 1 addition & 0 deletions kubernetes/apps/selfhosted/resume/app/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
- ./blog-builder.yaml
7 changes: 7 additions & 0 deletions kubernetes/apps/selfhosted/resume/blog/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Intentionally empty: the Flux Kustomization injects the volsync components, which
# create the blog-content PVC and its backup/restore resources.
# yaml-language-server: $schema=https://json.schemastore.org/kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: []
44 changes: 44 additions & 0 deletions kubernetes/apps/selfhosted/resume/ks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ spec:
dependsOn:
- name: volsync
namespace: storage
- name: blog-content
namespace: selfhosted
path: "./kubernetes/apps/selfhosted/resume/app"
prune: true
sourceRef:
Expand All @@ -26,3 +28,45 @@ spec:
postBuild:
substitute:
APP: *app
---
# The built blog served at derekmackley.com/blog. A publisher job writes the static
# site here; the resume pod mounts it read-only. Content is rebuilt from the vault, so
# a daily backup is plenty; it restores itself if the PVC is ever recreated.
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/kustomize.toolkit.fluxcd.io/kustomization_v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app blog-content
namespace: &namespace selfhosted
spec:
targetNamespace: *namespace
components:
- ../../../../flux/components/volsync/repository
- ../../../../flux/components/volsync/operations
commonMetadata:
labels:
app.kubernetes.io/name: *app
dependsOn:
- name: volsync
namespace: storage
path: ./kubernetes/apps/selfhosted/resume/blog
prune: true
sourceRef:
kind: GitRepository
name: flux-system
namespace: flux-system
wait: true
interval: 30m
retryInterval: 1m
timeout: 10m
postBuild:
substitute:
APP: *app
VOLSYNC_CAPACITY: 2Gi
VOLSYNC_CACHE_CAPACITY: 1Gi
VOLSYNC_STORAGECLASS: cephfs-shared
VOLSYNC_SNAPSHOTCLASS: cephfs-snapshot
VOLSYNC_ACCESSMODES: ReadWriteMany # publisher job writes, resume pods read
VOLSYNC_SCHEDULE: "0 3 * * *"
VOLSYNC_PUID: "1000"
VOLSYNC_PGID: "1000"
Loading