Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit cee3406

Browse files
committed
Add v1beta1 CRD version for replication* types
This commit add v1beta1 CRD version for the replication objects and also update the CRD manifests. Addition to that, bundle version has been updated to v0.0.2 boilerplate header has been updated to reflect current year. Fix: #122 Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
1 parent caf40c2 commit cee3406

10 files changed

Lines changed: 672 additions & 37 deletions

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.0.1
6+
VERSION ?= 0.0.2
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview,fast,stable")
@@ -34,7 +34,7 @@ IMG_TAG ?= latest
3434
IMG=${IMG_NAME}:${IMG_TAG}
3535
image_arch_list=linux/amd64,linux/ppc64le,linux/s390x
3636
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
37-
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
37+
CRD_OPTIONS ?= ""
3838

3939
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
4040
ifeq (,$(shell go env GOBIN))
@@ -79,7 +79,7 @@ undeploy:
7979

8080
# Generate manifests e.g. CRD, RBAC etc.
8181
manifests: controller-gen
82-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
82+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./api/..." output:crd:dir=config/crd/bases
8383

8484
# Run go fmt against code
8585
fmt:
@@ -91,7 +91,7 @@ vet:
9191

9292
# Generate code
9393
generate: controller-gen
94-
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
94+
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="api/..."
9595

9696
# Build the docker image
9797
docker-build: test

