diff --git a/README.md b/README.md index c17e48f..beed47f 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,13 @@ Containers my home media server set up +## Fix home-server running out of disk + +```bash +# Remove dangling images +sudo k3s crictl rmi --prune + +# Clean stopped containers +sudo k3s crictl rm $(sudo k3s crictl ps -a -q --state exited) + +``` diff --git a/agents.md b/agents.md index 791243f..09b028c 100644 --- a/agents.md +++ b/agents.md @@ -2,6 +2,7 @@ > **Purpose**: This document helps AI assistants (GitHub Copilot, Claude, ChatGPT, etc.) understand the repository structure, architecture, and context for better code assistance. +DO NOT DELETE ANY LOCAL OR REMOTE FILES WITHOUT ASKING ME TO CONFIRM! --- ## 📋 Repository Overview diff --git a/home-apps/moltbot.yaml b/home-apps/moltbot.yaml new file mode 100644 index 0000000..ff79bfa --- /dev/null +++ b/home-apps/moltbot.yaml @@ -0,0 +1,273 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: moltbot-config-local-pv + labels: + type: local + name: moltbot-config +spec: + capacity: + storage: 5Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Delete + storageClassName: local-storage + local: + path: /mnt/k8s/moltbot/config + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - server-3 +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: home-apps + name: moltbot-config-local-pvc +spec: + volumeName: moltbot-config-local-pv + storageClassName: "local-storage" + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi +--- + +apiVersion: v1 +kind: PersistentVolume +metadata: + name: moltbot-workspace-local-pv + labels: + type: local + name: moltbot-workspace +spec: + capacity: + storage: 10Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Delete + storageClassName: local-storage + local: + path: /mnt/k8s/moltbot/workspace + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - server-3 +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: home-apps + name: moltbot-workspace-local-pvc +spec: + volumeName: moltbot-workspace-local-pv + storageClassName: "local-storage" + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi +--- + +apiVersion: v1 +kind: Secret +metadata: + name: moltbot-credentials + namespace: home-apps +type: Opaque +stringData: + gateway-token: "96101b63fec7789ef14e4691d30745c2a329170aa165f8dbe3174407ca61aefa" # Generate with: openssl rand -hex 32 + # Optional: Claude AI credentials (NOT REQUIRED - can configure any provider later) + # Supported providers: OpenRouter, Google Gemini, OpenAI, Anthropic, Venice AI, Ollama, etc. + # Configure via: kubectl exec -it deployment/moltbot-gateway -n home-apps -- node dist/index.js onboard + # Or edit config at: /home/node/.clawdbot/moltbot.json with model like: + # { "agents": { "defaults": { "model": { "primary": "openrouter/google/gemini-2.0-flash-exp" } } } } + claude-ai-session-key: "" + claude-web-session-key: "" + claude-web-cookie: "" +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: moltbot-gateway + namespace: home-apps + labels: + app: moltbot-gateway +spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + app: moltbot-gateway + template: + metadata: + labels: + app: moltbot-gateway + name: moltbot-gateway + spec: + initContainers: + - name: build-image + image: mirror.gcr.io/node:25-bookworm + workingDir: /build + command: ["/bin/bash", "-c"] + args: + - | + set -e + if [ ! -f /build/dist/index.js ]; then + echo "Cloning moltbot repository..." + apt-get update && apt-get install -y git + git clone https://github.com/moltbot/moltbot.git /build + cd /build + npm install -g pnpm + npm install + npm run build + fi + volumeMounts: + - name: build-cache + mountPath: /build + containers: + - name: moltbot-gateway + image: mirror.gcr.io/node:25-bookworm + imagePullPolicy: IfNotPresent + workingDir: /app + command: ["/bin/bash", "-c"] + args: + - | + cp -r /build/* /app/ + node dist/index.js gateway --allow-unconfigured --bind lan --port 18789 + ports: + - containerPort: 18789 + name: gateway + protocol: TCP + - containerPort: 18790 + name: bridge + protocol: TCP + env: + - name: HOME + value: "/home/node" + - name: TERM + value: "xterm-256color" + - name: CLAWDBOT_GATEWAY_TOKEN + valueFrom: + secretKeyRef: + name: moltbot-credentials + key: gateway-token + - name: CLAUDE_AI_SESSION_KEY + valueFrom: + secretKeyRef: + name: moltbot-credentials + key: claude-ai-session-key + optional: true + - name: CLAUDE_WEB_SESSION_KEY + valueFrom: + secretKeyRef: + name: moltbot-credentials + key: claude-web-session-key + optional: true + - name: CLAUDE_WEB_COOKIE + valueFrom: + secretKeyRef: + name: moltbot-credentials + key: claude-web-cookie + optional: true + volumeMounts: + - name: config + mountPath: "/home/node/.moltbot" + - name: workspace + mountPath: "/home/node/clawd" + - name: build-cache + mountPath: /build + resources: + requests: + cpu: 200m + memory: 512Mi + limits: + cpu: 1000m + memory: 2Gi + livenessProbe: + tcpSocket: + port: gateway + initialDelaySeconds: 30 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: gateway + initialDelaySeconds: 10 + periodSeconds: 5 + volumes: + - name: config + persistentVolumeClaim: + claimName: moltbot-config-local-pvc + - name: workspace + persistentVolumeClaim: + claimName: moltbot-workspace-local-pvc + - name: build-cache + emptyDir: {} + +--- + +apiVersion: v1 +kind: Service +metadata: + name: moltbot-gateway + namespace: home-apps + labels: + name: moltbot-gateway +spec: + type: ClusterIP + selector: + app: moltbot-gateway + ports: + - name: gateway + targetPort: gateway + port: 18789 + protocol: TCP + - name: bridge + targetPort: bridge + port: 18790 + protocol: TCP + +--- + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: moltbot-gateway-ingress + namespace: home-apps + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + nginx.ingress.kubernetes.io/auth-url: "https://pass.junv.cc/oauth2/auth" + nginx.ingress.kubernetes.io/auth-signin: "https://pass.junv.cc/oauth2/start?rd=https://$host$escaped_request_uri" + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" +spec: + ingressClassName: nginx + tls: + - hosts: + - moltbot.junv.cc + secretName: moltbot-gateway-tls + rules: + - host: moltbot.junv.cc + http: + paths: + - backend: + service: + name: moltbot-gateway + port: + number: 18789 + path: / + pathType: Prefix