Skip to content

Commit

Permalink
Feat/implement service spec (#124)
Browse files Browse the repository at this point in the history
Fixes #115 
Fixes #166
  • Loading branch information
sergeyshevch committed Apr 23, 2024
1 parent e21a680 commit 7f761b6
Show file tree
Hide file tree
Showing 15 changed files with 1,129 additions and 83 deletions.
30 changes: 30 additions & 0 deletions api/v1alpha1/etcdcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ type EtcdClusterSpec struct {
Options map[string]string `json:"options,omitempty"`
// PodTemplate defines the desired state of PodSpec for etcd members. If not specified, default values will be used.
PodTemplate PodTemplate `json:"podTemplate,omitempty"`
// Service defines the desired state of Service for etcd members. If not specified, default values will be used.
// +optional
ServiceTemplate *EmbeddedService `json:"serviceTemplate,omitempty"`
// HeadlessService defines the desired state of HeadlessService for etcd members. If not specified, default values will be used.
// +optional
HeadlessServiceTemplate *EmbeddedMetadataResource `json:"headlessServiceTemplate,omitempty"`
// PodDisruptionBudgetTemplate describes PDB resource to create for etcd cluster members. Nil to disable.
// +optional
PodDisruptionBudgetTemplate *EmbeddedPodDisruptionBudget `json:"podDisruptionBudgetTemplate,omitempty"`
Expand Down Expand Up @@ -128,6 +134,15 @@ type EmbeddedObjectMetadata struct {
Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"`
}

// ToObjectMeta converts EmbeddedObjectMetadata to metav1.ObjectMeta
func (r *EmbeddedObjectMetadata) ToObjectMeta() metav1.ObjectMeta {
return metav1.ObjectMeta{
Name: r.Name,
Labels: r.Labels,
Annotations: r.Annotations,
}
}

// PodTemplate allows overrides, such as sidecars, init containers, changes to the security context, etc to the pod template generated by the operator.
type PodTemplate struct {
// EmbeddedObjectMetadata contains metadata relevant to an EmbeddedResource
Expand Down Expand Up @@ -226,6 +241,21 @@ type PodDisruptionBudgetSpec struct {
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
}

type EmbeddedService struct {
// EmbeddedMetadata contains metadata relevant to an EmbeddedResource.
// +optional
EmbeddedObjectMetadata `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Spec defines the behavior of the service.
// +optional
Spec corev1.ServiceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
}

type EmbeddedMetadataResource struct {
// EmbeddedMetadata contains metadata relevant to an EmbeddedResource.
// +optional
EmbeddedObjectMetadata `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
}

func init() {
SchemeBuilder.Register(&EtcdCluster{}, &EtcdClusterList{})
}
43 changes: 43 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 7f761b6

Please sign in to comment.