ข้ามไปยังเนื้อหา
mofcloud

ติดตั้ง MOF บน Kubernetes

อัพเดทล่าสุด:

MOF, Dash และ MCP ใน Pod เดียว

Linux amd64 · kubectl · PostgreSQL ภายนอก · 1 Pod · 3 container

เครือข่ายส่วนตัว · ต้องมีสิทธิ์ CREATEDB · ไม่รองรับ PostgreSQL ที่บังคับ TLS

แหล่งอิมเมจ

ดาวน์โหลด mof.yaml

Docker Hub · MOF v2.0.15 · Dash v2.0.17 · MCP v2.0.3

ดาวน์โหลด mof.yaml ↓
ดูไฟล์
mof.yaml
# MOF v2.0.15 + Dash v2.0.17 + MCP v2.0.3
# Edit database address, user and password before applying. Keep this file private.
# Keep the Service names mof, mof-mcp and dash, all in one namespace: the components find each
# other by them (mof:8080, mof-mcp:8001). Renamed Services can't connect.
# Private-network PostgreSQL without TLS. TLS-only databases are not supported by this release.
apiVersion: v1
kind: Namespace
metadata:
  name: mof
---
apiVersion: v1
kind: Secret
metadata:
  name: mof-database
  namespace: mof
type: Opaque
stringData:
  password: "REPLACE_WITH_YOUR_DATABASE_PASSWORD"
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: mof-config
  namespace: mof
data:
  RK_POSTGRES_0_ADDR: "db.example.com:5432"
  RK_POSTGRES_0_USER: "mof"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mof
  namespace: mof
spec:
  replicas: 1
  # First-release template: stop the old Pod before starting the new version.
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: mof
  template:
    metadata:
      labels:
        app: mof
      # Prometheus discovery by annotation; see the monitoring guide for a PodMonitor
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8080"
        prometheus.io/path: /internal/v1/mof/metrics
    spec:
      enableServiceLinks: false
      nodeSelector:
        kubernetes.io/arch: amd64
      terminationGracePeriodSeconds: 120
      containers:
        - name: mof
          image: mofcloud/mof:v2.0.15
          envFrom:
            - configMapRef:
                name: mof-config
          env:
            - name: RK_POSTGRES_0_PASS
              valueFrom:
                secretKeyRef:
                  name: mof-database
                  key: password
          ports:
            - name: api
              containerPort: 8080
          startupProbe:
            httpGet:
              path: /v1/mof/site-info
              port: api
            periodSeconds: 10
            failureThreshold: 60
          readinessProbe:
            httpGet:
              path: /v1/mof/site-info
              port: api
            periodSeconds: 10
            timeoutSeconds: 5
          resources:
            requests:
              cpu: "500m"
              memory: "1Gi"
          volumeMounts:
            - name: offer-cache
              mountPath: /usr/src/mof/offer-cache
      volumes:
        - name: offer-cache
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: mof
  namespace: mof
spec:
  selector:
    app: mof
  ports:
    - name: api
      port: 8080
      targetPort: api
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mof-mcp
  namespace: mof
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mof-mcp
  template:
    metadata:
      labels:
        app: mof-mcp
    spec:
      enableServiceLinks: false
      nodeSelector:
        kubernetes.io/arch: amd64
      containers:
        - name: mof-mcp
          image: mofcloud/mof-mcp:v2.0.3
          ports:
            - name: mcp
              containerPort: 8001
          readinessProbe:
            exec:
              command: ["node", "/app/build/healthcheck.js"]
            periodSeconds: 10
            timeoutSeconds: 5
          resources:
            requests:
              cpu: "100m"
              memory: "128Mi"
---
apiVersion: v1
kind: Service
metadata:
  name: mof-mcp
  namespace: mof
spec:
  selector:
    app: mof-mcp
  ports:
    - name: mcp
      port: 8001
      targetPort: mcp
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dash
  namespace: mof
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dash
  template:
    metadata:
      labels:
        app: dash
    spec:
      enableServiceLinks: false
      nodeSelector:
        kubernetes.io/arch: amd64
      containers:
        - name: dash
          image: mofcloud/dash:v2.0.17
          ports:
            - name: web
              containerPort: 80
          readinessProbe:
            httpGet:
              path: /
              port: web
            periodSeconds: 10
          resources:
            requests:
              cpu: "100m"
              memory: "64Mi"
---
apiVersion: v1
kind: Service
metadata:
  name: dash
  namespace: mof
spec:
  selector:
    app: dash
  ports:
    - name: web
      port: 80
      targetPort: web
  type: ClusterIP

คงชื่อ Service mof, mof-mcp และ dash ไว้ใน namespace เดียวกัน คอมโพเนนต์ค้นหากันด้วยชื่อเหล่านี้ (mof:8080, mof-mcp:8001) จึงไม่ต้องกำหนดค่าอื่น Service ที่เปลี่ยนชื่อจะเชื่อมต่อไม่ได้

การเชื่อมต่อฐานข้อมูล

กรอก PostgreSQL ที่มีอยู่ใน mof.yaml:

RK_POSTGRES_0_ADDR
ที่อยู่:พอร์ต
RK_POSTGRES_0_USER
ชื่อผู้ใช้
stringData.password
รหัสผ่านฐานข้อมูลที่มีอยู่