api/v1alpha1/volumereplication_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type VolumeReplicationStatus struct {
9191
// +kubebuilder:printcolumn:JSONPath=".spec.replicationState",name=desiredState,type=string
9292
// +kubebuilder:printcolumn:JSONPath=".status.state",name=currentState,type=string
9393
// +kubebuilder:resource:shortName=vr
94+
// +kubebuilder:storageversion
9495

9596
// VolumeReplication is the Schema for the volumereplications API.
9697
type VolumeReplication struct {

api/v1alpha1/volumereplicationclass_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type VolumeReplicationClassStatus struct{}
4040
// +kubebuilder:subresource:status
4141
// +kubebuilder:resource:scope=Cluster,shortName=vrc
4242
// +kubebuilder:printcolumn:JSONPath=".spec.provisioner",name=provisioner,type=string
43+
// +kubebuilder:storageversion
4344

4445
// VolumeReplicationClass is the Schema for the volumereplicationclasses API.
4546
type VolumeReplicationClass struct {

api/v1beta1/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2022.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1beta1 contains API Schema definitions for the replication v1beta1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=replication.storage.openshift.io
20+
package v1beta1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "replication.storage.openshift.io", Version: "v1beta1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
Copyright 2022.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// ReplicationState represents the replication operations to be performed on the volume.
25+
// +kubebuilder:validation:Enum=primary;secondary;resync
26+
type ReplicationState string
27+
28+
const (
29+
// Primary ReplicationState enables mirroring and promotes the volume to primary.
30+
Primary ReplicationState = "primary"
31+
32+
// Secondary ReplicationState demotes the volume to secondary and resyncs the volume if out of sync.
33+
Secondary ReplicationState = "secondary"
34+
35+
// Resync option resyncs the volume.
36+
Resync ReplicationState = "resync"
37+
)
38+
39+
// State captures the latest state of the replication operation.
40+
type State string
41+
42+
const (
43+
// PrimaryState represents the Primary replication state.
44+
PrimaryState State = "Primary"
45+
46+
// SecondaryState represents the Secondary replication state.
47+
SecondaryState State = "Secondary"
48+
49+
// UnknownState represents the Unknown replication state.
50+
UnknownState State = "Unknown"
51+
)
52+
53+
// VolumeReplicationSpec defines the desired state of VolumeReplication.
54+
type VolumeReplicationSpec struct {
55+
// VolumeReplicationClass is the VolumeReplicationClass name for this VolumeReplication resource
56+
// +kubebuilder:validation:Required
57+
VolumeReplicationClass string `json:"volumeReplicationClass"`
58+
59+
// ReplicationState represents the replication operation to be performed on the volume.
60+
// Supported operations are "primary", "secondary" and "resync"
61+
// +kubebuilder:validation:Required
62+
ReplicationState ReplicationState `json:"replicationState"`
63+
64+
// DataSource represents the object associated with the volume
65+
// +kubebuilder:validation:Required
66+
DataSource corev1.TypedLocalObjectReference `json:"dataSource"`
67+
68+
// replicationHandle represents an existing (but new) replication id
69+
// +kubebuilder:validation:Optional
70+
ReplicationHandle string `json:"replicationHandle"`
71+
}
72+
73+
// VolumeReplicationStatus defines the observed state of VolumeReplication.
74+
type VolumeReplicationStatus struct {
75+
State State `json:"state,omitempty"`
76+
Message string `json:"message,omitempty"`
77+
// Conditions are the list of conditions and their status.
78+
Conditions []metav1.Condition `json:"conditions,omitempty"`
79+
// observedGeneration is the last generation change the operator has dealt with
80+
// +optional
81+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
82+
LastStartTime *metav1.Time `json:"lastStartTime,omitempty"`
83+
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"`
84+
}
85+
86+
// +kubebuilder:object:root=true
87+
// +kubebuilder:subresource:status
88+
// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date
89+
// +kubebuilder:printcolumn:JSONPath=".spec.volumeReplicationClass",name=volumeReplicationClass,type=string
90+
// +kubebuilder:printcolumn:JSONPath=".spec.dataSource.name",name=pvcName,type=string
91+
// +kubebuilder:printcolumn:JSONPath=".spec.replicationState",name=desiredState,type=string
92+
// +kubebuilder:printcolumn:JSONPath=".status.state",name=currentState,type=string
93+
// +kubebuilder:resource:shortName=vr
94+
95+
// VolumeReplication is the Schema for the volumereplications API.
96+
type VolumeReplication struct {
97+
metav1.TypeMeta `json:",inline"`
98+
metav1.ObjectMeta `json:"metadata,omitempty"`
99+
100+
Spec VolumeReplicationSpec `json:"spec,omitempty"`
101+
Status VolumeReplicationStatus `json:"status,omitempty"`
102+
}
103+
104+
// +kubebuilder:object:root=true
105+
106+
// VolumeReplicationList contains a list of VolumeReplication.
107+
type VolumeReplicationList struct {
108+
metav1.TypeMeta `json:",inline"`
109+
metav1.ListMeta `json:"metadata,omitempty"`
110+
Items []VolumeReplication `json:"items"`
111+
}
112+
113+
func init() {
114+
SchemeBuilder.Register(&VolumeReplication{}, &VolumeReplicationList{})
115+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2022.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// VolumeReplicationClassSpec specifies parameters that an underlying storage system uses
24+
// when creating a volume replica. A specific VolumeReplicationClass is used by specifying
25+
// its name in a VolumeReplication object.
26+
type VolumeReplicationClassSpec struct {
27+
// Provisioner is the name of storage provisioner
28+
// +kubebuilder:validation:Required
29+
Provisioner string `json:"provisioner"`
30+
// Parameters is a key-value map with storage provisioner specific configurations for
31+
// creating volume replicas
32+
// +kubebuilder:validation:Optional
33+
Parameters map[string]string `json:"parameters,omitempty"`
34+
}
35+
36+
// VolumeReplicationClassStatus defines the observed state of VolumeReplicationClass.
37+
type VolumeReplicationClassStatus struct{}
38+
39+
// +kubebuilder:object:root=true
40+
// +kubebuilder:subresource:status
41+
// +kubebuilder:resource:scope=Cluster,shortName=vrc
42+
// +kubebuilder:printcolumn:JSONPath=".spec.provisioner",name=provisioner,type=string
43+
44+
// VolumeReplicationClass is the Schema for the volumereplicationclasses API.
45+
type VolumeReplicationClass struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ObjectMeta `json:"metadata,omitempty"`
48+
49+
Spec VolumeReplicationClassSpec `json:"spec,omitempty"`
50+
Status VolumeReplicationClassStatus `json:"status,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
55+
// VolumeReplicationClassList contains a list of VolumeReplicationClass.
56+
type VolumeReplicationClassList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ListMeta `json:"metadata,omitempty"`
59+
Items []VolumeReplicationClass `json:"items"`
60+
}
61+
62+
func init() {
63+
SchemeBuilder.Register(&VolumeReplicationClass{}, &VolumeReplicationClassList{})
64+
}

0 commit comments

Comments
 (0)