feat: Support ephemeral pvc strategy (#1580)

* feat: Support ephemeral pvc strategy

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/1588/head
Anatolii Bazko 2022-12-21 09:24:19 +02:00 committed by GitHub
parent 9961280411
commit bd74906edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 58 additions and 20 deletions

View File

@ -394,12 +394,13 @@ type WorkspaceStorage struct {
// +optional
PerWorkspaceStrategyPvcConfig *PVC `json:"perWorkspaceStrategyPvcConfig,omitempty"`
// Persistent volume claim strategy for the Che server.
// The supported strategies are: `per-user` (all workspaces PVCs in one volume)
// and 'per-workspace' (each workspace is given its own individual PVC).
// For details, see https://github.com/eclipse/che/issues/21185.
// The supported strategies are: `per-user` (all workspaces PVCs in one volume),
// `per-workspace` (each workspace is given its own individual PVC)
// and `ephemeral` (non-persistent storage where local changes will be lost when
// the workspace is stopped.)
// +optional
// +kubebuilder:default:="per-user"
// +kubebuilder:validation:Enum=common;per-user;per-workspace
// +kubebuilder:validation:Enum=common;per-user;per-workspace;ephemeral
PvcStrategy string `json:"pvcStrategy,omitempty"`
}

View File

@ -77,7 +77,7 @@ metadata:
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/eclipse-che/che-operator
support: Eclipse Foundation
name: eclipse-che.v7.58.0-737.next
name: eclipse-che.v7.59.0-739.next
namespace: placeholder
spec:
apiservicedefinitions: {}
@ -1233,7 +1233,7 @@ spec:
minKubeVersion: 1.19.0
provider:
name: Eclipse Foundation
version: 7.58.0-737.next
version: 7.59.0-739.next
webhookdefinitions:
- admissionReviewVersions:
- v1

View File

@ -7040,13 +7040,15 @@ spec:
default: per-user
description: 'Persistent volume claim strategy for the Che
server. The supported strategies are: `per-user` (all
workspaces PVCs in one volume) and ''per-workspace'' (each
workspace is given its own individual PVC). For details,
see https://github.com/eclipse/che/issues/21185.'
workspaces PVCs in one volume), `per-workspace` (each
workspace is given its own individual PVC) and `ephemeral`
(non-persistent storage where local changes will be lost
when the workspace is stopped.)'
enum:
- common
- per-user
- per-workspace
- ephemeral
type: string
type: object
tolerations:

View File

@ -6849,12 +6849,15 @@ spec:
default: per-user
description: 'Persistent volume claim strategy for the Che
server. The supported strategies are: `per-user` (all workspaces
PVCs in one volume) and ''per-workspace'' (each workspace
is given its own individual PVC). For details, see https://github.com/eclipse/che/issues/21185.'
PVCs in one volume), `per-workspace` (each workspace is
given its own individual PVC) and `ephemeral` (non-persistent
storage where local changes will be lost when the workspace
is stopped.)'
enum:
- common
- per-user
- per-workspace
- ephemeral
type: string
type: object
tolerations:

View File

@ -4632,11 +4632,12 @@ spec:
type: object
pvcStrategy:
default: per-user
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume) and ''per-workspace'' (each workspace is given its own individual PVC). For details, see https://github.com/eclipse/che/issues/21185.'
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume), `per-workspace` (each workspace is given its own individual PVC) and `ephemeral` (non-persistent storage where local changes will be lost when the workspace is stopped.)'
enum:
- common
- per-user
- per-workspace
- ephemeral
type: string
type: object
tolerations:

View File

@ -4627,11 +4627,12 @@ spec:
type: object
pvcStrategy:
default: per-user
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume) and ''per-workspace'' (each workspace is given its own individual PVC). For details, see https://github.com/eclipse/che/issues/21185.'
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume), `per-workspace` (each workspace is given its own individual PVC) and `ephemeral` (non-persistent storage where local changes will be lost when the workspace is stopped.)'
enum:
- common
- per-user
- per-workspace
- ephemeral
type: string
type: object
tolerations:

View File

