Skip to content

Commit

Permalink
adding vg api
Browse files Browse the repository at this point in the history
Signed-off-by: matancarmeli7 <[email protected]>
  • Loading branch information
matancarmeli7 committed Jul 16, 2023
1 parent bed9c6e commit b808dde
Show file tree
Hide file tree
Showing 80 changed files with 15,455 additions and 97 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
CONTROLLER_IMG ?= quay.io/csiaddons/k8s-controller
SIDECAR_IMG ?= quay.io/csiaddons/k8s-sidecar
BUNDLE_IMG ?= quay.io/csiaddons/k8s-bundle
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"
TOOLS_IMG ?= quay.io/csiaddons/tools

# set TAG to a release for consumption in the bundle
Expand Down Expand Up @@ -119,7 +120,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen kustomize ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="{./apis/...,./cmd/...,./controllers/...,./sidecar/...}" output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role $(CRD_OPTIONS) webhook paths="{./apis/...,./cmd/...,./controllers/...,./sidecar/...}" output:crd:artifacts:config=config/crd/bases
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG} rbac-proxy=${RBAC_PROXY_IMG}
$(KUSTOMIZE) build config/crd > deploy/controller/crds.yaml
$(KUSTOMIZE) build config/rbac > deploy/controller/rbac.yaml
Expand Down
33 changes: 33 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,37 @@ resources:
webhooks:
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
domain: openshift.io
group: volumegroup.storage
kind: VolumeGroup
path: github.com/csi-addons/kubernetes-csi-addons/apis/volumegroup.storage/v1alpha1
version: v1alpha1
webhooks:
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
domain: openshift.io
group: volumegroup.storage
kind: VolumeGroupContent
path: github.com/csi-addons/kubernetes-csi-addons/apis/volumegroup.storage/v1alpha1
version: v1alpha1
webhooks:
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
domain: openshift.io
group: volumegroup.storage
kind: VolumeGroupClass
path: github.com/csi-addons/kubernetes-csi-addons/apis/volumegroup.storage/v1alpha1
version: v1alpha1
webhooks:
validation: true
webhookVersion: v1
version: "3"
44 changes: 44 additions & 0 deletions apis/volumegroup.storage/v1/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2023 The Kubernetes-CSI-Addons Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// VolumeGroupDeletionPolicy describes a policy for end-of-life maintenance of
// volume group contents
type VolumeGroupDeletionPolicy string

const (
// VolumeGroupContentDelete means the group will be deleted from the
// underlying storage system on release from its volume group.
VolumeGroupContentDelete VolumeGroupDeletionPolicy = "Delete"

// VolumeGroupContentRetain means the group will be left in its current
// state on release from its volume group.
VolumeGroupContentRetain VolumeGroupDeletionPolicy = "Retain"
)

// Describes an error encountered on the group
type VolumeGroupError struct {
// time is the timestamp when the error was encountered.
// +optional
Time *metav1.Time `json:"time,omitempty"`

// message details the encountered error
// +optional
Message *string `json:"message,omitempty"`
}
36 changes: 36 additions & 0 deletions apis/volumegroup.storage/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2023 The Kubernetes-CSI-Addons Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1 contains API Schema definitions for the csi v1 API group
// +kubebuilder:object:generate=true
// +groupName=volumegroup.storage.openshift.io
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "volumegroup.storage.openshift.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
101 changes: 101 additions & 0 deletions apis/volumegroup.storage/v1/volumegroup_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
Copyright 2023 The Kubernetes-CSI-Addons Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// VolumeGroupSpec describes the common attributes of group storage devices
// and allows a Source for provider-specific attributes
type VolumeGroupSpec struct {
// +optional
VolumeGroupClassName *string `json:"volumeGroupClassName,omitempty"`

// Source has the information about where the group is created from.
Source VolumeGroupSource `json:"source"`
}

