diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..5df79b8 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,29 @@ +kind: pipeline +type: kubernetes +name: build-and-push + +trigger: + branch: + - main + - develop + event: + - push + - custom + +steps: + - name: build-and-push + image: gcr.io/kaniko-project/executor:debug + commands: + - > + /kaniko/executor + --context=/drone/src + --dockerfile=Dockerfile + --destination=192.168.68.11:30500/xiaohongshu-mcp:${DRONE_COMMIT_SHA:0:8} + --destination=192.168.68.11:30500/xiaohongshu-mcp:latest + --insecure + --skip-tls-verify + + - name: restart-deployment + image: bitnami/kubectl:latest + commands: + - kubectl rollout restart deploy/xiaohongshu-mcp -n xiaohongshu-mcp diff --git a/k8s/argocd-app.yaml b/k8s/argocd-app.yaml new file mode 100644 index 0000000..30f42db --- /dev/null +++ b/k8s/argocd-app.yaml @@ -0,0 +1,20 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: xiaohongshu-mcp + namespace: argocd +spec: + project: default + source: + repoURL: https://git.colacoder.com/kai/xiaohongshu-mcp.git + targetRevision: main + path: k8s/base + destination: + server: https://kubernetes.default.svc + namespace: xiaohongshu-mcp + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/k8s/base/deployment.yaml b/k8s/base/deployment.yaml new file mode 100644 index 0000000..a0393f8 --- /dev/null +++ b/k8s/base/deployment.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: xiaohongshu-mcp + namespace: xiaohongshu-mcp + labels: + app: xiaohongshu-mcp +spec: + replicas: 1 + selector: + matchLabels: + app: xiaohongshu-mcp + template: + metadata: + labels: + app: xiaohongshu-mcp + spec: + containers: + - name: xiaohongshu-mcp + image: 192.168.68.11:30500/xiaohongshu-mcp:latest + imagePullPolicy: Always + ports: + - containerPort: 18060 + protocol: TCP + env: + - name: ROD_BROWSER_BIN + value: "/usr/bin/google-chrome" + - name: COOKIES_PATH + value: "/app/data/cookies.json" + - name: TZ + value: "Asia/Shanghai" + resources: + requests: + cpu: 200m + memory: 512Mi + limits: + cpu: "1" + memory: 2Gi + volumeMounts: + - name: data + mountPath: /app/data + - name: images + mountPath: /app/images + - name: dshm + mountPath: /dev/shm + livenessProbe: + httpGet: + path: /health + port: 18060 + initialDelaySeconds: 30 + periodSeconds: 30 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: /health + port: 18060 + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 5 + volumes: + - name: data + persistentVolumeClaim: + claimName: xiaohongshu-mcp-data + - name: images + persistentVolumeClaim: + claimName: xiaohongshu-mcp-images + - name: dshm + emptyDir: + medium: Memory + sizeLimit: 256Mi diff --git a/k8s/base/drone-rbac.yaml b/k8s/base/drone-rbac.yaml new file mode 100644 index 0000000..cf80389 --- /dev/null +++ b/k8s/base/drone-rbac.yaml @@ -0,0 +1,29 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: drone-deploy + namespace: xiaohongshu-mcp +rules: + - apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["get", "list", "patch", "update"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: drone-deploy + namespace: xiaohongshu-mcp +subjects: + - kind: ServiceAccount + name: default + namespace: drone + - kind: ServiceAccount + name: drone + namespace: drone + - kind: ServiceAccount + name: drone-runner-drone-runner-kube + namespace: drone +roleRef: + kind: Role + name: drone-deploy + apiGroup: rbac.authorization.k8s.io diff --git a/k8s/base/ingress.yaml b/k8s/base/ingress.yaml new file mode 100644 index 0000000..a5925fc --- /dev/null +++ b/k8s/base/ingress.yaml @@ -0,0 +1,26 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: xiaohongshu-mcp + namespace: xiaohongshu-mcp + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: "50m" + nginx.ingress.kubernetes.io/proxy-read-timeout: "300" + nginx.ingress.kubernetes.io/proxy-send-timeout: "300" +spec: + ingressClassName: nginx + tls: + - hosts: + - xiaohongshu-mcp.k8s.home + secretName: xiaohongshu-mcp-tls + rules: + - host: xiaohongshu-mcp.k8s.home + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: xiaohongshu-mcp + port: + number: 18060 diff --git a/k8s/base/kustomization.yaml b/k8s/base/kustomization.yaml new file mode 100644 index 0000000..96b0414 --- /dev/null +++ b/k8s/base/kustomization.yaml @@ -0,0 +1,12 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: xiaohongshu-mcp + +resources: + - namespace.yaml + - pvc.yaml + - deployment.yaml + - service.yaml + - ingress.yaml + - drone-rbac.yaml diff --git a/k8s/base/namespace.yaml b/k8s/base/namespace.yaml new file mode 100644 index 0000000..4f080eb --- /dev/null +++ b/k8s/base/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: xiaohongshu-mcp diff --git a/k8s/base/pvc.yaml b/k8s/base/pvc.yaml new file mode 100644 index 0000000..81de198 --- /dev/null +++ b/k8s/base/pvc.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: xiaohongshu-mcp-data + namespace: xiaohongshu-mcp + labels: + app: xiaohongshu-mcp +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: xiaohongshu-mcp-images + namespace: xiaohongshu-mcp + labels: + app: xiaohongshu-mcp +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi diff --git a/k8s/base/service.yaml b/k8s/base/service.yaml new file mode 100644 index 0000000..ba40688 --- /dev/null +++ b/k8s/base/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: xiaohongshu-mcp + namespace: xiaohongshu-mcp + labels: + app: xiaohongshu-mcp +spec: + type: ClusterIP + selector: + app: xiaohongshu-mcp + ports: + - port: 18060 + targetPort: 18060 + protocol: TCP