Kubernetes云原生存储解决方案openebs部署实践-3.10.0版本(helm部署)

Kubernetes云原生存储解决方案openebs部署实践-3.10.0版本(helm部署)

记录在k8s 1.19.0集群环境下安装openebs 3.10.0。

环境信息如下:

shell 复制代码
[root@k8s-master ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[root@k8s-master ~]# uname -a
Linux k8s-master 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@k8s-master ~]# kubectl get node
NAME         STATUS   ROLES    AGE   VERSION
k8s-master   Ready    master   16d   v1.19.0
k8s-node1    Ready    worker   16d   v1.19.0
k8s-node2    Ready    worker   16d   v1.19.0
[root@k8s-master ~]# helm version
version.BuildInfo{Version:"v3.6.1", GitCommit:"61d8e8c4a6f95540c15c6a65f36a6dd0a45e7a2f", GitTreeState:"clean", GoVersion:"go1.16.5"}

1. 安装openebs

openebs支持kubectl基于yaml安装,也可以使用helm进行安装。本文基于helm方式。

  1. 配置helm仓库
shell 复制代码
[root@k8s-master ~]# helm repo add openebs https://openebs.github.io/charts

[root@k8s-master ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "grafana" chart repository
...Successfully got an update from the "ingress-nginx" chart repository
...Successfully got an update from the "bitnami" chart repository
...Successfully got an update from the "prometheus-community" chart repository
...Successfully got an update from the "openebs" chart repository
Update Complete. ⎈Happy Helming!⎈
  1. 安装 openebs chart
shell 复制代码
[root@k8s-master ~]# helm install openebs --namespace openebs openebs/openebs --create-namespace
NAME: openebs
LAST DEPLOYED: Fri Jun 28 15:14:46 2024
NAMESPACE: openebs
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Successfully installed OpenEBS.

Check the status by running: kubectl get pods -n openebs

The default values will install NDM and enable OpenEBS hostpath and device
storage engines along with their default StorageClasses. Use `kubectl get sc`
to see the list of installed OpenEBS StorageClasses.

**Note**: If you are upgrading from the older helm chart that was using cStor
and Jiva (non-csi) volumes, you will have to run the following command to include
the older provisioners:

helm upgrade openebs openebs/openebs \
        --namespace openebs \
        --set legacy.enabled=true \
        --reuse-values

For other engines, you will need to perform a few more additional steps to
enable the engine, configure the engines (e.g. creating pools) and create
StorageClasses.

For example, cStor can be enabled using commands like:

helm upgrade openebs openebs/openebs \
        --namespace openebs \
        --set cstor.enabled=true \
        --reuse-values

For more information,
- view the online documentation at https://openebs.io/docs or
- connect with an active community on Kubernetes slack #openebs channel.
  1. 检查部署的资源:
shell 复制代码
# 部署的chart
[root@k8s-master ~]# helm ls -n openebs
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
openebs openebs         1               2024-06-28 15:14:46.982427602 +0800 CST deployed        openebs-3.10.0  3.10.0

# pods
[root@k8s-master ~]# kubectl get pod -n openebs -o wide
NAME                                           READY   STATUS    RESTARTS   AGE     IP             NODE         NOMINATED NODE   READINESS GATES
openebs-localpv-provisioner-685b678c88-lq57l   1/1     Running   0          9m49s   10.244.0.232   k8s-master   <none>           <none>
openebs-ndm-bxzwv                              1/1     Running   0          9m49s   192.168.0.51   k8s-master   <none>           <none>
openebs-ndm-d54bt                              1/1     Running   1          9m49s   192.168.0.53   k8s-node2    <none>           <none>
openebs-ndm-hjnpx                              1/1     Running   2          9m49s   192.168.0.52   k8s-node1    <none>           <none>
openebs-ndm-operator-c959d9d77-dscd2           1/1     Running   0          9m49s   10.244.0.233   k8s-master   <none>           <none>

# 存储类
[root@k8s-master ~]# kubectl get sc
NAME               PROVISIONER        RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
openebs-device     openebs.io/local   Delete          WaitForFirstConsumer   false                  16d
openebs-hostpath   openebs.io/local   Delete          WaitForFirstConsumer   false                  16d

本文安装的openebs版本较低,3.10.0版本,较新版本的chart仓库已经变更,详情参考官方文档:

官方文档:https://openebs.netlify.app/docs/quickstart-guide/installation

官方仓库:https://github.com/openebs/openebs

2. demo测试

openebs部署完成后会自动创建存储类,我们使用openebs-hostpath这个StorageClass来创建PVC

创建一个示例应用挂载openebs提供的存储进行测试。资源清单文件openebs-test.yaml,包括pvc和pod:

yaml 复制代码
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: local-hostpath-pvc
spec:
  storageClassName: openebs-hostpath
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: hello-local-hostpath-pod
spec:
  volumes:
  - name: local-storage
    persistentVolumeClaim:
      claimName: local-hostpath-pvc
  containers:
  - name: hello-container
    image: busybox
    command:
       - sh
       - -c
       - 'while true; do echo "`date` [`hostname`] Hello from OpenEBS Local PV." >> /mnt/store/greet.txt; sleep $(($RANDOM % 5 + 300)); done'
    volumeMounts:
    - mountPath: /mnt/store
      name: local-storage

创建资源:kubectl create -f openebs-test.yaml,等待创建完成。

shell 复制代码
[root@k8s-master openebs]# kubectl get pod -o wide
NAME                       READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES
hello-local-hostpath-pod   1/1     Running   0          15m   10.244.1.65   k8s-node1   <none>           <none>

[root@k8s-master openebs]# kubectl get pvc
NAME                 STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS       AGE
local-hostpath-pvc   Bound    pvc-b240b152-718e-44e2-938f-0255e457ec8f   5Gi        RWO            openebs-hostpath   11m

[root@k8s-master openebs]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                        STORAGECLASS       REASON   AGE
pvc-b240b152-718e-44e2-938f-0255e457ec8f   5Gi        RWO            Delete           Bound    default/local-hostpath-pvc   openebs-hostpath            8m49s

# 检查node1节点的本地路径
[root@k8s-node1 ~]# cat /var/openebs/local/pvc-b240b152-718e-44e2-938f-0255e457ec8f/greet.txt
Fri Jun 28 08:11:00 UTC 2024 [hello-local-hostpath-pod] Hello from OpenEBS Local PV.
Fri Jun 28 08:16:04 UTC 2024 [hello-local-hostpath-pod] Hello from OpenEBS Local PV.
Fri Jun 28 08:21:08 UTC 2024 [hello-local-hostpath-pod] Hello from OpenEBS Local PV.
相关推荐
Linux运维老纪6 小时前
DNS缓存详解(DNS Cache Detailed Explanation)
计算机网络·缓存·云原生·容器·kubernetes·云计算·运维开发
元气满满的热码式14 小时前
K8S部署DevOps自动化运维平台
运维·kubernetes·devops
IT艺术家-rookie19 小时前
k8s--部署k8s集群--控制平面节点
容器·kubernetes
Elastic 中国社区官方博客20 小时前
使用 Ollama 和 Kibana 在本地为 RAG 测试 DeepSeek R1
大数据·数据库·人工智能·elasticsearch·ai·云原生·全文检索
Linux运维老纪1 天前
windows部署deepseek之方法(The Method of Deploying DeepSeek on Windows)
linux·人工智能·分布式·云原生·运维开发·devops
Elastic 中国社区官方博客2 天前
Elastic Cloud Serverless 获得主要合规认证
大数据·数据库·elasticsearch·搜索引擎·云原生·serverless·全文检索
超级阿飞2 天前
在K8s中部署动态nfs存储provisioner
云原生·容器·kubernetes·nfs
赵渝强老师2 天前
【赵渝强老师】K8s中Pod探针的TCPSocketAction
云原生·容器·kubernetes
努力的小T2 天前
Linux二进制部署K8s集群的平滑升级教程
linux·运维·服务器·云原生·容器·kubernetes·云计算
2的n次方_2 天前
Eureka 服务注册和服务发现的使用
spring boot·spring cloud·云原生·eureka·服务发现