Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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