Skip to content

Commit

Permalink
Merge pull request #120 from hyperspike/external
Browse files Browse the repository at this point in the history
feat(controller): Support External Cluster Access
  • Loading branch information
dmolik authored Nov 25, 2024
2 parents 0a58dd7 + e2799b7 commit 86d08c7
Show file tree
Hide file tree
Showing 8 changed files with 748 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.31.1

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -28,8 +27,9 @@ CONTAINER_TOOL ?= docker
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

K8S_VERSION ?= 1.31.2
CILIUM_VERSION ?= 1.16.3
K8S_VERSION ?= 1.31.3
ENVTEST_K8S_VERSION = $(K8S_VERSION)
CILIUM_VERSION ?= 1.16.4

V ?= 0
ifeq ($(V), 1)
Expand Down
56 changes: 54 additions & 2 deletions api/v1/valkey_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type ValkeySpec struct {
// Exporter Image to use
ExporterImage string `json:"exporterImage,omitempty"`

// Number of nodes
// Number of shards
// +kubebuilder:default:=3
Nodes int32 `json:"nodes,omitempty"`
Shards int32 `json:"nodes,omitempty"`

// Number of replicas
// +kubebuilder:default:=0
Expand Down Expand Up @@ -72,6 +72,58 @@ type ValkeySpec struct {

// Resources requirements and limits for the Valkey Server container
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`

// External access configuration
ExternalAccess *ExternalAccess `json:"externalAccess,omitempty"`
}

// ExternalAccess defines the external access configuration
type ExternalAccess struct {
// Enable external access
// +kubebuilder:default:=false
Enabled bool `json:"enabled,omitempty"`

// External access type
// LoadBalancer or Proxy, the LoadBalancer type will create a LoadBalancer service for each Valkey Shard (master node)
// The Proxy type will create a single LoadBalancer service and use an envoy proxy to route traffic to the Valkey Shards
// +kubebuilder:default:=Proxy
// +kubebuilder:validation:Enum=LoadBalancer;Proxy
Type string `json:"type,omitempty"`

// Proxy Settings
Proxy *ProxySettings `json:"proxy,omitempty"`

// LoadBalancer Settings
LoadBalancer *LoadBalancerSettings `json:"loadBalancer,omitempty"`

// Support External DNS
// +kubebuilder:default:=false
ExternalDNS bool `json:"externalDNS,omitempty"`
}

// ProxySettings defines the proxy settings
type ProxySettings struct {
// Image to use for the proxy
// +kubebuilder:default:="envoyproxy/envoy:v1.32.1"
Image string `json:"image,omitempty"`
// Resources requirements and limits for the proxy container
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`

// Extra Envoy configuration
ExtraConfig string `json:"extraConfig,omitempty"`

// Annotations for the proxy service
Annotations map[string]string `json:"annotations,omitempty"`

// Replicas for the proxy
// +kubebuilder:default:=1
Replicas *int32 `json:"replicas,omitempty"`
}

// LoadBalancerSettings defines the load balancer settings
type LoadBalancerSettings struct {
// Annotations for the load balancer service
Annotations map[string]string `json:"annotations,omitempty"`
}

// ValkeyStatus defines the observed state of Valkey
Expand Down
84 changes: 84 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.

114 changes: 113 additions & 1 deletion config/crd/bases/hyperspike.io_valkeys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,124 @@ spec:
exporterImage:
description: Exporter Image to use
type: string
externalAccess:
description: External access configuration
properties:
enabled:
default: false
description: Enable external access
type: boolean
externalDNS:
default: false
description: Support External DNS
type: boolean
loadBalancer:
description: LoadBalancer Settings
properties:
annotations:
additionalProperties:
type: string
description: Annotations for the load balancer service
type: object
type: object
proxy:
description: Proxy Settings
properties:
annotations:
additionalProperties:
type: string
description: Annotations for the proxy service
type: object
extraConfig:
description: Extra Envoy configuration
type: string
image:
default: envoyproxy/envoy:v1.32.1
description: Image to use for the proxy
type: string
replicas:
default: 1
description: Replicas for the proxy
format: int32
type: integer
resources:
description: Resources requirements and limits for the proxy
container
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
request:
description: |-
Request is the name chosen for a request in the referenced claim.
If empty, everything from the claim is made available, otherwise
only the result of this request.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
otherwise to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
type: object
type:
default: Proxy
description: |-
External access type
LoadBalancer or Proxy, the LoadBalancer type will create a LoadBalancer service for each Valkey Shard (master node)
The Proxy type will create a single LoadBalancer service and use an envoy proxy to route traffic to the Valkey Shards
enum:
- LoadBalancer
- Proxy
type: string
type: object
image:
description: Image to use
type: string
nodes:
default: 3
description: Number of nodes
description: Number of shards
format: int32
type: integer
prometheus:
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: localhost:5000/controller
newTag: "1"
newTag: "24"
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
- command:
- /manager
args:
- --leader-elect
- --leader-elect=false
- --health-probe-bind-address=:8081
image: controller:latest
name: manager
Expand Down
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ rules:
- apiGroups:
- apps
resources:
- deployments
- statefulsets
verbs:
- create
Expand Down
Loading

0 comments on commit 86d08c7

Please sign in to comment.