@ -4632,11 +4632,12 @@ spec:
type: object
pvcStrategy:
default: per-user
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume) and ''per-workspace'' (each workspace is given its own individual PVC). For details, see https://github.com/eclipse/che/issues/21185.'
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume), `per-workspace` (each workspace is given its own individual PVC) and `ephemeral` (non-persistent storage where local changes will be lost when the workspace is stopped.)'
enum:
- common
- per-user
- per-workspace
- ephemeral
type: string
type: object
tolerations:

View File

@ -4627,11 +4627,12 @@ spec:
type: object
pvcStrategy:
default: per-user
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume) and ''per-workspace'' (each workspace is given its own individual PVC). For details, see https://github.com/eclipse/che/issues/21185.'
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume), `per-workspace` (each workspace is given its own individual PVC) and `ephemeral` (non-persistent storage where local changes will be lost when the workspace is stopped.)'
enum:
- common
- per-user
- per-workspace
- ephemeral
type: string
type: object
tolerations:

View File

@ -4627,11 +4627,12 @@ spec:
type: object
pvcStrategy:
default: per-user
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume) and ''per-workspace'' (each workspace is given its own individual PVC). For details, see https://github.com/eclipse/che/issues/21185.'
description: 'Persistent volume claim strategy for the Che server. The supported strategies are: `per-user` (all workspaces PVCs in one volume), `per-workspace` (each workspace is given its own individual PVC) and `ephemeral` (non-persistent storage where local changes will be lost when the workspace is stopped.)'
enum:
- common
- per-user
- per-workspace
- ephemeral
type: string
type: object
tolerations:

View File

@ -99,6 +99,7 @@ const (
PerUserPVCStorageStrategy = "per-user"
DefaultPvcStorageStrategy = "per-user"
PerWorkspacePVCStorageStrategy = "per-workspace"
EphemeralPVCStorageStrategy = "ephemeral"
CommonPVCStorageStrategy = "common"
DefaultAutoProvision = true
DefaultWorkspaceJavaOpts = "-XX:MaxRAM=150m -XX:MaxRAMFraction=2 -XX:+UseParallelGC " +

View File

@ -90,10 +90,11 @@ func updateWorkspaceConfig(devEnvironments *chev2.CheClusterDevEnvironments, ope
func updateWorkspaceStorageConfig(devEnvironments *chev2.CheClusterDevEnvironments, workspaceConfig *controllerv1alpha1.WorkspaceConfig) error {
pvcStrategy := utils.GetValue(devEnvironments.Storage.PvcStrategy, constants.DefaultPvcStorageStrategy)
isPerWorkspacePVCStorageStrategy := pvcStrategy == constants.PerWorkspacePVCStorageStrategy
pvc := map[bool]*chev2.PVC{
true: devEnvironments.Storage.PerWorkspaceStrategyPvcConfig,
false: devEnvironments.Storage.PerUserStrategyPvcConfig,
}[isPerWorkspacePVCStorageStrategy]
pvc := map[string]*chev2.PVC{
constants.PerUserPVCStorageStrategy: devEnvironments.Storage.PerUserStrategyPvcConfig,
constants.CommonPVCStorageStrategy: devEnvironments.Storage.PerUserStrategyPvcConfig,
constants.PerWorkspacePVCStorageStrategy: devEnvironments.Storage.PerWorkspaceStrategyPvcConfig,
}[pvcStrategy]
if pvc != nil {
if pvc.StorageClass != "" {

View File

@ -90,6 +90,31 @@ func TestReconcileDevWorkspaceConfigPerUserStorage(t *testing.T) {
},
expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{Workspace: &controllerv1alpha1.WorkspaceConfig{}},
},
{
name: "Create DevWorkspaceOperatorConfig with ephemeral strategy",
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Name: "eclipse-che",
},
Spec: chev2.CheClusterSpec{
DevEnvironments: chev2.CheClusterDevEnvironments{
Storage: chev2.WorkspaceStorage{
PvcStrategy: constants.EphemeralPVCStorageStrategy,
PerUserStrategyPvcConfig: &chev2.PVC{
StorageClass: "test-storage",
ClaimSize: "10Gi",
},
PerWorkspaceStrategyPvcConfig: &chev2.PVC{
StorageClass: "test-storage",
ClaimSize: "10Gi",
},
},
},
},
},
expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{Workspace: &controllerv1alpha1.WorkspaceConfig{}},
},
{
name: "Create DevWorkspaceOperatorConfig with StorageClassName only",
cheCluster: &chev2.CheCluster{