1.部署webdav-aliyundriver
1.1 docker方式部署
docker run -d --name=webdav-aliyundriver --restart=always -p 8080:8080 -v /etc/localtime:/etc/localtime -v /etc/aliyun-driver/:/etc/aliyun-driver/ -e TZ="Asia/Shanghai" -e ALIYUNDRIVE_REFRESH_TOKEN="your refreshToken" -e ALIYUNDRIVE_AUTH_PASSWORD="admin" -e JAVA_OPTS="-Xmx1g" yuanhaishan/webdav-aliyundriver:v2.4.0
# /etc/aliyun-driver/ 掛載卷自動維護了最新的refreshToken,建議掛載
# ALIYUNDRIVE_AUTH_PASSWORD 是admin賬戶的密碼,建議修改
# JAVA_OPTS 可修改最大內存占用,比如 -e JAVA_OPTS="-Xmx512m" 表示最大內存限制為512m
需要先把自己的refreshToken獲取到
瀏覽器獲取refreshToken方式:
1.登錄阿里雲盤官網 https://www.aliyundrive.com/sign/
2.按f12打開控制台—application—local storage—token,即可查看refresh token
1.2 k8s方式安裝
需要手動創建namespace,執行kubectl create ns yuanhaishan
ALIYUNDRIVE_AUTH_USER_NAME,ALIYUNDRIVE_AUTH_PASSWORD這兩個參數分別是webdav的用戶名跟密碼 可有可無 但是ALIYUNDRIVE_REFRESH_TOKEN參數是必須的
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: yuanhaishan
labels:
app: webdav
name: webdav
spec:
replicas: 1
selector:
matchLabels:
app: webdav
template:
metadata:
labels:
app: webdav
spec:
containers:
- name: webdav
image: yuanhaishan/webdav-aliyundriver:v2.4.0
env:
- name: TZ
value: Asia/Shanghai
- name: ALIYUNDRIVE_REFRESH_TOKEN
value: 這個就是上面獲取到的refreshToken
- name: ALIYUNDRIVE_AUTH_USER_NAME
value: webdav的用戶名
- name: ALIYUNDRIVE_AUTH_PASSWORD
value: webdav的密碼
- name: JAVA_OPTS
value: -Xmx512m
ports:
- containerPort: 8080
resources:
limits:
cpu: "2000m"
memory: "1024Mi"
requests:
cpu: "100m"
memory: "512Mi"
對外提供服務
apiVersion: v1
kind: Service
metadata:
name: webdav-svc
namespace: yuanhaishan
labels:
app: webdav
spec:
type: NodePort
selector:
app: webdav
ports:
- protocol: TCP
port: 8080
2.安裝Rclone進行掛載
2.1 rclone安裝介紹: https://rclone.org/install/
2.2 配置rclone
[root@k8s-master test]# rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> webdav(這個是存儲的名字)
Option Storage.
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value.
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, SeaweedFS, and Tencent COS
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Better checksums for other remotes
\ "hasher"
7 / Box
\ "box"
8 / Cache a remote
\ "cache"
9 / Citrix Sharefile
\ "sharefile"
10 / Compress a remote
\ "compress"
11 / Dropbox
\ "dropbox"
12 / Encrypt/Decrypt a remote
\ "crypt"
13 / Enterprise File Fabric
\ "filefabric"
14 / FTP Connection
\ "ftp"
15 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
16 / Google Drive
\ "drive"
17 / Google Photos
\ "google photos"
18 / Hadoop distributed file system
\ "hdfs"
19 / Hubic
\ "hubic"
20 / In memory object storage system.
\ "memory"
21 / Jottacloud
\ "jottacloud"
22 / Koofr
\ "koofr"
23 / Local Disk
\ "local"
24 / Mail.ru Cloud
\ "mailru"
25 / Mega
\ "mega"
26 / Microsoft Azure Blob Storage
\ "azureblob"
27 / Microsoft OneDrive
\ "onedrive"
28 / OpenDrive
\ "opendrive"
29 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
30 / Pcloud
\ "pcloud"
31 / Put.io
\ "putio"
32 / QingCloud Object Storage
\ "qingstor"
33 / SSH/SFTP Connection
\ "sftp"
34 / Sia Decentralized Cloud
\ "sia"
35 / Sugarsync
\ "sugarsync"
36 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
37 / Transparently chunk/split large files
\ "chunker"
38 / Union merges the contents of several upstream fs
\ "union"
39 / Uptobox
\ "uptobox"
40 / Webdav
\ "webdav"
41 / Yandex Disk
\ "yandex"
42 / Zoho
\ "zoho"
43 / http Connection
\ "http"
44 / premiumize.me
\ "premiumizeme"
45 / seafile
\ "seafile"
Storage> 40
Option url.
URL of http host to connect to.
E.g. https://example.com.
Enter a string value. Press Enter for the default ("").
url> http://webdav.yuanhaishan.cn
Option vendor.
Name of the Webdav site/service/software you are using.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value.
1 / Nextcloud
\ "nextcloud"
2 / Owncloud
\ "owncloud"
3 / Sharepoint Online, authenticated by Microsoft account
\ "sharepoint"
4 / Sharepoint with NTLM authentication, usually self-hosted or on-premises
\ "sharepoint-ntlm"
5 / Other site/service or software
\ "other"
vendor> 5
Option user.
User name.
In case NTLM authentication is used, the username should be in the format 'Domain\User'.
Enter a string value. Press Enter for the default ("").
user> (部署webdav配置的用戶名 沒有配置用戶名就直接跳過)
Option pass.
Password.
Choose an alternative below. Press Enter for the default (n).
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blank (default)
y/g/n> y(部署webdav配置的密碼 沒有配置密碼就直接回車跳過)
Enter the password:
password:
Confirm the password:
password:
Option bearer_token.
Bearer token instead of user/pass (e.g. a Macaroon).
Enter a string value. Press Enter for the default ("").
bearer_token>
Edit advanced config?
y) Yes
n) No (default)
y/n>
--------------------
[webdav]
type = webdav
url = webdav的地址
vendor = other
user = 用戶名
pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>
Current remotes:
Name Type
==== ====
webdav webdav
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
2.3 掛載到本地
#新建本地文件夾
mkdir -p /data/aliyunpan
#掛載
rclone mount DriveName:Folder LocalFolder --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty
DriverName是你在配置rclone的時候設置的名字,Folder沒有需要求的話填/即可,LocalFolder是你本地掛載的地址,/tmp比較特殊,上傳時緩存目錄,其他類型掛載一般時不需要這個參數的,默認/tmp地址即可,除非你的系統特殊
最終寫成rclone mount webdav:/ /data/aliyunpan --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty
3.測試使用
可以看到/data/aliyunpan已經掛載成功 也能實現數據的互傳及存儲
[root@k8s-master deploy]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 28G 9.9G 74% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs 1.8G 1.7M 1.8G 1% /run
tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
tmpfs 365M 0 365M 0% /run/user/0
tmpfs 1.8G 12K 1.8G 1%
webdav: 1.0P 0 1.0P 0% /data/aliyunpan
[root@k8s-master deploy]# ls /data/aliyunpan/
calico.yaml Docker+Kubernetes實戰視頻課程 jenkins打包腳本 k8s學習資料 容器雲資料 操作系統鏡像 來自:QQ備份 來自:微信備份 百度網盤數據 運維資料