Skip to content

Commit

Permalink
Merge pull request #21 from xishengcai/caixisheng
Browse files Browse the repository at this point in the history
add storageClass accessMode parameter
  • Loading branch information
caixisheng authored Nov 28, 2022
2 parents f51d9a8 + 0310fb6 commit 799539e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions apis/core/v1alpha2/volume_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1alpha2
import (
runtimev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
"github.com/xishengcai/oam/pkg/oam"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -13,6 +14,11 @@ type VolumeClaimSpec struct {
Type string `json:"type,omitempty"`
//HostPath string `json:"hostPath,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
// type enum:"ReadWriteOnce,ReadOnlyMany,ReadWriteMany"
// ReadWriteOnce – the volume can be mounted as read-write by a single node
// ReadOnlyMany – the volume can be mounted read-only by many nodes
// ReadWriteMany – the volume can be mounted as read-write by many nodes
AccessMode v1.PersistentVolumeAccessMode `json:"accessMode,omitempty"`
Size string `json:"size,omitempty"`
}

Expand Down Expand Up @@ -60,4 +66,6 @@ type VolumeClaimConfig struct {
//HostPath string `json:"hostPath,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
Size string `json:"size,omitempty"`
AccessMode v1.PersistentVolumeAccessMode `json:"accessMode,omitempty"`

}
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ spec:
volumeClaims:
items:
properties:
accessMode:
type: string
hostPath:
type: string
name:
type: string
size:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ spec:
type: object
spec:
properties:
accessMode:
description: type enum:"ReadWriteOnce,ReadOnlyMany,ReadWriteMany" ReadWriteOnce – the volume can be mounted as read-write by a single node ReadOnlyMany – the volume can be mounted read-only by many nodes ReadWriteMany – the volume can be mounted as read-write by many nodes
type: string
hostPath:
type: string
size:
type: string
storageClassName:
Expand Down
5 changes: 4 additions & 1 deletion examples/volumeclaims/sample_application_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ spec:

volumeClaims:
- type: StorageClass
storageClassName: hello
storageClassName: csi-obs
name: sc-2
size: 10Gi
# accessMode: ReadOnlyOnce
# huawei cce obs must use ReadOnlyMany
accessMode: ReadOnlyMany
- type: HostPath
hostPath: /data/opt/xxx
name: hp-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (r *volumeClaims) renderVolumeClaims(ctx context.Context, ac *v1alpha2.Appl
Spec: v1alpha2.VolumeClaimSpec{
Type: vcc.Type,
StorageClassName: vcc.StorageClassName,
AccessMode: vcc.AccessMode,
Size: vcc.Size,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (r *Reconcile) Reconcile(req ctrl.Request) (ctrl.Result, error) {
Spec: v1.PersistentVolumeClaimSpec{
StorageClassName: &volumeClaim.Spec.StorageClassName,
AccessModes: []v1.PersistentVolumeAccessMode{
v1.ReadWriteOnce,
volumeClaim.Spec.AccessMode,
},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
Expand Down

0 comments on commit 799539e

Please sign in to comment.