ใส่เครื่องหมายคำพูดครอบรหัสผ่าน และเก็บไฟล์นี้เป็นความลับ

Deploy

Terminal
kubectl apply -f mof.yaml
kubectl -n mof rollout status deployment/mof --timeout=10m
kubectl -n mof rollout status deployment/mof-mcp deployment/dash

เมื่อทั้งสามตัว rollout เสร็จแล้ว ให้ดึงรหัสผ่าน Admin:

Terminal
kubectl -n mof logs deployment/mof | grep "Admin password"

เปิด MOF

Terminal
kubectl -n mof port-forward service/dash 8000:80

เปิดเทอร์มินัลนี้ค้างไว้

Adminhttp://127.0.0.1:8000/admin

ติดตั้งไลเซนส์และสร้างผู้ใช้

MOF Webhttp://127.0.0.1:8000

ลงชื่อเข้าใช้ด้วยบัญชี MOF ของคุณ

การกำหนดค่าขั้นสูง

ความเข้ากันได้ของ TLS กับ PostgreSQL

MOF ใช้การตั้งค่า TLS กับ Mof และ AsyncJobMof แต่ไม่ใช้กับฐานข้อมูลของ provider เทมเพลตนี้ต้องใช้เครือข่ายส่วนตัวที่เชื่อถือได้ และใช้ PostgreSQL ที่บังคับ TLS ไม่ได้

โดเมน HTTPS และ OAuth (ไม่บังคับ)

ใช้ Ingress controller ที่มีอยู่และชี้โดเมนของคุณไปที่นั่น ตั้งค่า class, hostname และ TLS Secret ที่มีอยู่ใน namespace mof

ดาวน์โหลด ingress.yaml ↓
ingress.yaml
# Requires an installed Ingress controller and an existing TLS Secret.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mof
  namespace: mof
spec:
  ingressClassName: nginx
  tls:
    - hosts: [mof.example.com]
      secretName: mof-web-tls
  rules:
    - host: mof.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: dash
                port:
                  number: 80
Terminal
kubectl apply -f ingress.yaml
kubectl -n mof get ingress

เปิด MCP ใน Admin → การตั้งค่า → MCP Endpoint: /v1/mof/remote-mcp โทเค็นไม่ต้องใช้ OAuth ส่วน OAuth ผ่านเบราว์เซอร์ต้องใช้ HTTPS, MOF_PUBLIC_URL และ MOF_MCP_OAUTH_SECRET

Health check และการแก้ปัญหา
Terminal
kubectl -n mof get pods
kubectl -n mof logs deployment/mof --tail=100
kubectl -n mof logs deployment/mof-mcp --tail=60
kubectl -n mof logs deployment/dash --tail=60
kubectl -n mof exec deployment/mof -- wget -q -O - http://mof-mcp:8001/health

ผลที่คาดหวัง: mof, mof-mcp และ dash อยู่ในสถานะ Running และ Ready และ MCP ready: true หากเริ่มทำงานไม่สำเร็จ ให้ตรวจการ pull อิมเมจ สถาปัตยกรรมของ node และการเข้าถึงฐานข้อมูล

พารามิเตอร์ของเทมเพลต
RK_POSTGRES_0_ADDRhostname:port ของ PostgreSQL ภายนอก ที่ Pod เข้าถึงได้
RK_POSTGRES_0_USERrole ฐานข้อมูลที่มีอยู่ซึ่งมีสิทธิ์สร้างฐานข้อมูลของ MOF และ provider
mof-database / passwordรหัสผ่านฐานข้อมูลเก็บใน Secret และ inject ให้ MOF เท่านั้น
Services mof / mof-mcp / dashอย่างละหนึ่ง Deployment และ Service ค้นหากันด้วยชื่อ Service ไม่ต้องตั้งค่าอะไร
replicas / strategy1 / Recreate การอัปเกรดจะหยุดบริการชั่วครู่ HA แบบหลาย replica อยู่นอกขอบเขตของเทมเพลตนี้
resources.requestsเป็นการจองทรัพยากรสำหรับการจัดตาราง ไม่ใช่ขีดจำกัดหน่วยความจำ กำหนดขนาด MOF ตามปริมาณบิลและติดตามการใช้งานจริง
offer-cache / emptyDirแคชราคาสาธารณะที่สร้างใหม่ได้ จะหายเมื่อ Pod ถูกแทนที่ ข้อมูลบิลยังอยู่ใน PostgreSQL
ingressClassName / host / tlsให้ตรงกับ controller ที่ติดตั้ง โดเมนสาธารณะ และ TLS Secret ของคุณ ไม่จำเป็นหากตรวจสอบผ่าน port-forward ในเครื่อง
การอัปเดต ข้อมูล และการขยายระบบ

สำรอง PostgreSQL อัปเดตเวอร์ชันอิมเมจ แล้ว apply mof.yaml รีสตาร์ตหลังแก้ไข ConfigMap หรือ Secret การอัปเกรดแบบ Recreate จะหยุดบริการชั่วคราว

Terminal
kubectl -n mof rollout restart deployment/mof
kubectl -n mof rollout status deployment/mof --timeout=10m

รองรับ replica เดียวเท่านั้น ยังไม่มี Kubernetes Job แบบตามต้องการ ข้อมูลแอปพลิเคชันอยู่ใน PostgreSQL ภายนอก ส่วนแคชราคาสร้างใหม่ได้