Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0f51308
Merge branch 'resource-handler-metadata-label-utility' into etcd-cont…
rytswd Oct 11, 2025
c7a990e
Add etcd env variable handling
rytswd Oct 11, 2025
73d8814
Merge branch 'storage-utility' into etcd-controller
rytswd Oct 11, 2025
a7abcfd
Add necessary module dependencies
rytswd Oct 12, 2025
24228f4
Correct function scope
rytswd Oct 12, 2025
442c7c2
Add port setup for etcd
rytswd Oct 12, 2025
18ab0b5
Add StatefulSet definition
rytswd Oct 12, 2025
f116fff
Add service port handling
rytswd Oct 12, 2025
00d821c
Simplify port logic to use etcd obj
rytswd Oct 12, 2025
92b6e99
Add service handling
rytswd Oct 12, 2025
d372434
Add controller logic
rytswd Oct 12, 2025
a25d443
Merge branch 'storage-utility' into etcd-controller
rytswd Oct 12, 2025
a71e22a
Fix port and scheme panic based test
rytswd Oct 12, 2025
c0cdf64
Merge remote-tracking branch 'origin/main' into etcd-controller
rytswd Oct 12, 2025
046817c
Fix standard labels to match
rytswd Oct 13, 2025
3061950
Add fake client wrapper for failure test
rytswd Oct 13, 2025
1eccb32
Make all tests parallel
rytswd Oct 13, 2025
c8c3aac
Only add working tests with failure injection
rytswd Oct 13, 2025
c4aa5ee
Clean up object verification
rytswd Oct 13, 2025
d0fabd2
Merge branch 'etcd-api-and-crd' into etcd-controller
rytswd Oct 13, 2025
9d4bf83
Merge branch 'main' into etcd-controller
rytswd Oct 13, 2025
6fb1b6f
Merge branch 'fix-crds-and-makefile' into etcd-controller
rytswd Oct 13, 2025
4381ba0
Add requeue check
rytswd Oct 14, 2025
9355f3d
Add namespace + name key test utility
rytswd Oct 14, 2025
2fa5d16
Introduce concrete type after N call failure util
rytswd Oct 14, 2025
d856c22
Add more test cases for reconciliation
rytswd Oct 14, 2025
c11dc73
Add NotFound reconcile testing
rytswd Oct 14, 2025
7ab7fd0
Add storage testing
rytswd Oct 14, 2025
bdbd6b1
Add internal testing for defensive coverage
rytswd Oct 14, 2025
6e22f2b
Add TODO comment about missing test coverage
rytswd Oct 14, 2025
2526ff8
Merge branch 'fix-crds-and-makefile' into etcd-controller
rytswd Oct 14, 2025
a4b0f22
Remove unused file
rytswd Oct 14, 2025
0baa63a
Add extra assertion to check updated resource
rytswd Oct 14, 2025
066ece7
Add more assertion functions for success cases
rytswd Oct 14, 2025
3a083df
Ensure test cases have success assertion
rytswd Oct 14, 2025
5eecb76
Add some more test for safety
rytswd Oct 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 93 additions & 24 deletions api/v1alpha1/etcd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,106 @@ limitations under the License.
package v1alpha1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// NOTE: json tags are required. Any new fields you add must have json tags for
// the fields to be serialized.

// EtcdSpec defines the desired state of Etcd
// EtcdSpec defines the desired state of an Etcd cluster managed by the operator
type EtcdSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// The following markers will use OpenAPI v3 schema to validate the value
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
// CellName is the name of the cell this Etcd belongs to.
// +kubebuilder:validation:MinLength=1
// +optional
CellName string `json:"cellName,omitempty"`

// Image is the container image for Etcd.
// NOTE: The version information is taken from Multigres repo's local
// provisioning setup:
// https://github.com/multigres/multigres/blob/38264ed3cb5049961a1e3d8a9de4836f8215ca76/go/provisioner/local/config.go#L186
// +kubebuilder:validation:MinLength=1
// +kubebuilder:default="gcr.io/etcd-development/etcd:v3.5.9"
// +optional
Image string `json:"image,omitempty"`

// ImagePullSecrets is an optional list of references to secrets in the same namespace
// to use for pulling the image.
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// Replicas is the desired number of Etcd members.
// For high availability, use an odd number (typically 3 or 5).
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=3
// +optional
Replicas *int32 `json:"replicas,omitempty"`

// Resources defines the resource requirements for the Etcd container.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// ServiceAccountName is the name of the ServiceAccount to use for the Etcd pods.
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// StorageClassName is the name of the StorageClass to use for Etcd data volumes.
// If not specified, the default StorageClass will be used.
// +optional
StorageClassName *string `json:"storageClassName,omitempty"`

// StorageSize is the size of the persistent volume for each Etcd member.
// +kubebuilder:default="10Gi"
// +optional
StorageSize string `json:"storageSize,omitempty"`

// VolumeClaimTemplate allows customization of the PersistentVolumeClaim for Etcd data.
// If specified, this takes precedence over StorageClassName and StorageSize.
// +optional
VolumeClaimTemplate *corev1.PersistentVolumeClaimSpec `json:"volumeClaimTemplate,omitempty"`

// Affinity defines pod affinity and anti-affinity rules.
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`

// Tolerations allows pods to schedule onto nodes with matching taints.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// NodeSelector is a selector which must be true for the pod to fit on a node.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// foo is an example field of Etcd. Edit etcd_types.go to remove/update
// TopologySpreadConstraints controls how pods are spread across topology domains.
// +optional
Foo *string `json:"foo,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`

// PodAnnotations are annotations to add to the Etcd pods.
// +optional
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`

// PodLabels are additional labels to add to the Etcd pods.
// These are merged with the standard labels generated by the operator.
// In case of a key conflict, the operator's standard labels take precedence.
// +optional
PodLabels map[string]string `json:"podLabels,omitempty"`
}

// EtcdStatus defines the observed state of Etcd.
type EtcdStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// For Kubernetes API conventions, see:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties

// conditions represent the current state of the Etcd resource.
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
//
// Standard condition types include:
// - "Available": the resource is fully functional
// - "Progressing": the resource is being created or updated
// - "Degraded": the resource failed to reach or maintain its desired state
//
// The status of each condition is one of True, False, or Unknown.
// Ready indicates whether the Etcd cluster is healthy and available.
Ready bool `json:"ready"`

// Replicas is the desired number of Etcd members.
Replicas int32 `json:"replicas"`

// ReadyReplicas is the number of ready Etcd members.
ReadyReplicas int32 `json:"readyReplicas"`

// ObservedGeneration reflects the generation of the most recently observed Etcd spec.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// Conditions represent the latest available observations of the Etcd cluster's state.
// +listType=map
// +listMapKey=type
// +optional
Expand All @@ -60,6 +125,10 @@ type EtcdStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
// +kubebuilder:printcolumn:name="DesiredReplicas",type=string,JSONPath=`.status.replicas`
// +kubebuilder:printcolumn:name="ReadyReplicas",type=string,JSONPath=`.status.readyReplicas`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

// Etcd is the Schema for the etcds API
type Etcd struct {
Expand Down
Loading
Loading