From c3118722fd9928087ccdb44ef2cabd366d336fec Mon Sep 17 00:00:00 2001 From: Christian Schwede Date: Mon, 29 Jan 2024 15:58:21 +0100 Subject: [PATCH] Add support for memcached instance Removing the existing memcached container will be done in a follow up commit. --- .../swift.openstack.org_swiftproxies.yaml | 5 ++ api/bases/swift.openstack.org_swifts.yaml | 15 +++++ .../swift.openstack.org_swiftstorages.yaml | 5 ++ api/v1beta1/swift_types.go | 5 ++ api/v1beta1/swiftproxy_types.go | 8 +++ api/v1beta1/swiftstorage_types.go | 10 +++ .../swift.openstack.org_swiftproxies.yaml | 5 ++ .../crd/bases/swift.openstack.org_swifts.yaml | 15 +++++ .../swift.openstack.org_swiftstorages.yaml | 5 ++ config/rbac/role.yaml | 8 +++ controllers/swift_controller.go | 2 + controllers/swiftproxy_controller.go | 63 ++++++++++++++++++ controllers/swiftstorage_controller.go | 64 ++++++++++++++++++- go.mod | 1 + go.sum | 2 + main.go | 2 + pkg/swiftproxy/templates.go | 2 + pkg/swiftstorage/templates.go | 3 +- templates/swiftproxy/config/proxy-server.conf | 1 + .../swiftstorage/config/object-expirer.conf | 1 + 20 files changed, 220 insertions(+), 2 deletions(-) diff --git a/api/bases/swift.openstack.org_swiftproxies.yaml b/api/bases/swift.openstack.org_swiftproxies.yaml index 86c5cfd6..65c25bb7 100644 --- a/api/bases/swift.openstack.org_swiftproxies.yaml +++ b/api/bases/swift.openstack.org_swiftproxies.yaml @@ -54,6 +54,10 @@ spec: containerImageProxy: description: Swift Proxy Container Image URL type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -269,6 +273,7 @@ spec: required: - containerImageMemcached - containerImageProxy + - memcachedInstance - replicas - secret - serviceUser diff --git a/api/bases/swift.openstack.org_swifts.yaml b/api/bases/swift.openstack.org_swifts.yaml index 45235832..abc5b009 100644 --- a/api/bases/swift.openstack.org_swifts.yaml +++ b/api/bases/swift.openstack.org_swifts.yaml @@ -48,6 +48,10 @@ spec: spec: description: SwiftSpec defines the desired state of Swift properties: + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -73,6 +77,10 @@ spec: containerImageProxy: description: Swift Proxy Container Image URL type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -296,6 +304,7 @@ spec: required: - containerImageMemcached - containerImageProxy + - memcachedInstance - replicas - secret - serviceUser @@ -342,6 +351,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -371,12 +384,14 @@ spec: - containerImageMemcached - containerImageObject - containerImageProxy + - memcachedInstance - replicas - storageClass - storageRequest - swiftConfSecret type: object required: + - memcachedInstance - storageClass - swiftConfSecret - swiftProxy diff --git a/api/bases/swift.openstack.org_swiftstorages.yaml b/api/bases/swift.openstack.org_swiftstorages.yaml index 58841f0e..11f27f20 100644 --- a/api/bases/swift.openstack.org_swiftstorages.yaml +++ b/api/bases/swift.openstack.org_swiftstorages.yaml @@ -63,6 +63,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -92,6 +96,7 @@ spec: - containerImageMemcached - containerImageObject - containerImageProxy + - memcachedInstance - replicas - storageClass - storageRequest diff --git a/api/v1beta1/swift_types.go b/api/v1beta1/swift_types.go index 2b574d01..aec20d39 100644 --- a/api/v1beta1/swift_types.go +++ b/api/v1beta1/swift_types.go @@ -59,6 +59,11 @@ type SwiftSpec struct { // +kubebuilder:validation:Optional // NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network NetworkAttachments []string `json:"networkAttachments,omitempty"` + + // +kubebuilder:validation:Required + // +kubebuilder:default=memcached + // Memcached instance name. + MemcachedInstance string `json:"memcachedInstance"` } // SwiftStatus defines the observed state of Swift diff --git a/api/v1beta1/swiftproxy_types.go b/api/v1beta1/swiftproxy_types.go index 64ec4419..fc85b5d1 100644 --- a/api/v1beta1/swiftproxy_types.go +++ b/api/v1beta1/swiftproxy_types.go @@ -48,6 +48,9 @@ type SwiftProxySpec struct { // +kubebuilder:validation:Required // Image URL for Memcache servicd ContainerImageMemcached string `json:"containerImageMemcached"` + // +kubebuilder:default=memcached + // Memcached instance name. + MemcachedInstance string `json:"memcachedInstance"` // +kubebuilder:validation:Required // +kubebuilder:default=swift @@ -76,6 +79,11 @@ type SwiftProxySpec struct { // +kubebuilder:validation:Optional // NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network NetworkAttachments []string `json:"networkAttachments,omitempty"` + + // +kubebuilder:validation:Required + // +kubebuilder:default=memcached + // Memcached instance name. + MemcachedInstance string `json:"memcachedInstance"` } // ProxyOverrideSpec to override the generated manifest of several child resources. diff --git a/api/v1beta1/swiftstorage_types.go b/api/v1beta1/swiftstorage_types.go index 7756fe0d..3b43a75e 100644 --- a/api/v1beta1/swiftstorage_types.go +++ b/api/v1beta1/swiftstorage_types.go @@ -31,6 +31,11 @@ type SwiftStorageSpec struct { // +kubebuilder:validation:Minimum=0 Replicas *int32 `json:"replicas"` + // +kubebuilder:validation:Required + // +kubebuilder:default=memcached + // Memcached instance name. + MemcachedInstance string `json:"memcachedInstance"` + // +kubebuilder:validation:Required // Name of StorageClass to use for Swift PVs // +kubebuilder:default="" @@ -69,6 +74,11 @@ type SwiftStorageSpec struct { // +kubebuilder:validation:Optional // NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network NetworkAttachments []string `json:"networkAttachments,omitempty"` + + // +kubebuilder:validation:Required + // +kubebuilder:default=memcached + // Memcached instance name. + MemcachedInstance string `json:"memcachedInstance"` } // SwiftStorageStatus defines the observed state of SwiftStorage diff --git a/config/crd/bases/swift.openstack.org_swiftproxies.yaml b/config/crd/bases/swift.openstack.org_swiftproxies.yaml index 86c5cfd6..65c25bb7 100644 --- a/config/crd/bases/swift.openstack.org_swiftproxies.yaml +++ b/config/crd/bases/swift.openstack.org_swiftproxies.yaml @@ -54,6 +54,10 @@ spec: containerImageProxy: description: Swift Proxy Container Image URL type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -269,6 +273,7 @@ spec: required: - containerImageMemcached - containerImageProxy + - memcachedInstance - replicas - secret - serviceUser diff --git a/config/crd/bases/swift.openstack.org_swifts.yaml b/config/crd/bases/swift.openstack.org_swifts.yaml index 45235832..abc5b009 100644 --- a/config/crd/bases/swift.openstack.org_swifts.yaml +++ b/config/crd/bases/swift.openstack.org_swifts.yaml @@ -48,6 +48,10 @@ spec: spec: description: SwiftSpec defines the desired state of Swift properties: + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -73,6 +77,10 @@ spec: containerImageProxy: description: Swift Proxy Container Image URL type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -296,6 +304,7 @@ spec: required: - containerImageMemcached - containerImageProxy + - memcachedInstance - replicas - secret - serviceUser @@ -342,6 +351,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -371,12 +384,14 @@ spec: - containerImageMemcached - containerImageObject - containerImageProxy + - memcachedInstance - replicas - storageClass - storageRequest - swiftConfSecret type: object required: + - memcachedInstance - storageClass - swiftConfSecret - swiftProxy diff --git a/config/crd/bases/swift.openstack.org_swiftstorages.yaml b/config/crd/bases/swift.openstack.org_swiftstorages.yaml index 58841f0e..11f27f20 100644 --- a/config/crd/bases/swift.openstack.org_swiftstorages.yaml +++ b/config/crd/bases/swift.openstack.org_swiftstorages.yaml @@ -63,6 +63,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + memcachedInstance: + default: memcached + description: Memcached instance name. + type: string networkAttachments: description: NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network @@ -92,6 +96,7 @@ spec: - containerImageMemcached - containerImageObject - containerImageProxy + - memcachedInstance - replicas - storageClass - storageRequest diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 782d6483..8e631754 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -159,6 +159,14 @@ rules: - patch - update - watch +- apiGroups: + - memcached.openstack.org + resources: + - memcacheds + verbs: + - get + - list + - watch - apiGroups: - networking.k8s.io resources: diff --git a/controllers/swift_controller.go b/controllers/swift_controller.go index 9b889e47..d986e398 100644 --- a/controllers/swift_controller.go +++ b/controllers/swift_controller.go @@ -353,6 +353,7 @@ func (r *SwiftReconciler) storageCreateOrUpdate(ctx context.Context, instance *s ContainerImageMemcached: instance.Spec.SwiftStorage.ContainerImageMemcached, SwiftConfSecret: instance.Spec.SwiftConfSecret, NetworkAttachments: instance.Spec.SwiftStorage.NetworkAttachments, + MemcachedInstance: instance.Spec.MemcachedInstance, } deployment := &swiftv1.SwiftStorage{ @@ -387,6 +388,7 @@ func (r *SwiftReconciler) proxyCreateOrUpdate(ctx context.Context, instance *swi SwiftConfSecret: instance.Spec.SwiftConfSecret, Override: instance.Spec.SwiftProxy.Override, NetworkAttachments: instance.Spec.SwiftStorage.NetworkAttachments, + MemcachedInstance: instance.Spec.MemcachedInstance, } deployment := &swiftv1.SwiftProxy{ diff --git a/controllers/swiftproxy_controller.go b/controllers/swiftproxy_controller.go index fc4bb943..25a0f77b 100644 --- a/controllers/swiftproxy_controller.go +++ b/controllers/swiftproxy_controller.go @@ -19,11 +19,13 @@ package controllers import ( "context" "fmt" + "strings" "time" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -43,6 +45,7 @@ import ( service "github.com/openstack-k8s-operators/lib-common/modules/common/service" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1" keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" "github.com/openstack-k8s-operators/swift-operator/pkg/swift" @@ -66,6 +69,7 @@ type SwiftProxyReconciler struct { //+kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneservices,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete; //+kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch +//+kubebuilder:rbac:groups=memcached.openstack.org,resources=memcacheds,verbs=get;list;watch; // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. @@ -286,6 +290,44 @@ func (r *SwiftProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request) } password := string(sps.Data[instance.Spec.PasswordSelectors.Service]) + // + // Check for required memcached used for caching + // + memcached, err := r.getSwiftMemcached(ctx, helper, instance) + if err != nil { + if apierrors.IsNotFound(err) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.MemcachedReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.MemcachedReadyWaitingMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, fmt.Errorf("memcached %s not found", instance.Spec.MemcachedInstance) + } + instance.Status.Conditions.Set(condition.FalseCondition( + condition.MemcachedReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.MemcachedReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + + if !memcached.IsReady() { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.MemcachedReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.MemcachedReadyWaitingMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, fmt.Errorf("memcached %s is not ready", memcached.Name) + } + // Mark the Memcached Service as Ready if we get to this point with no errors + instance.Status.Conditions.MarkTrue( + condition.MemcachedReadyCondition, condition.MemcachedReadyMessage) + // run check memcached - end + + // Get the memached server URLs + memcachedServers := strings.Join(memcached.Status.ServerList, ",") + // Create a Secret populated with content from templates/ envVars := make(map[string]env.Setter) tpl := swiftproxy.SecretTemplates( @@ -294,6 +336,7 @@ func (r *SwiftProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request) keystonePublicURL, keystoneInternalURL, password, + memcachedServers, ) err = secret.EnsureSecrets(ctx, helper, instance, tpl, &envVars) if err != nil { @@ -404,3 +447,23 @@ func (r *SwiftProxyReconciler) reconcileDelete(ctx context.Context, instance *sw return ctrl.Result{}, nil } + +// getSwiftMemcached - gets the Memcached instance used for Swift cache backend +func (r *SwiftProxyReconciler) getSwiftMemcached( + ctx context.Context, + h *helper.Helper, + instance *swiftv1beta1.SwiftProxy, +) (*memcachedv1.Memcached, error) { + memcached := &memcachedv1.Memcached{} + err := h.GetClient().Get( + ctx, + types.NamespacedName{ + Name: instance.Spec.MemcachedInstance, + Namespace: instance.Namespace, + }, + memcached) + if err != nil { + return nil, err + } + return memcached, err +} diff --git a/controllers/swiftstorage_controller.go b/controllers/swiftstorage_controller.go index 1d6384ab..6993ecb1 100644 --- a/controllers/swiftstorage_controller.go +++ b/controllers/swiftstorage_controller.go @@ -19,11 +19,13 @@ package controllers import ( "context" "fmt" + "strings" "time" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -37,6 +39,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/kubernetes" + memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" "github.com/openstack-k8s-operators/swift-operator/pkg/swiftstorage" @@ -61,6 +64,7 @@ type SwiftStorageReconciler struct { //+kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch +//+kubebuilder:rbac:groups=memcached.openstack.org,resources=memcacheds,verbs=get;list;watch; // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. @@ -125,6 +129,44 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request serviceLabels := swiftstorage.Labels() envVars := make(map[string]env.Setter) + // + // Check for required memcached used for caching + // + memcached, err := r.getSwiftMemcached(ctx, helper, instance) + if err != nil { + if apierrors.IsNotFound(err) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.MemcachedReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.MemcachedReadyWaitingMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, fmt.Errorf("memcached %s not found", instance.Spec.MemcachedInstance) + } + instance.Status.Conditions.Set(condition.FalseCondition( + condition.MemcachedReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.MemcachedReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + + if !memcached.IsReady() { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.MemcachedReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.MemcachedReadyWaitingMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, fmt.Errorf("memcached %s is not ready", memcached.Name) + } + // Mark the Memcached Service as Ready if we get to this point with no errors + instance.Status.Conditions.MarkTrue( + condition.MemcachedReadyCondition, condition.MemcachedReadyMessage) + // run check memcached - end + + // Get the memached server URLs + memcachedServers := strings.Join(memcached.Status.ServerList, ",") + // Check if there is already an existing ConfigMap and device list. If // not, create an initial device list to bootstrap the cluster with The // weights are simply set to the requested size, this will be changed @@ -142,7 +184,7 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request } // Create a ConfigMap populated with content from templates/ - tpl := swiftstorage.ConfigMapTemplates(instance, serviceLabels) + tpl := swiftstorage.ConfigMapTemplates(instance, serviceLabels, memcachedServers) err = configmap.EnsureConfigMaps(ctx, helper, instance, tpl, &envVars) if err != nil { return ctrl.Result{}, err @@ -237,3 +279,23 @@ func (r *SwiftStorageReconciler) SetupWithManager(mgr ctrl.Manager) error { Owns(&networkingv1.NetworkPolicy{}). Complete(r) } + +// getSwiftMemcached - gets the Memcached instance used for Swift cache backend +func (r *SwiftStorageReconciler) getSwiftMemcached( + ctx context.Context, + h *helper.Helper, + instance *swiftv1beta1.SwiftStorage, +) (*memcachedv1.Memcached, error) { + memcached := &memcachedv1.Memcached{} + err := h.GetClient().Get( + ctx, + types.NamespacedName{ + Name: instance.Spec.MemcachedInstance, + Namespace: instance.Namespace, + }, + memcached) + if err != nil { + return nil, err + } + return memcached, err +} diff --git a/go.mod b/go.mod index 7a20d98b..8dd47d66 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/go-logr/logr v1.4.1 github.com/onsi/ginkgo/v2 v2.14.0 github.com/onsi/gomega v1.30.0 + github.com/openstack-k8s-operators/infra-operator/apis v0.3.0 github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240125201204-a18a1e700034 github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240124141114-55d029e4658b github.com/openstack-k8s-operators/swift-operator/api v0.1.0 diff --git a/go.sum b/go.sum index de41e6e6..a794308e 100644 --- a/go.sum +++ b/go.sum @@ -234,6 +234,8 @@ github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxCMwNRnMjhhIDOWHJowi6q8G6koI= github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4= +github.com/openstack-k8s-operators/infra-operator/apis v0.3.0 h1:omqNm2mG5YOXdNLuUs4fNCvi/2B13njLXfbS2Z4GNUE= +github.com/openstack-k8s-operators/infra-operator/apis v0.3.0/go.mod h1:zqFs5MrBKeaE4HQroUgMWwIkBwmmcygg6sghcidSdCA= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240125201204-a18a1e700034 h1:aEtjPHkCsANdkB8pirv7r9p7DE0KOBwxUvaVA5LPua8= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240125201204-a18a1e700034/go.mod h1:bgVKIMNoFsK3roq5DA8BBn3Cpxh8PRTqYhBgnlRhWvk= github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240124141114-55d029e4658b h1:8tPUN0Aj4MKEltI2pv3vjy2HyxPEAYXcs6UNrz2vzm8= diff --git a/main.go b/main.go index 7203b91e..5b630578 100644 --- a/main.go +++ b/main.go @@ -39,6 +39,7 @@ import ( keystonev1beta1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" "github.com/openstack-k8s-operators/swift-operator/controllers" //+kubebuilder:scaffold:imports @@ -53,6 +54,7 @@ func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(swiftv1beta1.AddToScheme(scheme)) utilruntime.Must(keystonev1beta1.AddToScheme(scheme)) + utilruntime.Must(memcachedv1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } diff --git a/pkg/swiftproxy/templates.go b/pkg/swiftproxy/templates.go index 36719f03..9f59f9cb 100644 --- a/pkg/swiftproxy/templates.go +++ b/pkg/swiftproxy/templates.go @@ -29,12 +29,14 @@ func SecretTemplates( keystonePublicURL string, keystoneInternalURL string, password string, + memcachedServers string, ) []util.Template { templateParameters := make(map[string]interface{}) templateParameters["ServiceUser"] = instance.Spec.ServiceUser templateParameters["ServicePassword"] = password templateParameters["KeystonePublicURL"] = keystonePublicURL templateParameters["KeystoneInternalURL"] = keystoneInternalURL + templateParameters["MemcachedServers"] = memcachedServers return []util.Template{ { diff --git a/pkg/swiftstorage/templates.go b/pkg/swiftstorage/templates.go index a4bff73a..35fbc752 100644 --- a/pkg/swiftstorage/templates.go +++ b/pkg/swiftstorage/templates.go @@ -22,8 +22,9 @@ import ( swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" ) -func ConfigMapTemplates(instance *swiftv1beta1.SwiftStorage, labels map[string]string) []util.Template { +func ConfigMapTemplates(instance *swiftv1beta1.SwiftStorage, labels map[string]string, memcachedServers string) []util.Template { templateParameters := make(map[string]interface{}) + templateParameters["MemcachedServers"] = memcachedServers return []util.Template{ { diff --git a/templates/swiftproxy/config/proxy-server.conf b/templates/swiftproxy/config/proxy-server.conf index d6267d2a..10d9a678 100644 --- a/templates/swiftproxy/config/proxy-server.conf +++ b/templates/swiftproxy/config/proxy-server.conf @@ -13,6 +13,7 @@ use = egg:swift#healthcheck [filter:cache] use = egg:swift#memcache +memcache_servers = {{ .MemcachedServers }} [filter:ratelimit] use = egg:swift#ratelimit diff --git a/templates/swiftstorage/config/object-expirer.conf b/templates/swiftstorage/config/object-expirer.conf index ccb804a7..65f69901 100644 --- a/templates/swiftstorage/config/object-expirer.conf +++ b/templates/swiftstorage/config/object-expirer.conf @@ -12,6 +12,7 @@ use = egg:swift#proxy [filter:cache] use = egg:swift#memcache +memcache_servers = {{ .MemcachedServers }} [filter:catch_errors] use = egg:swift#catch_errors