Skip to content

Docs site deployment

Overview

This wiki covers the full implementation of our documentation site using MkDocs Material, deployed on Kubernetes (K3s) with APISIX ingress and served at developer.castis.io.


Stack

Component Technology
Documentation framework MkDocs Material 9.7.6
Container Docker (multi-stage, nginx:alpine)
Registry registry.nexus.castis.io
Orchestration K3s
Ingress APISIX
TLS cert-manager + Let's Encrypt
GitOps ArgoCD

Project Structure

documentations/
├── docs/               # Markdown source files
├── Dockerfile
├── nginx.conf
└── mkdocs.yml

Dockerfile

Multi-stage build: MkDocs builds the static site, nginx serves it.

FROM squidfunk/mkdocs-material:9.7.6 AS builder

RUN pip install \
    mkdocs-render-swagger-plugin \
    mkdocs-git-revision-date-localized-plugin

WORKDIR /docs
COPY . .
RUN mkdocs build

FROM nginx:alpine
COPY --from=builder /docs/site /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

nginx.conf

Minimal config for serving MkDocs static output.

server {
    listen 80;
    server_name developer.castis.io;

    root /usr/share/nginx/html;
    index index.html;

    location / {
        try_files $uri $uri/ $uri.html =404;
    }

    error_page 404 /404.html;
}

try_files $uri $uri/ $uri.html is required for MkDocs URL structure to resolve correctly.


Kubernetes Manifests

All resources live in the production namespace.

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: documentations
  namespace: production
spec:
  replicas: 1
  selector:
    matchLabels:
      app: documentations
  template:
    metadata:
      labels:
        app: documentations
    spec:
      imagePullSecrets:
        - name: nexus-registry
      containers:
        - name: documentations
          image: registry.nexus.castis.io/playtelly/documentations:prod-latest
          ports:
            - containerPort: 80
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 200m
              memory: 128Mi

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: documentations
  namespace: production
spec:
  selector:
    app: documentations
  ports:
    - port: 80
      targetPort: 80

certificate.yaml

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: documentations-tls
  namespace: production
spec:
  secretName: documentations-tls-secret
  issuerRef:
    name: letsencrypt-prod
    kind: ClusterIssuer
  dnsNames:
    - developer.castis.io

apisix-tls.yaml

apiVersion: apisix.apache.org/v2
kind: ApisixTls
metadata:
  name: documentations-tls
  namespace: production
spec:
  hosts:
    - developer.castis.io
  secret:
    name: documentations-tls-secret
    namespace: production

apisix-route.yaml

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: documentations-public
  namespace: production
spec:
  http:
    - name: documentations-public
      match:
        hosts:
          - developer.castis.io
        paths:
          - "/*"
      backends:
        - serviceName: documentations
          servicePort: 80
      plugins:
        - name: redirect
          enable: true
          config:
            http_to_https: true
        - name: proxy-rewrite
          enable: true
          config:
            headers:
              set:
                X-Forwarded-Proto: "https"
                X-Forwarded-Host: "developer.castis.io"

Deployment Order

Apply manifests in this order to avoid dependency issues:

kubectl apply -f certificate.yaml
kubectl apply -f apisix-tls.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f apisix-route.yaml

ArgoCD Integration

The app is registered as documentation-prod under argocd/apps/prod/documentation-prod.yml in the IAC repo and is managed by the root-app-prod app-of-apps.

The cluster already has:

  • repo-secret-prod — access to the IAC repo
  • registry-secret-prod — access to registry.nexus.castis.io

documentation-prod.yml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: documentation-prod
  namespace: argocd
spec:
  project: default
  source:
    repoURL: YOUR_IAC_REPO_URL
    targetRevision: main
    path: compose/infrastructure/documentations
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Drop this file into argocd/apps/prod/ — root-app-prod will detect and sync it automatically.

Force Re-sync via kubectl

kubectl patch application documentation-prod -n argocd \
  --type merge \
  -p '{"operation":{"initiatedBy":{"username":"admin"},"sync":{"revision":"HEAD"}}}'

Troubleshooting

ErrImagePull / ImagePullBackOff

The cluster cannot authenticate to the registry.

# Check the error
kubectl describe pod -n production <pod-name>

# Verify the pull secret exists
kubectl get secrets -n production | grep registry

Recreate the secret if missing (see Registry Authentication above).

Pod stuck in Pending

kubectl describe pod -n production <pod-name>

Check the Events section at the bottom for the root cause.

Site not reachable after deploy

# Check certificate is ready
kubectl get certificate -n production

# Check APISIX route
kubectl get apisixroute -n production

# Check pod is running
kubectl get pods -n production

Force rebuild without code change

Trigger a rollout restart:

kubectl rollout restart deployment/documentations -n production