Skip to content

Commit

Permalink
Make cacheSize maxConn configurable
Browse files Browse the repository at this point in the history
Jira: OSPRH-12339
  • Loading branch information
xek committed Jan 9, 2025
1 parent c302f3d commit bdc706a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
10 changes: 10 additions & 0 deletions apis/bases/memcached.openstack.org_memcacheds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ spec:
spec:
description: MemcachedSpec defines the desired state of Memcached
properties:
cacheSize:
default: 9932
description: Maximum Memcached cache size in MB
format: int32
type: integer
containerImage:
description: Name of the memcached container image to run (will be
set to environmental default if empty)
type: string
maxConn:
default: 9932
description: Maximum number of connections accepted by Memcached
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
Expand Down
10 changes: 10 additions & 0 deletions apis/memcached/v1beta1/memcached_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ type MemcachedSpecCore struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS settings for memcached service
TLS tls.SimpleService `json:"tls,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=9932
// Maximum Memcached cache size in MB
CacheSize int32 `json:"cacheSize"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=9932
// Maximum number of connections accepted by Memcached
MaxConn int32 `json:"maxConn"`
}

// MemcachedStatus defines the observed state of Memcached
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/memcached.openstack.org_memcacheds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ spec:
spec:
description: MemcachedSpec defines the desired state of Memcached
properties:
cacheSize:
default: 9932
description: Maximum Memcached cache size in MB
format: int32
type: integer
containerImage:
description: Name of the memcached container image to run (will be
set to environmental default if empty)
type: string
maxConn:
default: 9932
description: Maximum number of connections accepted by Memcached
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
Expand Down
1 change: 1 addition & 0 deletions config/samples/memcached_v1beta1_memcached.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ metadata:
name: memcached
spec:
replicas: 1
cacheSize: 1024
2 changes: 2 additions & 0 deletions controllers/memcached/memcached_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ func (r *Reconciler) generateConfigMaps(
"memcachedTLSListen": memcachedTLSListen,
"memcachedTLSOptions": memcachedTLSOptions,
"memcachedPort": memcachedPort,
"memcachedCacheSize": instance.Spec.CacheSize,
"memcachedMaxConn": instance.Spec.MaxConn,
}

cms := []util.Template{
Expand Down
4 changes: 2 additions & 2 deletions templates/memcached/config/memcached
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PORT="{{ .memcachedPort }}"
USER="memcached"
MAXCONN="8192"
CACHESIZE="9932"
MAXCONN="{{ .memcachedMaxConn }}"
CACHESIZE="{{ .memcachedCacheSize }}"
# explicit IP to bind to (wrap IPv6 in brackets)
LISTEN=$(echo 127.0.0.1 ::1 $POD_IPS | tr ',' ' ' | tr ' ' '\n' | sed 's/\(.*\):\(.*\)/[\1:\2]/' {{ .memcachedTLSListen }})
OPTIONS="-l $(echo $LISTEN | tr ' ' ',') {{ .memcachedTLSOptions }} -vv"

0 comments on commit bdc706a

Please sign in to comment.