您好,登錄后才能下訂單哦!
kubernetes集群三步安裝
git clone https://github.com/rook/rook
cd cluster/examples/kubernetes/ceph
kubectl create -f operator.yaml
查看operator是否成功:
[root@dev-86-201 ~]# kubectl get pod -n rook-ceph-system
NAME READY STATUS RESTARTS AGE
rook-ceph-agent-5z6p7 1/1 Running 0 88m
rook-ceph-agent-6rj7l 1/1 Running 0 88m
rook-ceph-agent-8qfpj 1/1 Running 0 88m
rook-ceph-agent-xbhzh 1/1 Running 0 88m
rook-ceph-operator-67f4b8f67d-tsnf2 1/1 Running 0 88m
rook-discover-5wghx 1/1 Running 0 88m
rook-discover-lhwvf 1/1 Running 0 88m
rook-discover-nl5m2 1/1 Running 0 88m
rook-discover-qmbx7 1/1 Running 0 88m
然后創(chuàng)建ceph集群:
kubectl create -f cluster.yaml
查看ceph集群:
[root@dev-86-201 ~]# kubectl get pod -n rook-ceph
NAME READY STATUS RESTARTS AGE
rook-ceph-mgr-a-8649f78d9b-jklbv 1/1 Running 0 64m
rook-ceph-mon-a-5d7fcfb6ff-2wq9l 1/1 Running 0 81m
rook-ceph-mon-b-7cfcd567d8-lkqff 1/1 Running 0 80m
rook-ceph-mon-d-65cd79df44-66rgz 1/1 Running 0 79m
rook-ceph-osd-0-56bd7545bd-5k9xk 1/1 Running 0 63m
rook-ceph-osd-1-77f56cd549-7rm4l 1/1 Running 0 63m
rook-ceph-osd-2-6cf58ddb6f-wkwp6 1/1 Running 0 63m
rook-ceph-osd-3-6f8b78c647-8xjzv 1/1 Running 0 63m
參數(shù)說明:
apiVersion: ceph.rook.io/v1
kind: CephCluster
metadata:
name: rook-ceph
namespace: rook-ceph
spec:
cephVersion:
# For the latest ceph images, see https://hub.docker.com/r/ceph/ceph/tags
image: ceph/ceph:v13.2.2-20181023
dataDirHostPath: /var/lib/rook # 數(shù)據(jù)盤目錄
mon:
count: 3
allowMultiplePerNode: true
dashboard:
enabled: true
storage:
useAllNodes: true
useAllDevices: false
config:
databaseSizeMB: "1024"
journalSizeMB: "1024"
訪問ceph dashboard:
[root@dev-86-201 ~]# kubectl get svc -n rook-ceph
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rook-ceph-mgr ClusterIP 10.98.183.33 <none> 9283/TCP 66m
rook-ceph-mgr-dashboard NodePort 10.103.84.48 <none> 8443:31631/TCP 66m # 把這個改成NodePort模式
rook-ceph-mon-a ClusterIP 10.99.71.227 <none> 6790/TCP 83m
rook-ceph-mon-b ClusterIP 10.110.245.119 <none> 6790/TCP 82m
rook-ceph-mon-d ClusterIP 10.101.79.159 <none> 6790/TCP 81m
然后訪問https://10.1.86.201:31631 即可
管理賬戶admin,獲取登錄密碼:
kubectl -n rook-ceph get secret rook-ceph-dashboard-password -o yaml | grep "password:" | awk '{print $2}' | base64 --decode
apiVersion: ceph.rook.io/v1
kind: CephBlockPool
metadata:
name: replicapool # operator會監(jiān)聽并創(chuàng)建一個pool,執(zhí)行完后界面上也能看到對應(yīng)的pool
namespace: rook-ceph
spec:
failureDomain: host
replicated:
size: 3
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: rook-ceph-block # 這里創(chuàng)建一個storage class, 在pvc中指定這個storage class即可實現(xiàn)動態(tài)創(chuàng)建PV
provisioner: ceph.rook.io/block
parameters:
blockPool: replicapool
# The value of "clusterNamespace" MUST be the same as the one in which your rook cluster exist
clusterNamespace: rook-ceph
# Specify the filesystem type of the volume. If not specified, it will use `ext4`.
fstype: xfs
# Optional, default reclaimPolicy is "Delete". Other options are: "Retain", "Recycle" as documented in https://kubernetes.io/docs/concepts/storage/storage-classes/
reclaimPolicy: Retain
在cluster/examples/kubernetes 目錄下,官方給了個worldpress的例子,可以直接運行一下:
kubectl create -f mysql.yaml
kubectl create -f wordpress.yaml
查看PV PVC:
[root@dev-86-201 ~]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
mysql-pv-claim Bound pvc-a910f8c2-1ee9-11e9-84fc-becbfc415cde 20Gi RWO rook-ceph-block 144m
wp-pv-claim Bound pvc-af2dfbd4-1ee9-11e9-84fc-becbfc415cde 20Gi RWO rook-ceph-block 144m
[root@dev-86-201 ~]# kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-a910f8c2-1ee9-11e9-84fc-becbfc415cde 20Gi RWO Retain Bound default/mysql-pv-claim rook-ceph-block 145m
pvc-af2dfbd4-1ee9-11e9-84fc-becbfc415cde 20Gi RWO Retain Bound default/wp-pv-claim rook-ceph-block 145m
看下yaml文件:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
labels:
app: wordpress
spec:
storageClassName: rook-ceph-block # 指定storage class
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi # 需要一個20G的盤
...
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim # 指定上面定義的PVC
是不是非常簡單。
要訪問wordpress的話請把service改成NodePort類型,官方給的是loadbalance類型:
kubectl edit svc wordpress
[root@dev-86-201 kubernetes]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
wordpress NodePort 10.109.30.99 <none> 80:30130/TCP 148m
分布式存儲在容器集群中充當非常重要的角色,使用容器集群一個非常重要的理念就是把集群當成一個整體使用,如果你在使用中還關(guān)心單個主機,比如調(diào)度到某個節(jié)點,
掛載某個節(jié)點目錄等,必然會導(dǎo)致不能把云的威力百分之百發(fā)揮出來。 一旦計算存儲分離后,就可真正實現(xiàn)隨意漂移,對集群維護來說是個極大的福音。
比如集群機器過保了需要下架,那么我們云化的架構(gòu)因為所有東西無單點,所以只需要簡單驅(qū)逐改節(jié)點,然后下架即可,不用關(guān)心上面跑的是什么業(yè)務(wù),不管是有狀態(tài)還是無
狀態(tài)的都可以自動修復(fù)。 不過目前面臨最大的挑戰(zhàn)可能還是分布式存儲的性能問題。 在性能要求不苛刻的場景下我是極推薦這種計算存儲分離架構(gòu)的。
探討可加QQ群:98488045
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。