From 82af1cc42d67b68e37e0160651a62fd64345b99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=AF=E8=88=AA?= <101104760+ZhangSetSail@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:45:46 +0800 Subject: [PATCH] fix: create deploy volume is RWX (#2015) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张启航 <101104760+ZhangSetSail@users.noreply.github.com> --- worker/appm/volume/other.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/worker/appm/volume/other.go b/worker/appm/volume/other.go index 0ddf987bf..4d2b4f255 100644 --- a/worker/appm/volume/other.go +++ b/worker/appm/volume/other.go @@ -34,6 +34,7 @@ type OtherVolume struct { // CreateVolume ceph rbd volume create volume func (v *OtherVolume) CreateVolume(define *Define) error { + statefulset := v.as.GetStatefulSet() //有状态组件 if v.svm.VolumeType == dbmodel.ShareFileVolumeType.String() { v.svm.VolumeType = v.as.SharedStorageClass } @@ -52,10 +53,12 @@ func (v *OtherVolume) CreateVolume(define *Define) error { volumeReadOnly := v.svm.IsReadOnly labels := v.as.GetCommonLabels(map[string]string{"volume_name": v.svm.VolumeName, "version": v.as.DeployVersion, "reclaim_policy": v.svm.ReclaimPolicy}) annotations := map[string]string{"volume_name": v.svm.VolumeName} + if statefulset == nil { + v.svm.AccessMode = "RWX" + } claim := newVolumeClaim(volumeMountName, volumeMountPath, v.svm.AccessMode, v.svm.VolumeType, v.svm.VolumeCapacity, labels, annotations) logrus.Debugf("storage class is : %s, claim value is : %s", v.svm.VolumeType, claim.GetName()) - v.as.SetClaim(claim) // store claim to appService - statefulset := v.as.GetStatefulSet() //有状态组件 + v.as.SetClaim(claim) // store claim to appService vo := corev1.Volume{Name: volumeMountName} vo.PersistentVolumeClaim = &corev1.PersistentVolumeClaimVolumeSource{ClaimName: claim.GetName(), ReadOnly: volumeReadOnly} if statefulset != nil {