在k8s中使用rook-ceph


https://rook.io/docs/rook/v1.1/ceph-examples.html rook-ceph官方指導

https://github.com/rook/rook/tree/master/cluster/examples/kubernetes/ceph github項目地址

gitlab上傳的附件

cluster.yaml修改的內容

  1. 修改 hostNetwork: true,設為false后運行一段時間出現osd掉線的情況,可能是內部網絡的問題
  2. 修改 node的調度策略,只要ceph-osd為enabled的node才可調度osd的pod,其他類似
     osd:
      nodeAffinity:
         requiredDuringSchedulingIgnoredDuringExecution:
           nodeSelectorTerms:
           - matchExpressions:
             - key: ceph-osd
               operator: In
               values:
               - enabled
    
  3. 選擇node運行的存儲
    - node:
     - name: "k8s-node03"
       devices: # specific devices to use for storage can be specified for each node
       - name: "vdb"
    
  4. 開啟mgr dashbord
     dashboard:
         enabled: true
    

rbd的使用

執行storageclass-delete.yaml文件,此文件大致執行如下內容:

  1. 創建pool

  2. 創建storageclass

    • 目前的版本中可使用兩種方式使用storageclass,flexvolumn和csi模式
    • flexvolum為插件模式
    • csi即CSI container storage insterface 容器存儲接口
    • 官方對此兩種的使用方式為

    The storage classes are found in different sub-directories depending on the driver:

    csi/rbd: The CSI driver for block devices. This is the preferred driver going forward.

    flex: The flex driver will be deprecated in a future release to be determined.

    • 所以此處使用csi這種面向未來的方式
  3. xfs和ext4的選擇,centos7.2后的標准文件系統為xfs,詳細可查看ext4和xfs的區別

  4. reclaimPolicy: Delete選擇為Delete,在刪除pvc后可直接刪除對應的pv,默認此選項供測試使用

  5. 另一種模式為Retained,只刪除pvc讓不會對pv有任何的操作,需要手動刪除

  6. 需要注意的是rbd模式只支持RWO模式,ReadWriteOnce

  7. 動態存儲卷調用實例

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    name: nginx-pvc
    spec:
    accessModes:
        - ReadWriteOnce
    resources:
        requests:
        storage: 1Gi
    storageClassName: rook-ceph
    

cephfs的使用

有問題(略)

object store對象存儲的使用

  1. 執行object-store.yaml文件,生成rgw pod
  2. 執行storageclass-bucket-retain.yaml文件,生成storageclass存儲
  3. 執行ingress-rgw-mystore.yaml文件,將此對象存儲映射出來可供訪問
  4. 執行cephobjstoreUser.yaml文件,生成對象存儲的用戶
     獲取Access key
     kubectl get secret rook-ceph-object-user-my-store-admin -o yaml -n rook-ceph|grep AccessKey | awk '{print $2}' | base64 --decode
     獲取Secret Key
     kubectl get secret rook-ceph-object-user-my-store-admin -o yaml -n rook-ceph|grep SecretKey | awk '{print $2}' | base64 --decode
    
  5. 使用s3 browser訪問對象存儲
  6. 使用s3 cmd訪問對象存儲
    • s3cmd --configure 生成配置文件
    • 修改生成的配置文件.s3cfg,需對應修改如下幾項
    access_key = SH48VDNKNIIZT45TYO1P
    host_base = oss.jwt.com
    host_bucket = %(*)s.oss.jwt.com
    secret_key = wTjY1bU3UH4AvDB7w6s4VnP97O5IsoeWbEkxwCP2
    use_https = False
    
    • 其他命令使用
    s3cmd ls 查看bucket列表
    s3cmd mb s3://my-bucket-name 創建bucket,且bucket名稱是唯一的,不可重復
    s3cmd rb s3://my-bucket-name 刪除空的bucket
    s3cmd rb s3://my-bucket-name 列舉bucket中的內容
    s3cmd put file.txt s3://my-bucket-name/file.txt 上傳文件到bucket的指定目錄下
    s3cmd put ./* s3://my-bucket-name/ 批量上傳
    s3cmd get s3://my-bucket-name/file.txt file.txt 下載bucket中的指定文件
    s3cmd get s3://my-bucket-name/* ./ 批量下載
    s3cmd del s3://my-bucket-name/file.txt 刪除bucket中的文件
    
  7. 設置mgr dashbord中的object gateway,根據官方設置,未成功

Enabling Dashboard Object Gateway managementProvided you have deployed the Ceph Toolbox, created an Object Store and a user, you can enable Object Gateway management by providing the user credentials to the dashboard:

Access toolbox CLI:
kubectl -n rook-ceph exec -it $(kubectl -n rook-ceph get pod -l "app=rook-ceph-tools" -o jsonpath='{.items[0].metadata.name}') bash

Enable system flag on the user:
radosgw-admin user modify --uid=my-user --system

Provide the user credentials:
ceph dashboard set-rgw-api-user-id my-user
ceph dashboard set-rgw-api-access-key
ceph dashboard set-rgw-api-secret-key -->

rook-ceph-tools使用

  1. 執行toolbox.yaml,生成rook-ceph-tools-xxxx pod

  2. 使用kubectl -n rook-ceph exec -it $(kubectl -n rook-ceph get pod -l "app=rook-ceph-tools" -o jsonpath='{.items[0].metadata.name}') bash 命令進入ceph的管理中

  3. ceph常用命令

    ceph -s 查看集群狀態
    ceph osd status 查看osd狀態
    ceph pg stat 查看pg狀態
    ceph osd pool set pool pg_num 64 設置pg數量
    ceph osd pool set pool pgp_num 64 設置pgp數量,在集群規模較小,pg數量過少會導致監控警告,此兩條命令需一起使用
    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM