|  | 
| 1 | 1 | { | 
| 2 | 2 |   local pvc = $.core.v1.persistentVolumeClaim, | 
| 3 | 3 |   local volumeMount = $.core.v1.volumeMount, | 
|  | 4 | +  local volume = $.core.v1.volume, | 
| 4 | 5 |   local container = $.core.v1.container, | 
| 5 | 6 |   local statefulSet = $.apps.v1.statefulSet, | 
| 6 | 7 |   local service = $.core.v1.service, | 
|  | 8 | +  local configMap = $.core.v1.configMap, | 
|  | 9 | + | 
| 7 | 10 |   local isHA = $._config.alertmanager.replicas > 1, | 
|  | 11 | +  local hasFallbackConfig = std.length($._config.alertmanager.fallback_config) > 0, | 
| 8 | 12 |   local peers = if isHA then | 
| 9 | 13 |     [ | 
| 10 | 14 |       'alertmanager-%d.alertmanager.%s.svc.%s.local:%s' % [i, $._config.namespace, $._config.cluster, $._config.alertmanager.gossip_port] | 
|  | 
| 22 | 26 |       'alertmanager.storage.path': '/data', | 
| 23 | 27 |       'alertmanager.storage.gcs.bucketname': '%(cluster)s-cortex-%(namespace)s' % $._config, | 
| 24 | 28 |       'alertmanager.web.external-url': '%s/alertmanager' % $._config.external_url, | 
| 25 |  | -    }, | 
|  | 29 | +    } + if hasFallbackConfig then { | 
|  | 30 | +      'alertmanager.configs.fallback': '/configs/alertmanager_fallback_config.yaml', | 
|  | 31 | +    } else {}, | 
|  | 32 | + | 
|  | 33 | +  alertmanager_fallback_config_map: | 
|  | 34 | +    if hasFallbackConfig then | 
|  | 35 | +      configMap.new('alertmanager-fallback-config') + | 
|  | 36 | +      configMap.withData({ | 
|  | 37 | +        'alertmanager_fallback_config.yaml': $.util.manifestYaml($._config.alertmanager.fallback_config), | 
|  | 38 | +      }) | 
|  | 39 | +    else {}, | 
|  | 40 | + | 
| 26 | 41 | 
 | 
| 27 | 42 |   alertmanager_pvc:: | 
| 28 | 43 |     if $._config.alertmanager_enabled then | 
|  | 
| 51 | 66 |           ['--cluster.peer=%s' % peer for peer in peers] | 
| 52 | 67 |         else [], | 
| 53 | 68 |       ) + | 
| 54 |  | -      container.withVolumeMountsMixin([volumeMount.new('alertmanager-data', '/data')]) + | 
|  | 69 | +      container.withVolumeMountsMixin( | 
|  | 70 | +        [volumeMount.new('alertmanager-data', '/data')] + | 
|  | 71 | +        if hasFallbackConfig then | 
|  | 72 | +          [volumeMount.new('alertmanager-fallback-config', '/configs')] | 
|  | 73 | +        else [] | 
|  | 74 | +      ) + | 
| 55 | 75 |       $.util.resourcesRequests('100m', '1Gi') + | 
| 56 | 76 |       $.util.readinessProbe + | 
| 57 | 77 |       $.jaeger_mixin | 
|  | 
| 67 | 87 |       statefulSet.mixin.spec.selector.withMatchLabels({ name: 'alertmanager' }) + | 
| 68 | 88 |       statefulSet.mixin.spec.template.spec.securityContext.withRunAsUser(0) + | 
| 69 | 89 |       statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') + | 
| 70 |  | -      statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(900) | 
|  | 90 | +      statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(900) + | 
|  | 91 | +      statefulSet.mixin.spec.template.spec.withVolumesMixin( | 
|  | 92 | +        if hasFallbackConfig then | 
|  | 93 | +          [volume.fromConfigMap('alertmanager-fallback-config', 'alertmanager-fallback-config')] | 
|  | 94 | +        else [] | 
|  | 95 | +      ) | 
| 71 | 96 |     else {}, | 
| 72 | 97 | 
 | 
| 73 | 98 |   alertmanager_service: | 
| 74 | 99 |     if $._config.alertmanager_enabled then | 
| 75 | 100 |       if isHA then | 
| 76 | 101 |         $.util.serviceFor($.alertmanager_statefulset) + | 
|  | 102 | +        service.mixin.metadata.withName('alertmanager-headless') + | 
| 77 | 103 |         service.mixin.spec.withClusterIp('None') | 
| 78 | 104 |       else | 
| 79 |  | -        $.util.serviceFor($.alertmanager_statefulset) | 
|  | 105 | +        $.util.serviceFor($.alertmanager_statefulset) + | 
|  | 106 | +        service.mixin.metadata.withName('alertmanager') | 
| 80 | 107 |     else {}, | 
| 81 | 108 | } | 
0 commit comments