惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
D
DataBreaches.Net
博客园_首页
罗磊的独立博客
B
Blog
T
Threat Research - Cisco Blogs
C
Cisco Blogs
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
G
GRAHAM CLULEY
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
SecWiki News
SecWiki News
T
Threatpost
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Schneier on Security
Schneier on Security
T
The Exploit Database - CXSecurity.com
Google Online Security Blog
Google Online Security Blog
T
Tor Project blog
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
H
Hacker News: Front Page
V
V2EX
Security Latest
Security Latest
Cloudbric
Cloudbric
Simon Willison's Weblog
Simon Willison's Weblog
Attack and Defense Labs
Attack and Defense Labs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
NISL@THU
NISL@THU
S
Secure Thoughts
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
P
Palo Alto Networks Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
Google DeepMind News
Google DeepMind News
Webroot Blog
Webroot Blog

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19) 使用 Velero 备份 Kubernetes 集群 Kubernetes Cheat Sheet 开发 Tips(18) 如何构建一个 Java 工程 开发 Tips(17) KubeSpray 安装 Kubernetes 报错 ip in ansible_all_ipv4_addresses 基于 Kubernetes 和 Jenkins 搭建自动化测试系统 在 Kubernetes 上动态创建 Jenkins Slave 使用 Jenkins 进行服务拨测 开发 Tips(16) Kubernetes 签发 Ingress 证书及日常故障运维 Kubernetes 中 Deployment 的基本操作 Kubernetes 中的证书 如何使用 KubeBuilder 开发一个 Operator Kubernetes 1.6.0 安装问题汇总 镜像管理工具 -- Harbor 开发 Tips(15) Docker 如何拉取镜像 开发 Tips(14) 使用 Helm 安装 harbor 开发 Tips(13) 使用 S2I 构建云原生应用 在 Kubernetes 中使用 emptyDir、hostPath、localVolume 开发 Tips(12) 开发 Tips(11) 代码质量分析工具 SonarQube 使用 Kubeadm 安装 Kubernetes 集群 一起来学 Go --(4)常用函数 Kubernetes 中的 Ceph Kubernetes 之 Volumes Kubernetes 之 Labels、Selectors 开发 Tips(10) 开源正在重构商业模式 Kubernetes 之网络 Kubernetes 之 API 使用 Helm 和 Operator 快速部署 Prometheus Kubernetes 复杂有状态应用管理框架 -- Operator Kubernetes 的包管理器 -- Helm 一起来学 Go --(3)Go Modules 如何一步一步地优化博客方案 kubectl 实用指南 Kubernetes 中的基本概念 搭建远程 Kubernetes 开发环境 大公司和小公司的 ToB 思路 开发 Tips(9) Go 入门指南 一起来学 Go --(2)数据与逻辑结构 如何预防 Web 富文本中的 XSS 攻击 django-xss-cleaner 云工作时代 一起来学 Go --(1)背景与特点 SaaS 开发团队的不同阶段 你不知道的 Git 使用技巧 输出既服务 微服务设计 继续奔跑 开发 Tips(8) 从账户安全到二次验证 Django 性能之数据库查询优化 Django 性能之分库分表 敏捷开发之研发流程 打造一致性的团队 开发 Tips(7) Pytest 进阶学习之 Mock PaaS 部署之 buildpack Go 开发配置 领域输出才是 PaaS 的核心竞争力 Pytest 入门学习 开发 Tips(6) 如何使用 Jenkins、Docker、GitLab 搭建 Django 自动化部署流程
在 Kubernetes 下创建后端为 JuiceFS 的 PVC(企业版)
微信公众号 · 2024-03-08 · via 陈少文的网站

本篇主要记录创建企业版 JuiceFS PVC 的脚本,方便快速配置。

1. 设置环境变量

1.1 基础配置

1
2
3
export NAMESPACE=
export PVC_NAME=
export JUICEFS_VOLUME=

1.2 JuiceFS 认证信息

1
2
3
export TOKEN=
export ACCESS_KEY=
export SECRET_KEY=

1.3 JuiceFS 服务配置

1
2
export BASE_URL=http://x.x.x.x:8080/static
export CFG_URL=http://x.x.x.x:8080/volume/%s/mount

1.4 镜像配置

1
2
3
4
export JUICEFS_IMAGE=juicedata/mount
export JUICEFS_IMAGE_TAG=ee-5.2.13-7a0eb79

export DEMO_IMAGE=ubuntu

1.5 Worker 配置

1
2
3
export WORKER_REPLICAS=1
export NODE_SELECTOR_KEY=
export NODE_SELECTOR_VALUE="true"

1.6 缓存配置

1
2
3
export CACHE_GROUP="${PVC_NAME}-cache-group"
export CACHE_PATH=/data/jfs-cache
export CACHE_QUOTA=2Ti

