glusterfsファイルシステムを使ってk 8 sの耐久化メモリを作ります.
3470 ワード
glusterfsのインストールを参照してください.https://jimmysong.io/kubernetes-handbook/practice/using-glusterfs-for-persistent-storage.html
一、次のスクリプトを使ってデータボリュームを作成します.
shellスクリプト変数の説明:1巻の名前$2マウントパス$3巻のサイズ
二、endpointsの配置
endpoints serviceの設定
三、pvを作成する
kubectl create-f jecins-master-pv.yaml
同前 kubectl create-f jecins-master-pvc.yaml
一、次のスクリプトを使ってデータボリュームを作成します.
#!/bin/bash
if [ $# -lt 3 ];
then
echo "please input at least 3 param"
exit 0
fi
volumeName=$1
mountPath=$2
dbSize=$3
gluster volume create $volumeName replica 2 transport tcp gfs-node1:/data1/gfs_data/${mountPath} gfs-node2:/data1/gfs_data/${mountPath} gfs-node3:/data1/gfs_data/${mountPath} gfs-node4:/data1/gfs_data/
${mountPath} force
gluster volume list
gluster volume start $volumeName
#gluster volume quota $volumeName enable
#gluster volume quota $volumeName limit-usage / ${dbSize}GB
#gluster volume set $volumeName performance.cache-size 2GB
#gluster volume set $volumeName performance.io-thread-count 16
#gluster volume set $volumeName network.ping-timeout 10
#gluster volume set $volumeName performance.write-behind-window-size 1024MB
echo "#########volume list #########"
gluster volume list
同前 createVolume.sh k 8 s-volume-jeck ins-master jeck-master 20shellスクリプト変数の説明:1巻の名前$2マウントパス$3巻のサイズ
二、endpointsの配置
{
"kind": "Endpoints",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster",
"namespace": "ci"
},
"subsets": [
{
"addresses": [
{
"ip": "192.168.1.1"
}
],
"ports": [
{
"port": 1990
}
]
},
{
"addresses": [
{
"ip": "192.168.1.2"
}
],
"ports": [
{
"port": 1990
}
]
},
{
"addresses": [
{
"ip": "192.168.1.3"
}
],
"ports": [
{
"port": 1990
}
]
},
{
"addresses": [
{
"ip": "192.168.1.4"
}
],
"ports": [
{
"port": 1990
}
]
}
]
}
皰kubectl apply-f glusterfs-endpoints.jsonendpoints serviceの設定
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster",
"namespace": "ci"
},
"spec": {
"ports": [
{"port": 1990}
]
}
}
菵 kubectl appy-f glusterfs-service.json三、pvを作成する
kubectl create-f jecins-master-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-jenkins-master
namespace: ci
spec:
capacity:
storage: 20Gi
accessModes:
- ReadWriteMany
glusterfs:
endpoints: "glusterfs-cluster"
path: "k8s-volume-jenkins-master"
readOnly: false
四、pvcを作成する同前 kubectl create-f jecins-master-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-jenkins-master
namespace: ci
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 20Gi
五、k 8 sオブジェクトはpvcを使用する. volumeMounts:
- name: home
mountPath: "/var/jenkins_home"
volumes:
- name: home
persistentVolumeClaim:
claimName: pvc-jenkins-master