Skip to content

feat: adding support for dynamic rackid assignment after pod schedule [KO-385] #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
26 changes: 24 additions & 2 deletions api/v1/aerospikecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,11 @@ type RackConfig struct { //nolint:govet // for readability
// This makes sure that later on, all pods are properly counted when evaluating the cluster stability.
// +optional
MaxIgnorablePods *intstr.IntOrString `json:"maxIgnorablePods,omitempty"`

// RackIDSource specifies the source from which to read the rack ID.
// If not specified, the rack ID is read from the CR.
// +optional
RackIDSource *RackIDSource `json:"rackIDSource,omitempty"`
}

// Rack specifies single rack config
Expand Down Expand Up @@ -698,11 +703,11 @@ type AttachmentOptions struct {
MountOptions `json:"mountOptions,omitempty"`
}

type MountOptions struct { //nolint:govet // for readability
type MountOptions struct {
// Mounted read-only if true, read-write otherwise (false or unspecified).
// Defaults to false.
// +optional
ReadOnly bool `json:"readOnly,omitempty"`
ReadOnly *bool `json:"readOnly,omitempty"`

// Path within the volume from which the container's volume should be mounted.
// Defaults to "" (volume's root).
Expand Down Expand Up @@ -766,6 +771,12 @@ type VolumeSource struct {

// +optional
PersistentVolume *PersistentVolumeSpec `json:"persistentVolume,omitempty"`

// HostPath represents a directory on the host provisioned by an administrator.
// This is useful for exposing host paths to pods in a controlled, read-only manner.
// More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath
// +optional
HostPath *corev1.HostPathVolumeSource `json:"hostPath,omitempty"`
}

type VolumeSpec struct {
Expand Down Expand Up @@ -1100,6 +1111,13 @@ type AerospikeNetworkPolicy struct {
CustomTLSFabricNetworkNames []string `json:"customTLSFabricNetworkNames,omitempty"`
}

// RackIDSource specifies the source from which to read the rack ID.
type RackIDSource struct {
// FilePath specifies an absolute path to a file containing the rack ID mounted in the aerospike server container.
// The file should contain a single integer value.
FilePath string `json:"filePath"`
}

// AerospikeInstanceSummary defines the observed state of a pod's Aerospike Server Instance.
// +k8s:openapi-gen=true
type AerospikeInstanceSummary struct { //nolint:govet // for readability
Expand Down Expand Up @@ -1191,6 +1209,10 @@ type AerospikePodStatus struct { //nolint:govet // for readability
// Empty "" status means successful update.
// +optional
DynamicConfigUpdateStatus DynamicConfigUpdateStatus `json:"dynamicConfigUpdateStatus,omitempty"`

// RackIDSourceHash is ripemd160 hash of RackIDSource used by this pod
// +optional
RackIDSourceHash string `json:"rackIDSourceHash"`
}

// +kubebuilder:object:root=true
Expand Down
6 changes: 3 additions & 3 deletions api/v1/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ const (
AerospikeInitContainerRegistryNamespaceEnvVar = "AEROSPIKE_KUBERNETES_INIT_REGISTRY_NAMESPACE"
AerospikeInitContainerNameTagEnvVar = "AEROSPIKE_KUBERNETES_INIT_NAME_TAG"
AerospikeInitContainerDefaultRegistry = "docker.io"
AerospikeInitContainerDefaultRegistryNamespace = "aerospike"
AerospikeInitContainerDefaultNameAndTag = "aerospike-kubernetes-init:2.3.0-dev2"
AerospikeInitContainerDefaultRegistryNamespace = "tanmay10"
AerospikeInitContainerDefaultNameAndTag = "aerospike-kubernetes-init:2.3.0-dev3"
AerospikeAppLabel = "app"
AerospikeAppLabelValue = "aerospike-cluster"
AerospikeCustomResourceLabel = "aerospike.com/cr"
Expand Down Expand Up @@ -633,7 +633,7 @@ func GetVolumeForAerospikePath(storage *AerospikeStorageSpec, path string) *Volu
return matchedVolume
}

// IsPathParentOrSame indicates if dir1 is a parent or same as dir2.
// IsPathParentOrSame indicates if dir1 is a parent or the same as dir2.
func IsPathParentOrSame(dir1, dir2 string) bool {
if relPath, err := filepath.Rel(dir1, dir2); err == nil {
// If dir1 is not a parent directory then relative path will have to climb up directory hierarchy of dir1.
Expand Down
30 changes: 30 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

Loading
Loading