Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(jsonnet)!: convert read statefulset into deployment for loki-simple-scalable #13977

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions production/ksonnet/loki-simple-scalable/read.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ 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,

_config+:: {
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',
Expand All @@ -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'),
Expand Down
Loading