Zum Inhalt

MariaDB und Nextcloud bereit für die Produktion machen

Für den Produktivbetrieb von MariaDB und Nextcloud fehlen noch einige Elemente, die wir zum Abschluss dieser Case Study umsetzen wollen.

Requests und Limits

Jeder Pod in einem Kubernetes-Cluster sollte Resource Requests und Limits definieren. Setze daher für MariaDB die folgenden Requests und Limits:

resources:
  requests:
    cpu: "1000m"
    memory: "4Gi"
  limits:
    cpu: "1000m"
    memory: "4Gi"

Für Nextcloud setze folgende Werte:

resources:
  requests:
    cpu: "1000m"
    memory: "2Gi"
  limits:
    cpu: "1000m"
    memory: "2Gi"

Readiness Probes

Für die Selbstheilung von Pods sollte eine Readiness Probe definiert werden. Für MariaDB ist die einfachste Readiness Probe die folgende:

readinessProbe:
  tcpSocket:
    port: 3306
  periodSeconds: 10
  timeoutSeconds: 1
  failureThreshold: 1

Für Nextcloud ist folgende Probe sinnvoll:

readinessProbe:
  httpGet:
    path: /status.php
    port: http
  periodSeconds: 10
  timeoutSeconds: 2
  failureThreshold: 1

Ingress

In Produktion braucht ein Service meistens noch einen Ingress oder ein Gateway. Dies ist nur für Nextcloud nötig:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nextcloud
  namespace: nextcloud
  annotations:
    # Reasonable defaults for typical Nextcloud use; students can tune:
    nginx.ingress.kubernetes.io/proxy-body-size: "2g"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
spec:
  ingressClassName: nginx
  rules:
    - host: nextcloud.local
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: nextcloud
                port:
                  number: 80

PodDisruptionBudget

Sowohl Nextcloud als auch MariaDB sollten beim Rollout von Deployments sowie beim Node Draining nicht mehr als einen Pod gleichzeitig unter ihrer Mindestprovisionierung verbleiben.

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: nextcloud-pdb
  namespace: nextcloud
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app: nextcloud

---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: nextcloud-db-pdb
  namespace: nextcloud
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app: nextcloud-db