@@ -17,23 +17,18 @@ limitations under the License.
1717package v1alpha1
1818
1919import (
20- "k8s.io/apimachinery/pkg/ api/resource "
20+ corev1 "k8s.io/api/core/v1 "
2121 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222)
2323
24- type Storage struct {
25- StorageClass string `json:"storageClass"`
26- Size resource.Quantity `json:"size"`
27- }
28-
2924// EtcdClusterSpec defines the desired state of EtcdCluster
3025type EtcdClusterSpec struct {
3126 // Replicas is the count of etcd instances in cluster.
3227 // +optional
3328 // +kubebuilder:default:=3
3429 // +kubebuilder:validation:Minimum:=0
35- Replicas * int32 `json:"replicas,omitempty"`
36- Storage Storage `json:"storage,omitempty "`
30+ Replicas * int32 `json:"replicas,omitempty"`
31+ Storage StorageSpec `json:"storage"`
3732}
3833
3934const (
@@ -76,6 +71,67 @@ type EtcdClusterList struct {
7671 Items []EtcdCluster `json:"items"`
7772}
7873
74+ // EmbeddedObjectMetadata contains a subset of the fields included in k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
75+ // Only fields which are relevant to embedded resources are included.
76+ type EmbeddedObjectMetadata struct {
77+ // Name must be unique within a namespace. Is required when creating resources, although
78+ // some resources may allow a client to request the generation of an appropriate name
79+ // automatically. Name is primarily intended for creation idempotence and configuration
80+ // definition.
81+ // Cannot be updated.
82+ // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names
83+ // +optional
84+ Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
85+
86+ // Labels Map of string keys and values that can be used to organize and categorize
87+ // (scope and select) objects. May match selectors of replication controllers
88+ // and services.
89+ // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
90+ // +optional
91+ Labels map [string ]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"`
92+
93+ // Annotations is an unstructured key value map stored with a resource that may be
94+ // set by external tools to store and retrieve arbitrary metadata. They are not
95+ // queryable and should be preserved when modifying objects.
96+ // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
97+ // +optional
98+ Annotations map [string ]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"`
99+ }
100+
101+ // StorageSpec defines the configured storage for a etcd members.
102+ // If neither `emptyDir` nor `volumeClaimTemplate` is specified, then by default an [EmptyDir](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) will be used.
103+ // +k8s:openapi-gen=true
104+ type StorageSpec struct {
105+ // EmptyDirVolumeSource to be used by the StatefulSets. If specified, used in place of any volumeClaimTemplate. More
106+ // info: https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
107+ // +optional
108+ EmptyDir * corev1.EmptyDirVolumeSource `json:"emptyDir,omitempty"`
109+ // A PVC spec to be used by the StatefulSets.
110+ // +optional
111+ VolumeClaimTemplate EmbeddedPersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
112+ }
113+
114+ // EmbeddedPersistentVolumeClaim is an embedded version of k8s.io/api/core/v1.PersistentVolumeClaim.
115+ // It contains TypeMeta and a reduced ObjectMeta.
116+ type EmbeddedPersistentVolumeClaim struct {
117+ metav1.TypeMeta `json:",inline"`
118+
119+ // EmbeddedMetadata contains metadata relevant to an EmbeddedResource.
120+ // +optional
121+ EmbeddedObjectMetadata `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
122+
123+ // Spec defines the desired characteristics of a volume requested by a pod author.
124+ // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
125+ // +optional
126+ Spec corev1.PersistentVolumeClaimSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
127+
128+ // Status represents the current information/status of a persistent volume claim.
129+ // Read-only.
130+ // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
131+ // +optional
132+ Status corev1.PersistentVolumeClaimStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
133+ }
134+
79135func init () {
80136 SchemeBuilder .Register (& EtcdCluster {}, & EtcdClusterList {})
81137}
0 commit comments