feat(k8s/blog): add static blog served via git-sync + nginx
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blog-nginx-config
|
||||
namespace: blog
|
||||
data:
|
||||
default.conf: |
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
root /git/current;
|
||||
index index.html;
|
||||
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "OK";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
location ~ /\.git {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: blog
|
||||
namespace: blog
|
||||
labels:
|
||||
app: blog
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: blog
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: blog
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
# git-sync (uid 65533) writes files; fsGroup makes the emptyDir group-writable by that uid
|
||||
fsGroup: 65533
|
||||
initContainers:
|
||||
- name: git-sync-init
|
||||
image: registry.k8s.io/git-sync/git-sync:v4.5.1
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: GITSYNC_REPO
|
||||
value: "https://${GITEA_HOST}/oleksandr/blog.git"
|
||||
- name: GITSYNC_ROOT
|
||||
value: "/git"
|
||||
- name: GITSYNC_REF
|
||||
value: "gh-pages"
|
||||
- name: GITSYNC_LINK
|
||||
value: "current"
|
||||
- name: GITSYNC_DEPTH
|
||||
value: "1"
|
||||
- name: GITSYNC_ONE_TIME
|
||||
value: "true"
|
||||
- name: GITSYNC_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-git-credentials
|
||||
key: GITSYNC_USERNAME
|
||||
- name: GITSYNC_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-git-credentials
|
||||
key: GITSYNC_PASSWORD
|
||||
securityContext:
|
||||
runAsUser: 65533
|
||||
runAsGroup: 65533
|
||||
volumeMounts:
|
||||
- name: git-content
|
||||
mountPath: /git
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
memory: 128Mi
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginxinc/nginx-unprivileged:1.30.0-alpine3.23
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: http
|
||||
protocol: TCP
|
||||
securityContext:
|
||||
runAsUser: 101
|
||||
runAsGroup: 101
|
||||
volumeMounts:
|
||||
- name: git-content
|
||||
mountPath: /git
|
||||
- name: nginx-config
|
||||
mountPath: /etc/nginx/conf.d/default.conf
|
||||
subPath: default.conf
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /health
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 30
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /health
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 64Mi
|
||||
- name: git-sync
|
||||
image: registry.k8s.io/git-sync/git-sync:v4.5.1
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: GITSYNC_REPO
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-git-credentials
|
||||
key: GITSYNC_REPO
|
||||
- name: GITSYNC_ROOT
|
||||
value: "/git"
|
||||
- name: GITSYNC_REF
|
||||
value: "gh-pages"
|
||||
- name: GITSYNC_LINK
|
||||
value: "current"
|
||||
- name: GITSYNC_DEPTH
|
||||
value: "1"
|
||||
- name: GITSYNC_PERIOD
|
||||
value: "30s"
|
||||
- name: GITSYNC_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-git-credentials
|
||||
key: GITSYNC_USERNAME
|
||||
- name: GITSYNC_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-git-credentials
|
||||
key: GITSYNC_PASSWORD
|
||||
securityContext:
|
||||
runAsUser: 65533
|
||||
runAsGroup: 65533
|
||||
volumeMounts:
|
||||
- name: git-content
|
||||
mountPath: /git
|
||||
resources:
|
||||
requests:
|
||||
cpu: 5m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 64Mi
|
||||
volumes:
|
||||
- name: git-content
|
||||
emptyDir: {}
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: blog-nginx-config
|
||||
@@ -0,0 +1,23 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: blog
|
||||
namespace: blog
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- ${BLOG_HOST}
|
||||
secretName: blog-tls
|
||||
rules:
|
||||
- host: ${BLOG_HOST}
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: blog
|
||||
port:
|
||||
number: 8080
|
||||
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: blog
|
||||
@@ -0,0 +1,26 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny-ingress
|
||||
namespace: blog
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: allow-ingress-controller
|
||||
namespace: blog
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: blog
|
||||
policyTypes:
|
||||
- Ingress
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: traefik
|
||||
@@ -0,0 +1,24 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: blog-git-credentials
|
||||
namespace: blog
|
||||
stringData:
|
||||
GITSYNC_USERNAME: ENC[AES256_GCM,data:6cZnsgZ53xsU,iv:j2qvZr+odimHPnlMKz9xTe8q+zXvyRDF9spH8TkcmBw=,tag:ik6DJ4cMfcNc5UHY5vRy3A==,type:str]
|
||||
GITSYNC_PASSWORD: ENC[AES256_GCM,data:mjQJuOuH2YQ1i1JVO+lFZ7WYLmy4RjCi2xZRErU5hRNi2SdgRo0fwg==,iv:9pl3nVmlnynJ4jMke1Hy4ACBuMyM+65vmGR2kS705I0=,tag:K1dQ9YwVN0sZjieAOU3KWw==,type:str]
|
||||
GITSYNC_REPO: ENC[AES256_GCM,data:ETjdkCP/PSa6HSD9M6JdvWbci/lRwegzzyuPb/IQmX58sxwqT2gUjooVKtcylzsE,iv:kOpvSQYznyxfmLjrehdRuEtwevoceDo0h/vbXTuu/i8=,tag:x+DEmoZUxRN6OksDJ9mQIQ==,type:str]
|
||||
sops:
|
||||
age:
|
||||
- enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBYR3FFRWdPajVzbjZGem1N
|
||||
OXA2aVhtSWRxQUpGcDFxLzBFQWkyMlh5L2pvCkgvM25IVTBqSFZ3QmJDaGxqSTJ2
|
||||
blQyOTQwaThRbkhzZ01uUmVoaXg5VHMKLS0tIHJJWlJoSmRXRi90M2VHSTlvdnBH
|
||||
VjRWTHRSWUE0VFpqakwxUmx3aENqYUUK21JXxrt792sHoI2TCYU3aIQKKLL9f8oq
|
||||
1o+qkueVYSYmVetrqcjSWqfGE496BYi+pd4a0mmRwaLpLCZIIgtlvA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
recipient: age1zffnskvuezntkk703a0pyxsd5m8vx2hm33dr47wdfy8mn4fdw4sqgw0jgc
|
||||
encrypted_regex: ^(data|stringData|email)$
|
||||
lastmodified: "2026-05-11T19:25:53Z"
|
||||
mac: ENC[AES256_GCM,data:jK/48Q7INbbcjZWASbS7ob1RrfDNm27jGnm1taL7hEMDC0k7n3igqlqSHmy7ZxCeUUe3Y+s7Jv9Ss1xITEPoUEYFphGrYeDUBVNtVfhBavTEaTPAuEv7WRA8xGpjXH0t9ernwwMyMQJRatazgX2jcc3rfzHMshs7cf5oeov15Zk=,iv:lg0ad1nDFDHBPv8Xvsn63V7SDPMo1p47gvSNFGJGw1I=,tag:fXatyOSOD/rCjEcpvDQpAw==,type:str]
|
||||
version: 3.13.0
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: blog
|
||||
namespace: blog
|
||||
spec:
|
||||
selector:
|
||||
app: blog
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
name: http
|
||||
Reference in New Issue
Block a user