From d6550f08c7cf0a8aed61dedee4e39bf0b26370a9 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Tue, 27 Aug 2024 17:04:24 +0000 Subject: [PATCH] chore(jsonnet): convert read statefulset into deployment for loki-simple-scalable --- .../loki-simple-scalable/read.libsonnet | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/production/ksonnet/loki-simple-scalable/read.libsonnet b/production/ksonnet/loki-simple-scalable/read.libsonnet index 3bdd98d76aafc..99ed09cc97b6f 100644 --- a/production/ksonnet/loki-simple-scalable/read.libsonnet +++ b/production/ksonnet/loki-simple-scalable/read.libsonnet @@ -2,8 +2,7 @@ local k = import 'ksonnet-util/kausal.libsonnet'; { local container = k.core.v1.container, - local pvc = k.core.v1.persistentVolumeClaim, - local statefulSet = k.apps.v1.statefulSet, + local deployment = k.apps.v1.deployment, local volumeMount = k.core.v1.volumeMount, local service = k.core.v1.service, @@ -11,12 +10,6 @@ local k = import 'ksonnet-util/kausal.libsonnet'; read_replicas: 3, }, - // Use PVC for queriers instead of node disk. - read_pvc:: - pvc.new('read-data') + - pvc.mixin.spec.resources.withRequests({ storage: '10Gi' }) + - pvc.mixin.spec.withAccessModes(['ReadWriteOnce']), - read_args:: $._config.commonArgs { target: 'read', @@ -26,28 +19,24 @@ local k = import 'ksonnet-util/kausal.libsonnet'; container.new('read', $._images.read) + container.withPorts($.util.defaultPorts) + container.withArgsMixin(k.util.mapToFlags($.read_args)) + - container.withVolumeMountsMixin([volumeMount.new('read-data', '/data')]) + container.mixin.readinessProbe.httpGet.withPath('/ready') + container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) + container.mixin.readinessProbe.withInitialDelaySeconds(15) + container.mixin.readinessProbe.withTimeoutSeconds(1), - read_statefulset: - statefulSet.new('read', $._config.read_replicas, [$.read_container], $.read_pvc) + - statefulSet.mixin.spec.withServiceName('read') + - statefulSet.mixin.metadata.withLabels({ app: $._config.headless_service_name, name: 'read' }) + - statefulSet.mixin.spec.selector.withMatchLabels({ name: 'read' }) + - statefulSet.mixin.spec.template.metadata.withLabels({ name: 'read', app: $._config.headless_service_name }) + + read_deployment: + deployment.new('read', $._config.read_replicas, [$.read_container]) + + deployment.mixin.metadata.withLabels({ app: $._config.headless_service_name, name: 'read' }) + + deployment.mixin.spec.selector.withMatchLabels({ name: 'read' }) + + deployment.mixin.spec.template.metadata.withLabels({ name: 'read', app: $._config.headless_service_name }) + $._config.config_hash_mixin + k.util.configVolumeMount('loki', '/etc/loki') + k.util.antiAffinity + - statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') + - statefulSet.mixin.spec.template.spec.securityContext.withFsGroup(10001) + // 10001 is the group ID assigned to Loki in the Dockerfile - statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800) + - statefulSet.mixin.spec.withPodManagementPolicy('Parallel'), + deployment.mixin.spec.template.spec.securityContext.withFsGroup(10001) + // 10001 is the group ID assigned to Loki in the Dockerfile + deployment.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800), read_service: - k.util.serviceFor($.read_statefulset) + + k.util.serviceFor($.read_deployment) + service.mixin.spec.withType('ClusterIP') + service.mixin.spec.withPorts([ k.core.v1.servicePort.newNamed('read-http-metrics', 80, 'http-metrics'),