不同网络分区的集群,CACHE_GROUP 应该设置为不同的值,禁止共享缓存数据。

2. 创建 Secret

创建包含 JuiceFS 认证信息和配置的 Secret。

1
2
3
4
5
6
kubectl -n $NAMESPACE create secret generic ${PVC_NAME} \
  --from-literal=name=$PVC_NAME \
  --from-literal=token="$TOKEN" \
  --from-literal=accesskey=$ACCESS_KEY \
  --from-literal=secretkey=$SECRET_KEY \
  --from-literal=envs="{\"BASE_URL\": \"$BASE_URL\", \"CFG_URL\": \"$CFG_URL\"}"

3. 创建 Dataset

创建 Dataset 资源,配置挂载点和加密选项。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
kubectl apply -f - <<EOF
apiVersion: data.fluid.io/v1alpha1
kind: Dataset
metadata:
    name: $PVC_NAME
    namespace: $NAMESPACE
spec:
    accessModes:
      - ReadWriteMany
    mounts:
      - name: $JUICEFS_VOLUME
        mountPoint: juicefs:///
        options:
            max-uploads: "200"
            max-cached-inodes: "10000000"
            cache-size: "2048000"
            opencache: ""
            buffer-size: "2048"
            cache-group: "$CACHE_GROUP"
        encryptOptions:
        - name: access-key
          valueFrom:
            secretKeyRef:
                name: ${PVC_NAME}
                key: accesskey
        - name: secret-key
          valueFrom:
            secretKeyRef:
                name: ${PVC_NAME}
                key: secretkey
        - name: token
          valueFrom:
            secretKeyRef:
                name: ${PVC_NAME}
                key: token
EOF

4. 创建 JuiceFSRuntime

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
kubectl apply -f - <<EOF
apiVersion: data.fluid.io/v1alpha1
kind: JuiceFSRuntime
metadata:
    name: $PVC_NAME
    namespace: $NAMESPACE
spec:
    replicas: $WORKER_REPLICAS
    juicefsVersion:
        image: $JUICEFS_IMAGE
        imageTag: $JUICEFS_IMAGE_TAG
    fuse:
        image: $JUICEFS_IMAGE
        imageTag: $JUICEFS_IMAGE_TAG
        env:
            - name: BASE_URL
              value: $BASE_URL
            - name: CFG_URL
              value: $CFG_URL
        cleanPolicy: OnDemand
        options:
          cache-size: "0"
    worker:
        env:
            - name: BASE_URL
              value: $BASE_URL
            - name: CFG_URL
              value: $CFG_URL
        nodeSelector:
          $NODE_SELECTOR_KEY: "$NODE_SELECTOR_VALUE"
        resources:
          requests:
            cpu: 1
            memory: 5Gi
    tieredstore:
        levels:
        - mediumtype: SSD
          path: $CACHE_PATH
          quota: $CACHE_QUOTA
          low: "0.2"
EOF

5. 创建测试 Pod

创建测试 Pod 验证 PVC 是否正常工作。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: ${PVC_NAME}
  namespace: $NAMESPACE
spec:
  containers:
    - name: demo
      image: $DEMO_IMAGE
      command: ["sleep", "infinity"]
      volumeMounts:
        - mountPath: /data/jfs
          name: data
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: $PVC_NAME
EOF

6. 清理资源

1
2
3
4
kubectl -n $NAMESPACE delete pod ${PVC_NAME}
kubectl -n $NAMESPACE delete juicefsruntime $PVC_NAME
kubectl -n $NAMESPACE delete dataset $PVC_NAME
kubectl -n $NAMESPACE delete secret ${PVC_NAME}

7. 其他配置

  • 自定义配置

worker 和 fuse 会使用 /root/.juicefs 目录下的配置文件,这个配置文件是通过 juicefs auth 命令生成的。如果需要自定义配置文件,可以创建一个 Secret,然后在 JuiceFSRuntime 中挂载这个 Secret。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
apiVersion: v1
kind: Secret
metadata:
  name: ${PVC_NAME}-conf
  namespace: $NAMESPACE
type: Opaque
stringData:
  ${JUICEFS_VOLUME}.conf: |
    {
      "master": "cn-beijing-1.local:9420",
      "master_ip": [
      ],
      "storage": "ks3",
      "region": "cn-beijing",
      "bucket": "http://my-bucket.ks3.my-domain.com"
    }

这里的 bucket 完成域名是 JuiceFS 根据环境探测所得,如果内网域名能联通会优先使用内网域名。如果需要自定义,可以在配置文件中指定完整的域名。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
apiVersion: data.fluid.io/v1alpha1
kind: JuiceFSRuntime
metadata:
  name: jfsdemo-ee
spec:
  fuse:
    volumeMounts:
      - name: auth-config
        mountPath: "/root/.juicefs"
  volumes:
    - name: auth-config
      secret:
        secretName: ${PVC_NAME}-conf