Skip to content

Commit

Permalink
api: scaffolding for volumegroupreplicationcontent
Browse files Browse the repository at this point in the history
adding scaffolding for volumegroupreplicationcontent
using below commands

```
cp cmd/manager/main.go .
kubebuilder create api --group replication.storage \
--version v1alpha1 --kind VolumeGroupReplicationContent \
--namespaced=false
mv main.go cmd/manager/
make generate
make manifests
```

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Jun 14, 2024
1 parent 01826f1 commit 450a98a
Show file tree
Hide file tree
Showing 14 changed files with 761 additions and 0 deletions.
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@ resources:
kind: VolumeGroupReplication
path: github.com/csi-addons/kubernetes-csi-addons/apis/replication.storage/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: openshift.io
group: replication.storage
kind: VolumeGroupReplicationContent
path: github.com/csi-addons/kubernetes-csi-addons/apis/replication.storage/v1alpha1
version: v1alpha1
version: "3"
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
Copyright 2024 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 v1alpha1

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

// VolumeGroupReplicationContentSpec defines the desired state of VolumeGroupReplicationContent
type VolumeGroupReplicationContentSpec struct {
// VolumeGroupreplicationRef specifies the VolumeGroupReplication object to which this
// VolumeGroupReplicationContent object is bound.
// VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to
// this VolumeGroupReplicationContent's name for the bidirectional binding to be valid.
// For a pre-existing VolumeGroupReplicationContent object, name and namespace of the
// VolumeGroupReplication object MUST be provided for binding to happen.
// This field is immutable after creation.
// Required.
// +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace must be set"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationRef is immutable"
VolumeGroupReplicationRef corev1.ObjectReference `json:"volumeGroupReplicationRef"`

// VolumeGroupReplicationHandle is a unique id returned by the CSI driver
// to identify the VolumeGroupReplication on the storage system.
VolumeGroupReplicationHandle string `json:"volumeGroupReplicationHandle"`

// provisioner is the name of the CSI driver used to create the physical
// volume group on
// the underlying storage system.
// This MUST be the same as the name returned by the CSI GetPluginName() call for
// that driver.
// Required.
Provisioner string `json:"provisioner"`

// VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from
// which this group replication was (or will be) created.
// +optional
VolumeGroupSnapshotClassName string `json:"volumeGroupReplicationClassName"`

// Source specifies whether the snapshot is (or should be) dynamically provisioned
// or already exists, and just requires a Kubernetes object representation.
// This field is immutable after creation.
// Required.
Source VolumeGroupReplicationContentSource `json:"source"`
}

// VolumeGroupSnapshotContentSource represents the CSI source of a group replication.
type VolumeGroupReplicationContentSource struct {
// VolumeHandles is a list of volume handles on the backend to be grouped
// and replicated.
VolumeHandles []string `json:"volumeHandles"`
}

// VolumeGroupReplicationContentStatus defines the status of VolumeGroupReplicationContent
type VolumeGroupReplicationContentStatus struct {
// PVVolumeList is the list of of PV for the group replication
// The maximum number of allowed PV in the group is 100.
// +optional
PVVolumeList []PVVolume `json:"pvVolumeList,omitempty"`
}

// PVVolumes represent PV name to be groped and replicated.
type PVVolume struct {
// PersistentVolumeRef is a reference to the persistent volume resource
PersistentVolumeRef corev1.LocalObjectReference `json:"persistentVolumeRef,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster

// VolumeGroupReplicationContent is the Schema for the volumegroupreplicationcontents API
type VolumeGroupReplicationContent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec VolumeGroupReplicationContentSpec `json:"spec,omitempty"`
Status VolumeGroupReplicationContentStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&VolumeGroupReplicationContent{}, &VolumeGroupReplicationContentList{})
}
132 changes: 132 additions & 0 deletions apis/replication.storage/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "VolumeGroupReplication")
os.Exit(1)
}
if err = (&replicationController.VolumeGroupReplicationContentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "VolumeGroupReplicationContent")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Loading

0 comments on commit 450a98a

Please sign in to comment.