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、保持网络通畅,然后添加设备,共享文件夹就是了

相关推荐
moppol38 分钟前
Serverless 架构入门与实战:AWS Lambda、Azure Functions、Cloudflare Workers 对比
云原生·serverless·aws
IvanCodes1 小时前
一、Docker:一场颠覆应用部署与运维的容器革命
docker·容器
栗子~~1 小时前
Milvus docker-compose 部署
docker·容器·milvus
没有名字的小羊3 小时前
2.安装Docker
运维·docker·容器
xiezhr3 小时前
50 个常用 Docker 命令
运维·docker·容器
退役小学生呀9 天前
三、kubectl使用详解
云原生·容器·kubernetes·k8s
被困者10 天前
Linux部署Sonic前后端(详细版)(腾讯云)
spring cloud·云原生·eureka
程序员小潘10 天前
Kubernetes多容器Pod实战
云原生·容器·kubernetes
进击的码码码码N10 天前
Docker 镜像加速
运维·docker·容器