// VolumeGroupSource contains several options.
// OneOf the options must be defined.
type VolumeGroupSource struct {
// +optional
// Pre-provisioned VolumeGroup
VolumeGroupContentName *string `json:"volumeGroupContentName,omitempty"`

// +optional
// Dynamically provisioned VolumeGroup
// A label query over persistent volume claims to be added to the volume group.
// This labelSelector will be used to match the label added to a PVC.
// In Phase 1, when the label is added to PVC, the PVC will be added to the matching group.
// In Phase 2, this labelSelector will be used to find all PVCs with matching label and add them to the group when the group is being created.
Selector *metav1.LabelSelector `json:"selector,omitempty"`
}

// VolumeGroupStatus defines the observed state of VolumeGroup
type VolumeGroupStatus struct {
// +optional
BoundVolumeGroupContentName *string `json:"boundVolumeGroupContentName,omitempty"`

// +optional
GroupCreationTime *metav1.Time `json:"groupCreationTime,omitempty"`

// A list of persistent volume claims
// +optional
PVCList []corev1.PersistentVolumeClaim `json:"pvcList,omitempty"`

// +optional
Ready *bool `json:"ready,omitempty"`

// Last error encountered during group creation
// +optional
Error *VolumeGroupError `json:"error,omitempty"`
}

// VolumeGroup is a user's request for a group of volumes
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Namespaced,shortName=vg
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
// +kubebuilder:printcolumn:name="VolumeGroupClass",type=string,JSONPath=`.spec.volumeGroupClassName`
// +kubebuilder:printcolumn:name="VolumeGroupContent",type=string,JSONPath=`.status.boundVolumeGroupContentName`
// +kubebuilder:printcolumn:name="CreationTime",type=date,JSONPath=`.status.groupCreationTime`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
type VolumeGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec defines the volume group requested by a user
Spec VolumeGroupSpec `json:"spec,omitempty"`
// Status represents the current information about a volume group
// +optional
Status VolumeGroupStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// VolumeGroupList contains a list of VolumeGroup
type VolumeGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VolumeGroup `json:"items"`
}

func init() {
SchemeBuilder.Register(&VolumeGroup{}, &VolumeGroupList{})
}
66 changes: 66 additions & 0 deletions apis/volumegroup.storage/v1/volumegroupclass_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2023 The Kubernetes-CSI-Addons Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// VolumeGroupClass is the Schema for the volumegroupclasses API
// +kubebuilder:resource:scope=Cluster,shortName=vgclass
// +kubebuilder:printcolumn:name="Driver",type=string,JSONPath=`.driver`
// +kubebuilder:printcolumn:name="DeletionPolicy",type=string,JSONPath=`.volumeGroupDeletionPolicy`
// +kubebuilder:printcolumn:name="SupportVolumeGroupSnapshot",type=boolean,JSONPath=`.supportVolumeGroupSnapshot`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
type VolumeGroupClass struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Driver is the driver expected to handle this VolumeGroupClass.
Driver string `json:"driver"`

// Parameters hold parameters for the driver.
// These values are opaque to the system and are passed directly
// to the driver.
// +optional
Parameters map[string]string `json:"parameters,omitempty"`

// +optional
// +kubebuilder:default:=Delete
VolumeGroupDeletionPolicy *VolumeGroupDeletionPolicy `json:"volumeGroupDeletionPolicy,omitempty"`

// This field specifies whether group snapshot is supported.
// +optional
// +kubebuilder:default:=false
SupportVolumeGroupSnapshot *bool `json:"supportVolumeGroupSnapshot,omitempty"`
}

//+kubebuilder:object:root=true

// VolumeGroupClassList contains a list of VolumeGroupClass
type VolumeGroupClassList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VolumeGroupClass `json:"items"`
}

func init() {
SchemeBuilder.Register(&VolumeGroupClass{}, &VolumeGroupClassList{})
}
Loading

0 comments on commit b808dde

Please sign in to comment.