diff --git a/go.mod b/go.mod index cf76f51f86..1e534dda47 100644 --- a/go.mod +++ b/go.mod @@ -83,4 +83,4 @@ require ( ) // Delete when https://github.com/observatorium/observatorium/pull/543 is merged to main branch -replace github.com/observatorium/observatorium => github.com/thibaultmg/observatorium v0.0.0-20231124164749-d47b398822ba +replace github.com/observatorium/observatorium => github.com/thibaultmg/observatorium v0.0.0-20231204171717-54b9405e5fab diff --git a/go.sum b/go.sum index d13e8c857a..e27d3e3d21 100644 --- a/go.sum +++ b/go.sum @@ -1253,8 +1253,8 @@ github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I= -github.com/thibaultmg/observatorium v0.0.0-20231124164749-d47b398822ba h1:C0lH8h/Dh6SCVG6FCNBsn1Rg075gQd3TPBVzjcdCIsk= -github.com/thibaultmg/observatorium v0.0.0-20231124164749-d47b398822ba/go.mod h1:P+7t9O8AitkuZjUhXC4LHw4iwAzTpIrs0tHz8X3xTvM= +github.com/thibaultmg/observatorium v0.0.0-20231204171717-54b9405e5fab h1:OLXEyHPt3e3Sz/w+MOU0uxwIPD7U1XRfHia1xs1TjuM= +github.com/thibaultmg/observatorium v0.0.0-20231204171717-54b9405e5fab/go.mod h1:P+7t9O8AitkuZjUhXC4LHw4iwAzTpIrs0tHz8X3xTvM= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= diff --git a/resources/services/app-sre-stage-01/rhobs/observatorium-metrics-query-frontend-template.yaml b/resources/services/app-sre-stage-01/rhobs/observatorium-metrics-query-frontend-template.yaml index 4337b384b9..4d566db786 100755 --- a/resources/services/app-sre-stage-01/rhobs/observatorium-metrics-query-frontend-template.yaml +++ b/resources/services/app-sre-stage-01/rhobs/observatorium-metrics-query-frontend-template.yaml @@ -4,6 +4,170 @@ metadata: creationTimestamp: null name: observatorium-thanos-query-frontend objects: +- apiVersion: apps/v1 + kind: Deployment + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + name: observatorium-thanos-query-frontend + namespace: rhobs + spec: + replicas: ${{REPLICAS}} + selector: + matchLabels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + strategy: {} + template: + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + namespace: rhobs + spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/instance + operator: In + values: + - observatorium + - key: app.kubernetes.io/name + operator: In + values: + - memcached + topologyKey: kubernetes.io/hostname + weight: 100 + containers: + - args: + - --conn-limit=3072 + - --max-item-size=5m + - --memory-limit=2048 + - --verbose=true + image: quay.io/app-sre/memcached:1.5 + imagePullPolicy: IfNotPresent + name: observatorium-thanos-query-frontend + ports: + - containerPort: 11211 + name: client + protocol: TCP + resources: + limits: + memory: ${MEMORY_LIMIT} + requests: + cpu: ${CPU_REQUEST} + memory: ${MEMORY_REQUEST} + terminationMessagePolicy: FallbackToLogsOnError + - args: + - --memcached.address=localhost:0 + - --web.listen-address=:9150 + image: quay.io/prometheus/memcached-exporter:v0.13.0 + imagePullPolicy: IfNotPresent + name: memcached-exporter + ports: + - containerPort: 9150 + name: metrics + protocol: TCP + resources: + limits: + cpu: 200m + memory: 200Mi + requests: + cpu: 50m + memory: 50Mi + terminationMessagePolicy: FallbackToLogsOnError + nodeSelector: + kubernetes.io/os: linux + serviceAccountName: observatorium-thanos-query-frontend + terminationGracePeriodSeconds: 120 +- apiVersion: v1 + kind: Service + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + name: observatorium-thanos-query-frontend + namespace: rhobs + spec: + clusterIP: None + ports: + - name: client + port: 11211 + protocol: TCP + targetPort: 11211 + - name: metrics + port: 9150 + protocol: TCP + targetPort: 9150 + selector: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium +- apiVersion: v1 + imagePullSecrets: + - name: quay.io + kind: ServiceAccount + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + name: observatorium-thanos-query-frontend + namespace: rhobs +- apiVersion: monitoring.coreos.com/v1 + kind: ServiceMonitor + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + prometheus: app-sre + name: observatorium-thanos-query-frontend + namespace: openshift-customer-monitoring + spec: + endpoints: + - port: metrics + relabelings: + - action: replace + separator: / + sourceLabels: + - namespace + - pod + targetLabel: instance + namespaceSelector: + matchNames: + - rhobs + selector: + matchLabels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium - apiVersion: route.openshift.io/v1 kind: Route metadata: @@ -168,6 +332,18 @@ objects: - --query-frontend.downstream-url=http://observatorium-thanos-query.rhobs.svc.cluster.local:10902 - --query-frontend.log-queries-longer-than=5s - --query-range.max-retries-per-request=0 + - | + --query-range.response-cache-config=type: MEMCACHED + config: + addresses: + - dnssrv+_client._tcp.observatorium-thanos-query-range-cache-memcached.rhobs.svc + timeout: 2s + max_idle_connections: 1300 + max_async_concurrency: 200 + max_async_buffer_size: 2000000 + max_get_multi_concurrency: 1000 + max_item_size: 64MiB + max_get_multi_batch_size: 100 - --query-range.split-interval=1d - | --tracing.config=type: JAEGER @@ -293,6 +469,25 @@ objects: - name: tls secret: secretName: query-frontend-tls +- apiVersion: policy/v1 + kind: PodDisruptionBudget + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + name: observatorium-thanos-query-frontend + namespace: rhobs + spec: + maxUnavailable: 1 + selector: + matchLabels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium parameters: - name: LOG_LEVEL value: warn diff --git a/resources/services/telemeter-prod-01/rhobs/observatorium-metrics-query-frontend-template.yaml b/resources/services/telemeter-prod-01/rhobs/observatorium-metrics-query-frontend-template.yaml index 86ecef1eb1..ed51cca806 100755 --- a/resources/services/telemeter-prod-01/rhobs/observatorium-metrics-query-frontend-template.yaml +++ b/resources/services/telemeter-prod-01/rhobs/observatorium-metrics-query-frontend-template.yaml @@ -4,6 +4,170 @@ metadata: creationTimestamp: null name: observatorium-thanos-query-frontend objects: +- apiVersion: apps/v1 + kind: Deployment + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + name: observatorium-thanos-query-frontend + namespace: rhobs + spec: + replicas: ${{REPLICAS}} + selector: + matchLabels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + strategy: {} + template: + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + namespace: rhobs + spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/instance + operator: In + values: + - observatorium + - key: app.kubernetes.io/name + operator: In + values: + - memcached + topologyKey: kubernetes.io/hostname + weight: 100 + containers: + - args: + - --conn-limit=3072 + - --max-item-size=5m + - --memory-limit=2048 + - --verbose=true + image: quay.io/app-sre/memcached:1.5 + imagePullPolicy: IfNotPresent + name: observatorium-thanos-query-frontend + ports: + - containerPort: 11211 + name: client + protocol: TCP + resources: + limits: + memory: ${MEMORY_LIMIT} + requests: + cpu: ${CPU_REQUEST} + memory: ${MEMORY_REQUEST} + terminationMessagePolicy: FallbackToLogsOnError + - args: + - --memcached.address=localhost:0 + - --web.listen-address=:9150 + image: quay.io/prometheus/memcached-exporter:v0.13.0 + imagePullPolicy: IfNotPresent + name: memcached-exporter + ports: + - containerPort: 9150 + name: metrics + protocol: TCP + resources: + limits: + cpu: 200m + memory: 200Mi + requests: + cpu: 50m + memory: 50Mi + terminationMessagePolicy: FallbackToLogsOnError + nodeSelector: + kubernetes.io/os: linux + serviceAccountName: observatorium-thanos-query-frontend + terminationGracePeriodSeconds: 120 +- apiVersion: v1 + kind: Service + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + name: observatorium-thanos-query-frontend + namespace: rhobs + spec: + clusterIP: None + ports: + - name: client + port: 11211 + protocol: TCP + targetPort: 11211 + - name: metrics + port: 9150 + protocol: TCP + targetPort: 9150 + selector: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium +- apiVersion: v1 + imagePullSecrets: + - name: quay.io + kind: ServiceAccount + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + name: observatorium-thanos-query-frontend + namespace: rhobs +- apiVersion: monitoring.coreos.com/v1 + kind: ServiceMonitor + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + app.kubernetes.io/version: "1.5" + prometheus: app-sre + name: observatorium-thanos-query-frontend + namespace: openshift-customer-monitoring + spec: + endpoints: + - port: metrics + relabelings: + - action: replace + separator: / + sourceLabels: + - namespace + - pod + targetLabel: instance + namespaceSelector: + matchNames: + - rhobs + selector: + matchLabels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium - apiVersion: route.openshift.io/v1 kind: Route metadata: @@ -168,6 +332,18 @@ objects: - --query-frontend.downstream-url=http://observatorium-thanos-query.rhobs.svc.cluster.local:10902 - --query-frontend.log-queries-longer-than=5s - --query-range.max-retries-per-request=0 + - | + --query-range.response-cache-config=type: MEMCACHED + config: + addresses: + - dnssrv+_client._tcp.observatorium-thanos-query-range-cache-memcached.rhobs.svc + timeout: 2s + max_idle_connections: 1300 + max_async_concurrency: 200 + max_async_buffer_size: 2000000 + max_get_multi_concurrency: 1000 + max_item_size: 64MiB + max_get_multi_batch_size: 100 - --query-range.split-interval=1d - | --tracing.config=type: JAEGER @@ -293,6 +469,25 @@ objects: - name: tls secret: secretName: query-frontend-tls +- apiVersion: policy/v1 + kind: PodDisruptionBudget + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium + name: observatorium-thanos-query-frontend + namespace: rhobs + spec: + maxUnavailable: 1 + selector: + matchLabels: + app.kubernetes.io/component: memcached + app.kubernetes.io/instance: observatorium + app.kubernetes.io/name: memcached + app.kubernetes.io/part-of: observatorium parameters: - name: LOG_LEVEL value: warn diff --git a/services_go/observatorium/cache.go b/services_go/observatorium/cache.go new file mode 100644 index 0000000000..05c29f9179 --- /dev/null +++ b/services_go/observatorium/cache.go @@ -0,0 +1,77 @@ +package observatorium + +import ( + "maps" + + "github.com/observatorium/observatorium/configuration_go/abstr/kubernetes/memcached" + "github.com/observatorium/observatorium/configuration_go/k8sutil" + monv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + policyv1 "k8s.io/api/policy/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" +) + +func makeMemcached(name, namespace string, preManifestHook func(*memcached.MemcachedDeployment)) k8sutil.ObjectMap { + // K8s config + memcachedDeployment := memcached.NewMemcachedStatefulSet() + memcachedDeployment.Name = name + // memcachedDeployment.CommonLabels[observatoriumInstanceLabel] = instanceName + // memcachedDeployment.CommonLabels[k8sutil.ComponentLabel] = component + memcachedDeployment.Image = "quay.io/app-sre/memcached" + memcachedDeployment.ImageTag = "1.5" + memcachedDeployment.Namespace = namespace + memcachedDeployment.Replicas = 1 + delete(memcachedDeployment.PodResources.Limits, corev1.ResourceCPU) + memcachedDeployment.SecurityContext = nil + memcachedDeployment.PodResources.Requests[corev1.ResourceCPU] = resource.MustParse("500m") + memcachedDeployment.PodResources.Requests[corev1.ResourceMemory] = resource.MustParse("2Gi") + memcachedDeployment.PodResources.Limits[corev1.ResourceMemory] = resource.MustParse("3Gi") + memcachedDeployment.ExporterImage = "quay.io/prometheus/memcached-exporter" + memcachedDeployment.ExporterImageTag = "v0.13.0" + + // Compactor config + memcachedDeployment.Options.MemoryLimit = 2048 + memcachedDeployment.Options.MaxItemSize = "5m" + memcachedDeployment.Options.ConnLimit = 3072 + memcachedDeployment.Options.Verbose = true + + // Execute preManifestsHook + if preManifestHook != nil { + preManifestHook(memcachedDeployment) + } + + // Post process + manifests := memcachedDeployment.Manifests() + postProcessServiceMonitor(getObject[*monv1.ServiceMonitor](manifests), memcachedDeployment.Namespace) + addQuayPullSecret(getObject[*corev1.ServiceAccount](manifests)) + + // Add pod disruption budget + labels := maps.Clone(getObject[*appsv1.Deployment](manifests).ObjectMeta.Labels) + delete(labels, k8sutil.VersionLabel) + manifests["store-index-cache-pdb"] = &policyv1.PodDisruptionBudget{ + TypeMeta: metav1.TypeMeta{ + Kind: "PodDisruptionBudget", + APIVersion: policyv1.SchemeGroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: memcachedDeployment.Name, + Namespace: namespace, + Labels: labels, + }, + Spec: policyv1.PodDisruptionBudgetSpec{ + MaxUnavailable: &intstr.IntOrString{ + + Type: intstr.Int, + IntVal: 1, + }, + Selector: &metav1.LabelSelector{ + MatchLabels: labels, + }, + }, + } + + return manifests +} diff --git a/services_go/observatorium/metrics.go b/services_go/observatorium/metrics.go index e0a8b0cf09..63a5f9c526 100644 --- a/services_go/observatorium/metrics.go +++ b/services_go/observatorium/metrics.go @@ -56,18 +56,19 @@ var storeAutoShardRelabelConfigMap string // ObservatoriumMetrics contains the configuration common to all metrics instances in an observatorium instance // and a list of ObservatoriumMetricsInstance configuring the individual metrics instances. type ObservatoriumMetrics struct { - Namespace string - ThanosImageTag string - Instances []*ObservatoriumMetricsInstance - ReceiveLimitsGlobal receive.GlobalLimitsConfig - ReceiveLimitsDefault receive.DefaultLimitsConfig - ReceiveControllerImageTag string - ReceiveRouterPreManifestsHook func(*receive.Router) - QueryRulePreManifestsHook func(*query.QueryDeployment) - QueryAdhocPreManifestsHook func(*query.QueryDeployment) - QueryFrontendPreManifestsHook func(*queryfrontend.QueryFrontendDeployment) - storesRegister []string - queryAdhocURL string + Namespace string + ThanosImageTag string + Instances []*ObservatoriumMetricsInstance + ReceiveLimitsGlobal receive.GlobalLimitsConfig + ReceiveLimitsDefault receive.DefaultLimitsConfig + ReceiveControllerImageTag string + ReceiveRouterPreManifestsHook func(*receive.Router) + QueryRulePreManifestsHook func(*query.QueryDeployment) + QueryAdhocPreManifestsHook func(*query.QueryDeployment) + QueryFrontendPreManifestsHook func(*queryfrontend.QueryFrontendDeployment) + QueryFrontendCachePreManifestsHook func(*memcached.MemcachedDeployment) + storesRegister []string + queryAdhocURL string } // ObservatoriumMetricsInstance contains the configuration for a metrics instance in an observatorium instance. @@ -153,6 +154,19 @@ func (o *ObservatoriumMetrics) makeQueryFrontend() encoding.Encoder { queryFrontend.Options.LabelsMaxRetriesPerRequest = &zero queryFrontend.Options.LabelsDefaultTimeRange = model.Duration(14 * 24 * time.Hour) queryFrontend.Options.CacheCompressionType = queryfrontend.CacheCompressionTypeSnappy + cacheName := "observatorium-thanos-query-range-cache-memcached" + queryFrontend.Options.QueryRangeResponseCacheConfig = cache.NewResponseCacheConfig(memcachedclientcfg.MemcachedClientConfig{ + Addresses: []string{ + fmt.Sprintf("dnssrv+_client._tcp.%s.%s.svc", cacheName, o.Namespace), + }, + MaxAsyncBufferSize: 2 * 10e5, + MaxAsyncConcurrency: 200, + MaxGetMultiBatchSize: 100, + MaxGetMultiConcurrency: 1000, + MaxIdleConnections: 1300, + MaxItemSize: "64MiB", + Timeout: 2 * time.Second, + }) // Execute preManifestsHook if o.QueryFrontendPreManifestsHook != nil { @@ -202,6 +216,12 @@ func (o *ObservatoriumMetrics) makeQueryFrontend() encoding.Encoder { }, } + // Add cache + res := makeMemcached(queryFrontend.Name, o.Namespace, o.QueryFrontendCachePreManifestsHook) + for k, v := range res { + manifests[k] = v + } + // Wrap in template, add parameters defaultParams := defaultTemplateParams(defaultTemplateParamsConfig{ LogLevel: string(queryFrontend.Options.LogLevel), @@ -940,12 +960,26 @@ func (o *ObservatoriumMetrics) makeStore(instanceCfg *ObservatoriumMetricsInstan } // Add index cache - for k, v := range o.makeStoreCache(indexCacheName, "store-index-cache", instanceCfg.InstanceName, instanceCfg.IndexCachePreManifestsHook) { + cachePreManHook := func(memdep *memcached.MemcachedDeployment) { + memdep.CommonLabels[observatoriumInstanceLabel] = instanceCfg.InstanceName + memdep.CommonLabels[k8sutil.ComponentLabel] = "store-index-cache" + if instanceCfg.IndexCachePreManifestsHook != nil { + instanceCfg.IndexCachePreManifestsHook(memdep) + } + } + for k, v := range makeMemcached(indexCacheName, o.Namespace, cachePreManHook) { manifests["index-cache-"+k] = v } // Add bucket cache - for k, v := range o.makeStoreCache(bucketCacheName, "store-bucket-cache", instanceCfg.InstanceName, instanceCfg.BucketCachePreManifestsHook) { + cachePreManHook = func(memdep *memcached.MemcachedDeployment) { + memdep.CommonLabels[observatoriumInstanceLabel] = instanceCfg.InstanceName + memdep.CommonLabels[k8sutil.ComponentLabel] = "store-bucket-cache" + if instanceCfg.BucketCachePreManifestsHook != nil { + instanceCfg.BucketCachePreManifestsHook(memdep) + } + } + for k, v := range makeMemcached(bucketCacheName, o.Namespace, cachePreManHook) { manifests["bucket-cache-"+k] = v } @@ -964,68 +998,6 @@ func (o *ObservatoriumMetrics) makeStore(instanceCfg *ObservatoriumMetricsInstan return NewDefaultTemplateYAML(encoding.GhodssYAML(template[""]), storeStatefulSet.Name) } -func (o *ObservatoriumMetrics) makeStoreCache(name, component, instanceName string, preManifestHook func(*memcached.MemcachedDeployment)) k8sutil.ObjectMap { - // K8s config - memcachedDeployment := memcached.NewMemcachedStatefulSet() - memcachedDeployment.Name = name - memcachedDeployment.CommonLabels[observatoriumInstanceLabel] = instanceName - memcachedDeployment.CommonLabels[k8sutil.ComponentLabel] = component - memcachedDeployment.Image = "quay.io/app-sre/memcached" - memcachedDeployment.ImageTag = "1.5" - memcachedDeployment.Namespace = o.Namespace - memcachedDeployment.Replicas = 1 - delete(memcachedDeployment.PodResources.Limits, corev1.ResourceCPU) - memcachedDeployment.SecurityContext = nil - memcachedDeployment.PodResources.Requests[corev1.ResourceCPU] = resource.MustParse("500m") - memcachedDeployment.PodResources.Requests[corev1.ResourceMemory] = resource.MustParse("2Gi") - memcachedDeployment.PodResources.Limits[corev1.ResourceMemory] = resource.MustParse("3Gi") - memcachedDeployment.ExporterImage = "quay.io/prometheus/memcached-exporter" - memcachedDeployment.ExporterImageTag = "v0.13.0" - - // Compactor config - memcachedDeployment.Options.MemoryLimit = 2048 - memcachedDeployment.Options.MaxItemSize = "5m" - memcachedDeployment.Options.ConnLimit = 3072 - memcachedDeployment.Options.Verbose = true - - // Execute preManifestsHook - if preManifestHook != nil { - preManifestHook(memcachedDeployment) - } - - // Post process - manifests := memcachedDeployment.Manifests() - postProcessServiceMonitor(getObject[*monv1.ServiceMonitor](manifests), memcachedDeployment.Namespace) - addQuayPullSecret(getObject[*corev1.ServiceAccount](manifests)) - - // Add pod disruption budget - labels := maps.Clone(getObject[*appsv1.Deployment](manifests).ObjectMeta.Labels) - delete(labels, k8sutil.VersionLabel) - manifests["store-index-cache-pdb"] = &policyv1.PodDisruptionBudget{ - TypeMeta: metav1.TypeMeta{ - Kind: "PodDisruptionBudget", - APIVersion: policyv1.SchemeGroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: memcachedDeployment.Name, - Namespace: o.Namespace, - Labels: labels, - }, - Spec: policyv1.PodDisruptionBudgetSpec{ - MaxUnavailable: &intstr.IntOrString{ - - Type: intstr.Int, - IntVal: 1, - }, - Selector: &metav1.LabelSelector{ - MatchLabels: labels, - }, - }, - } - - return manifests -} - type kubeObject interface { *corev1.Service | *appsv1.StatefulSet | *appsv1.Deployment | *monv1.ServiceMonitor | *corev1.ServiceAccount }