diff --git a/Dockerfile.valkey b/Dockerfile.valkey index ddcc741..f18317b 100644 --- a/Dockerfile.valkey +++ b/Dockerfile.valkey @@ -8,10 +8,10 @@ RUN apk add --no-cache --virtual .build-deps \ git=2.47.2-r0 \ coreutils=9.5-r2 \ linux-headers=6.6-r1 \ - musl-dev=1.2.5-r8 \ + musl-dev=1.2.5-r9 \ openssl-dev=3.3.3-r0 \ gcc=14.2.0-r4 \ - curl=8.11.1-r1 \ + curl=8.12.1-r0 \ make=4.4.1-r2 \ && curl -L https://github.com/valkey-io/valkey/archive/refs/tags/${VALKEY_VERSION}.tar.gz -o valkey.tar.gz \ && tar -xzf valkey.tar.gz --strip-components=1 \ diff --git a/api/v1/valkey_types.go b/api/v1/valkey_types.go index 5d9a129..6492bda 100644 --- a/api/v1/valkey_types.go +++ b/api/v1/valkey_types.go @@ -85,6 +85,14 @@ type ValkeySpec struct { // Tolerations Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + + // Node Selector + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + + // Which endpoint is shown as the preferred endpoint valid values are 'ip', 'hostname', or 'unknown-endpoint'. + // +kubebuilder:default:="ip" + // +kubebuilder:validation:Enum=ip;hostname;unknown-endpoint + ClusterPreferredEndpointType string `json:"clusterPreferredEndpointType,omitempty"` } // ExternalAccess defines the external access configuration diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 220c062..6a7679f 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -201,6 +201,13 @@ func (in *ValkeySpec) DeepCopyInto(out *ValkeySpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValkeySpec. diff --git a/config/crd/bases/hyperspike.io_valkeys.yaml b/config/crd/bases/hyperspike.io_valkeys.yaml index ed1a306..f70e354 100644 --- a/config/crd/bases/hyperspike.io_valkeys.yaml +++ b/config/crd/bases/hyperspike.io_valkeys.yaml @@ -80,6 +80,15 @@ spec: default: cluster.local description: Cluster Domain - used for DNS type: string + clusterPreferredEndpointType: + default: ip + description: Which endpoint is shown as the preferred endpoint valid + values are 'ip', 'hostname', or 'unknown-endpoint'. + enum: + - ip + - hostname + - unknown-endpoint + type: string exporterImage: description: Exporter Image to use type: string @@ -211,6 +220,11 @@ spec: image: description: Image to use type: string + nodeSelector: + additionalProperties: + type: string + description: Node Selector + type: object nodes: default: 3 description: Number of shards diff --git a/go.mod b/go.mod index a33b879..51a5a04 100644 --- a/go.mod +++ b/go.mod @@ -14,9 +14,9 @@ require ( github.com/spf13/cobra v1.8.1 github.com/valkey-io/valkey-go v1.0.54 go.uber.org/zap v1.27.0 - k8s.io/api v0.32.1 + k8s.io/api v0.32.2 k8s.io/apimachinery v0.32.2 - k8s.io/client-go v0.32.1 + k8s.io/client-go v0.32.2 sigs.k8s.io/controller-runtime v0.20.1 ) diff --git a/go.sum b/go.sum index 2eb600b..113782a 100644 --- a/go.sum +++ b/go.sum @@ -184,14 +184,14 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc= -k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k= +k8s.io/api v0.32.2 h1:bZrMLEkgizC24G9eViHGOPbW+aRo9duEISRIJKfdJuw= +k8s.io/api v0.32.2/go.mod h1:hKlhk4x1sJyYnHENsrdCWw31FEmCijNGPJO5WzHiJ6Y= k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw= k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto= k8s.io/apimachinery v0.32.2 h1:yoQBR9ZGkA6Rgmhbp/yuT9/g+4lxtsGYwW6dR6BDPLQ= k8s.io/apimachinery v0.32.2/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= -k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU= -k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg= +k8s.io/client-go v0.32.2 h1:4dYCD4Nz+9RApM2b/3BtVvBHw54QjMFUl1OLcJG5yOA= +k8s.io/client-go v0.32.2/go.mod h1:fpZ4oJXclZ3r2nDOv+Ux3XcJutfrwjKTCHz2H3sww94= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= diff --git a/internal/controller/scripts/valkey.conf b/internal/controller/scripts/valkey.conf index 48787c7..1abbf32 100644 --- a/internal/controller/scripts/valkey.conf +++ b/internal/controller/scripts/valkey.conf @@ -1746,7 +1746,7 @@ cluster-config-file /data/nodes.conf # the client to reach out on the same endpoint it used for making the last request, but use # the port provided in the response. -cluster-preferred-endpoint-type hostname +cluster-preferred-endpoint-type {{ .Spec.ClusterPreferredEndpointType }} ########################## CLUSTER DOCKER/NAT support ######################## diff --git a/internal/controller/valkey_controller.go b/internal/controller/valkey_controller.go index cd8f2fa..f3f5b28 100644 --- a/internal/controller/valkey_controller.go +++ b/internal/controller/valkey_controller.go @@ -2102,7 +2102,8 @@ func (r *ValkeyReconciler) upsertStatefulSet(ctx context.Context, valkey *hyperv }, }, }, - Tolerations: valkey.Spec.Tolerations, + Tolerations: valkey.Spec.Tolerations, + NodeSelector: valkey.Spec.NodeSelector, Containers: []corev1.Container{ { Image: image,