A partir d'un simple fichier YAML descriptif, une application basée sur wiki.js va s'autodéployer sur le cluster. Elle répondra automatiquement au nom de wiki.cluster.labk3s.ev1 sans avoir de modification DNS à réaliser.
Cette application aura l'ensemble de ses données persistée sur le stockage longhorn. En cas de défaillance d'un noeud, l'application reprendra automatiquement sur un autre noeud du cluster sans interruption de service.
# ------------------------------------------------------------
# Namespace dédié (isolation propre)
# ------------------------------------------------------------
apiVersion: v1
kind: Namespace
metadata:
name: wikijs
---
# ------------------------------------------------------------
# Secret des identifiants PostgreSQ
# ------------------------------------------------------------
apiVersion: v1
kind: Secret
metadata:
name: wikijs-postgres-secret
namespace: wikijs
type: Opaque
stringData:
POSTGRES_DB: wikijs
POSTGRES_USER: wikijs
POSTGRES_PASSWORD: "ChangeMe-SuperSecret"
---
# ------------------------------------------------------------
# PVC PostgreSQL (Longhorn)
# ------------------------------------------------------------
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wikijs-postgres-pvc
namespace: wikijs
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 10Gi
---
# ------------------------------------------------------------
# Déploiement PostgreSQL
# - FIX: PGDATA dans un sous-répertoire (évite lost+found)
# ------------------------------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: wikijs-postgres
namespace: wikijs
spec:
replicas: 1
selector:
matchLabels:
app: wikijs-postgres
template:
metadata:
labels:
app: wikijs-postgres
spec:
containers:
- name: postgres
image: postgres:16
ports:
- containerPort: 5432
envFrom:
- secretRef:
name: wikijs-postgres-secret
env:
# IMPORTANT: évite l'erreur initdb "directory exists but is not empty (lost+found)"
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
readinessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 30
periodSeconds: 10
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: wikijs-postgres-pvc
---
# ------------------------------------------------------------
# Service PostgreSQL (ClusterIP)
# ------------------------------------------------------------
apiVersion: v1
kind: Service
metadata:
name: wikijs-postgres
namespace: wikijs
spec:
type: ClusterIP
selector:
app: wikijs-postgres
ports:
- name: pg
port: 5432
targetPort: 5432
---
# ------------------------------------------------------------
# PVC Wiki.js (Longhorn)
# ------------------------------------------------------------
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wikijs-data-pvc
namespace: wikijs
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 5Gi
---
# ------------------------------------------------------------
# Déploiement Wiki.js
# ------------------------------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: wikijs
namespace: wikijs
spec:
replicas: 1
selector:
matchLabels:
app: wikijs
template:
metadata:
labels:
app: wikijs
spec:
containers:
- name: wikijs
image: ghcr.io/requarks/wiki:2
ports:
- containerPort: 3000
env:
# --- Base de données ---
- name: DB_TYPE
value: postgres
- name: DB_HOST
value: wikijs-postgres
- name: DB_PORT
value: "5432"
- name: DB_NAME
valueFrom:
secretKeyRef:
name: wikijs-postgres-secret
key: POSTGRES_DB
- name: DB_USER
valueFrom:
secretKeyRef:
name: wikijs-postgres-secret
key: POSTGRES_USER
- name: DB_PASS
valueFrom:
secretKeyRef:
name: wikijs-postgres-secret
key: POSTGRES_PASSWORD
# --- URL publique du wiki ---
- name: WIKI_PUBLIC_URL
value: "http://wiki.cluster.labk3s.ev1"
volumeMounts:
- name: wikijs-data
mountPath: /wiki/data
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 30
periodSeconds: 10
volumes:
- name: wikijs-data
persistentVolumeClaim:
claimName: wikijs-data-pvc
---
# ------------------------------------------------------------
# Service Wiki.js (ClusterIP)
# ------------------------------------------------------------
apiVersion: v1
kind: Service
metadata:
name: wikijs
namespace: wikijs
spec:
type: ClusterIP
selector:
app: wikijs
ports:
- name: http
port: 3000
targetPort: 3000
---
# ------------------------------------------------------------
# Ingress Traefik
# ------------------------------------------------------------
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: wikijs
namespace: wikijs
spec:
ingressClassName: traefik
rules:
- host: wiki.cluster.labk3s.ev1
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: wikijs
port:
number: 3000
root@kube-01:/opt/k3s_services# mkdir /opt/k3s_services/wikijs
root@kube-01:/opt/k3s_services# cd /opt/k3s_services/wikijs/
root@kube-01:/opt/k3s_services/wikijs# vim wiki.yaml
root@kube-01:/opt/k3s_services/wikijs# kubectl apply -f wiki.yaml
root@kube-01:/opt/k3s_services/wikijs# kubectl -n wikijs get pods -w
NAME READY STATUS RESTARTS AGE
wikijs-585768c95f-b68dh 0/1 ContainerCreating 0 2s
wikijs-postgres-597f8dc6f6-7nqzz 0/1 ContainerCreating 0 2s
root@kube-01:/opt/k3s_services/wikijs# kubectl -n wikijs get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
wikijs-data-pvc Bound pvc-5642a577-09a6-4fa4-8e22-4036c108b0c8 5Gi RWO longhorn <unset> 33s
wikijs-postgres-pvc Bound pvc-b05adba8-4586-45a9-8dfe-8f3715cb0da9 10Gi RWO longhorn <unset> 34s
root@kube-01:/opt/k3s_services/wikijs# kubectl get ingress -n wikijs
NAME CLASS HOSTS ADDRESS PORTS AGE
wikijs traefik wiki.cluster.labk3s.ev1 192.168.50.250 80 63s
root@kube-02:/home/guillaume# curl -I -H "Host: wiki.cluster.labk3s.ev1" http://192.168.50.250
HTTP/1.1 200 OK
Content-Length: 1315
Content-Type: text/html; charset=utf-8
Date: Sat, 17 Jan 2026 14:45:49 GMT
Etag: W/"523-j2XVGs+K7xi45W9wBfUre0sLJmU"
Vary: Accept-Encoding
X-Powered-By: Express
Le wiki est opérationnel!