Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

请在使用站内资源的同时不要恶意进行爬取或倒链等行为,感谢支持!

Note

相关文档:

UI Button
colorblue
newWindowtrue
sizesmall
displayblock
iconlink
title链接

Info
iconfalse

Table of Contents

Kubernetes Rbd Static

上述文章都是介绍 rbd 动态使用,下面通过静态(已经创建好的 rbd)进行使用。

创建 pool 后创建 rbd:

Code Block
languagebash
$ ceph osd pool create gitlab-ops 32 32
$ rbd create gitlab-ops/data --size 71680 --image-format 2 --image-feature layering
$ rbd create gitlab-ops/config --size 10240 --image-format 2 --image-feature layering
$ rbd create gitlab-ops/log --size 10240 --image-format 2 --image-feature layering

创建 Secret:

Code Block
languagebash
$ AUTH=`ceph auth get-key client.admin`
$ kubectl create secret generic ceph-admin-secret --from-literal=key=${AUTH} -n gitlab

创建 PV:

Code Block
languagebash
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlab-ops-stroagestorage-data
spec:
  capacity:
    storage: 70Gi
  accessModes:
    - ReadWriteOnce
  rbd:
    monitors:
      - 10.100.21.93:6789,10.100.21.94:6789,10.100.21.95:6789
    pool: gitlab-ops
    image: data
    user: admin
    secretRef:
      name: ceph-admin-secret
    fsType: ext4
    readOnly: false
  storageClassName: gitlab-ops-stroagestorage-data
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlab-ops-stroagestorage-log
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  rbd:
    monitors:
      - 10.100.21.93:6789,10.100.21.94:6789,10.100.21.95:6789
    pool: gitlab-ops
    image: log
    user: admin
    secretRef:
      name: ceph-admin-secret
    fsType: ext4
    readOnly: false
  storageClassName: gitlab-ops-stroagestorage-log
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlab-ops-stroagestorage-config
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  rbd:
    monitors:
      - 10.100.21.93:6789,10.100.21.94:6789,10.100.21.95:6789
    pool: gitlab-ops
    image: config
    user: admin
    secretRef:
      name: ceph-admin-secret
    fsType: ext4
    readOnly: false
  storageClassName: gitlab-ops-stroagestorage-config

创建 PVC:

Code Block
languagebash
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-ops-stroagestorage-data
  namespace: gitlab
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 70Gi
  storageClassName: gitlab-ops-stroagestorage-data
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-ops-stroagestorage-log
  namespace: gitlab
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: gitlab-ops-stroagestorage-log
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-ops-stroagestorage-config
  namespace: gitlab
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: gitlab-ops-stroagestorage-config

创建 Test Pod:

Code Block
languagebash
apiVersion: v1
kind: Pod
metadata:
  name: rbd-test
  namespace: gitlab
spec:
  restartPolicy: OnFailure
  hostNetwork: true
  containers:
  - name: pod
    image: alpine
    command: ["/bin/sh","-c", "sleep 3000"]
    volumeMounts:
    - name: rbd
      mountPath: /mnt/rbd
  volumes:
  - name: rbd
    persistentVolumeClaim:
      claimName: gitlab-ops-stroagestorage-data
Warning

rbd 只能有一个实例进行挂载,否则会提示如下错误:

Code Block
languagebash
$ kubectl describe pod rbd-test -n gitlab
...
Events:
  Type     Reason              Age    From                                 Message
  ----     ------              ----   ----                                 -------
  Normal   Scheduled           3m27s  default-scheduler                    Successfully assigned gitlab/rbd-test to master001.k8s.zhangyue.com
  Warning  FailedAttachVolume  3m27s  attachdetach-controller              Multi-Attach error for volume "gitlab-ops-stroagestorage-data" Volume is already used by pod(s) gitlab-ops-0
  Warning  FailedMount         84s    kubelet, master001.k8s.zhangyue.com  Unable to mount volumes for pod "rbd-test_gitlab(838a14ba-f2cc-4907-b3fe-18018976b6f1)": timeout expired waiting for volumes to attach or mount for pod "gitlab"/"rbd-test". list of unmounted volumes=[rbd]. list of unattached volumes=[rbd default-token-cxx9p]


文档创建于 最后一次更新于  , 文档当前的状态 

Status
colourGreen
title正式版
 , 当前编写页面的版本 
Status
colourBlue
titlev1.3.1
 。