k8s 与 docker 安装 Syncthing 文件同步服务器

Syncthing是一个开源文件同步工具,可以在多台设备之间实时同步文件或文件夹,官方网站:https://syncthing.net/ 下载地址:https://syncthing.net/downloads/ ,如果是windows一般推荐下载图形界面SyncTrayzor, 但我这边都是linux,就用k8s+docker了。

1、先贴上k8s的,因为这是云端的master服务器

XML 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  name: syncthing
  labels:
    app: syncthing
spec:
  replicas: 1
  selector:
    matchLabels:
      app: syncthing
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: syncthing
    spec:
      containers:
        - env:
            - name: PGID
              value: "1000"
            - name: PUID
              value: "1000"
            - name: TZ
              value: '"Asia/Shanghai"'
          image: linuxserver/syncthing:1.23.2
          name: syncthing
          ports:
            - containerPort: 8384
            - containerPort: 22000
            - containerPort: 22000
              protocol: UDP
            - containerPort: 21027
              protocol: UDP
          resources: {}
          volumeMounts:
            - mountPath: /var/syncthing
              name: syncthing-data
      restartPolicy: Always
      volumes:
        - name: syncthing-data
          nfs:
            server: 172.30.0.15
            path: /data/nfs/syncthing
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: syncthing
  name: syncthing
spec:
  ports:
    - name: "8384"      # web管理页面
      port: 8384
      targetPort: 8384  
    - name: "22000"     # 服务器同步发现端口,文件也通过这个端口传输
      port: 22000
      targetPort: 22000
    - name: 22000-udp
      port: 22000
      protocol: UDP
      targetPort: 22000
    - name: "21027"
      port: 21027
      protocol: UDP
      targetPort: 21027
  selector:
    app: syncthing
  type: NodePort
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: syncthing-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  tls:
    - hosts:
        - 'syncthing.xxx.com'
      secretName: syncthing-tls
  rules:
    - host: syncthing.xxx.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: syncthing
                port:
                  number: 8384

2、再贴上docker的,这是slave

XML 复制代码
docker run --name syncthing -d --restart always -p 8384:8384 -p 22000:22000 -p 21027:21027 \ -e PGID='1000' -e PUID='1000' -e TZ='Asia/Shanghai'  \
 -v /home/admin/docker_data/syncthing/data:/var/syncthing -v /home/admin/docker_data/syncthing/app:/app linuxserver/syncthing:1.23.2

3、保持网络通畅,然后添加设备,共享文件夹就是了

相关推荐
等什么君!35 分钟前
docker -数据卷技术
运维·docker·容器
花酒锄作田1 小时前
Debian 13基于kubeadm和containerd部署单节点kubernetes
kubernetes·containerd·cilium
上天_去_做颗惺星 EVE_BLUE2 小时前
Docker高效使用指南:从基础到实战模板
开发语言·ubuntu·docker·容器·mac·虚拟环境
Gary董3 小时前
高并发的微服务架构如何设计
微服务·云原生·架构
东哥爱编程3 小时前
使用Runpod进行gpu serverless推理
云原生·serverless
好好沉淀3 小时前
Docker开发笔记(详解)
运维·docker·容器
Ankie Wan4 小时前
cgroup(Control Group)是 Linux 内核提供的一种机制,用来“控制、限制、隔离、统计”进程对系统资源的使用。
linux·容器·cgroup·lxc
lcx_defender6 小时前
【Docker】Docker部署运行nacos
运维·docker·容器
啦啦啦小石头6 小时前
docker添加用户权限不使用sudo
运维·docker·容器
天才奇男子7 小时前
《深度解析HAProxy七层代理:原理、配置与最佳实践》
linux·运维·微服务·云原生