Using the Mailroom chart

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab Self-Managed

The Mailroom Chart handles incoming email.

Configuration

yaml
image:
  repository: registry.gitlab.com/gitlab-org/build/cng/gitlab-mailroom
  # tag: v0.9.1
  pullSecrets: []
  # pullPolicy: IfNotPresent

enabled: true

init:
  image: {}
    # repository:
    # tag:
  resources:
    requests:
      cpu: 50m

annotations: {}

# Tolerations for pod scheduling
tolerations: []
affinity: {}
podLabels: {}

hpa:
  minReplicas: 1
  maxReplicas: 2
  cpu:
    targetAverageUtilization: 75

  # Note that the HPA is limited to autoscaling/v2beta1, autoscaling/v2beta2 and autoscaling/v2
  customMetrics: []
  behavior: {}

networkpolicy:
  enabled: false
  egress:
    enabled: false
    rules: []
  ingress:
    enabled: false
    rules: []
  annotations: {}

resources:
  # limits:
  #  cpu: 1
  #  memory: 2G
  requests:
    cpu: 50m
    memory: 150M

## Allow to overwrite under which User and Group we're running.
securityContext:
  runAsUser: 1000
  fsGroup: 1000

## Enable deployment to use a serviceAccount
serviceAccount:
  enabled: false
  create: false
  annotations: {}
  ## Name to be used for serviceAccount, otherwise defaults to chart fullname
  # name:
ParameterDefaultDescription
affinity{}Affinity rules for pod assignment
annotations{}Pod annotations.
deployment.strategy{}Allows one to configure the update strategy utilized by the deployment
deployment.revisionHistoryLimitThe number of previous revisions to keep. When not provided and global.revisionHistoryLimit is unset, the Kubernetes default is used.
enabledtrueMailroom enablement flag
hpa.behavior{scaleDown: {stabilizationWindowSeconds: 300 }}Behavior contains the specifications for up- and downscaling behavior (requires autoscaling/v2beta2 or higher)
hpa.customMetrics[]Custom metrics contains the specifications for which to use to calculate the desired replica count (overrides the default use of Average CPU Utilization configured in targetAverageUtilization)
hpa.cpu.targetTypeUtilizationSet the autoscaling CPU target type, must be either Utilization or AverageValue
hpa.cpu.targetAverageValueSet the autoscaling CPU target value
hpa.cpu.targetAverageUtilization75Set the autoscaling CPU target utilization
hpa.memory.targetTypeSet the autoscaling memory target type, must be either Utilization or AverageValue
hpa.memory.targetAverageValueSet the autoscaling memory target value
hpa.memory.targetAverageUtilizationSet the autoscaling memory target utilization
hpa.maxReplicas2Maximum number of replicas
hpa.minReplicas1Minimum number of replicas
image.pullPolicyIfNotPresentMailroom image pull policy
extraEnvFromList of extra environment variables from other data sources to expose
image.pullSecretsMailroom image pull secrets
image.registryMailroom image registry
image.repositoryregistry.gitlab.com/gitlab-org/build/cng/gitlab-mailroomMailroom image repository
image.tagMailroom image tag
init.image.repositoryMailroom init image repository
init.image.tagMailroom init image tag
init.resources{ requests: { cpu: 50m }}Mailroom init container resource requirements
init.containerSecurityContextinitContainer container specific securityContext
keda.enabledfalseUse KEDA ScaledObjects instead of HorizontalPodAutoscalers
keda.pollingInterval30The interval to check each trigger on
keda.cooldownPeriod300The period to wait after the last trigger reported active before scaling the resource back to 0
keda.minReplicaCounthpa.minReplicasMinimum number of replicas KEDA will scale the resource down to.
keda.maxReplicaCounthpa.maxReplicasMaximum number of replicas KEDA will scale the resource up to.
keda.fallbackKEDA fallback configuration, see the documentation
keda.hpaNamekeda-hpa-{scaled-object-name}The name of the HPA resource KEDA will create.
keda.restoreToOriginalReplicaCountSpecifies whether the target resource should be scaled back to original replicas count after the ScaledObject is deleted
keda.behaviorhpa.behaviorThe specifications for up- and downscaling behavior.
keda.triggersList of triggers to activate scaling of the target resource, defaults to triggers computed from hpa.cpu and hpa.memory
podLabels{}Labels for running Mailroom Pods
common.labels{}Supplemental labels that are applied to all objects created by this chart.
resources{ requests: { cpu: 50m, memory: 150M }}Mailroom resource requirements
networkpolicy.annotations{}Annotations to add to the NetworkPolicy
networkpolicy.egress.enabledfalseFlag to enable egress rules of NetworkPolicy
networkpolicy.egress.rules[]Define a list of egress rules for NetworkPolicy
networkpolicy.enabledfalseFlag for using NetworkPolicy
networkpolicy.ingress.enabledfalseFlag to enable ingress rules of NetworkPolicy
networkpolicy.ingress.rules[]Define a list of ingress rules for NetworkPolicy
securityContext.fsGroup1000Group ID under which the pod should be started
securityContext.runAsUser1000User ID under which the pod should be started
securityContext.fsGroupChangePolicyPolicy for changing ownership and permission of the volume (requires Kubernetes 1.23)
containerSecurityContextOverride container securityContext under which the container is started
containerSecurityContext.runAsUser1000Allow to overwrite the specific security context under which the container is started
serviceAccount.annotations{}Annotations for ServiceAccount
serviceAccount.automountServiceAccountTokenfalseIndicates whether or not the default ServiceAccount access token should be mounted in pods
serviceAccount.enabledfalseIndicates whether or not to use a ServiceAccount
serviceAccount.createfalseIndicates whether or not a ServiceAccount should be created
serviceAccount.nameName of the ServiceAccount. If not set, the full chart name is used
tolerationsTolerations to add to the Mailroom
priorityClassNamePriority class assigned to pods.

Configuring KEDA

This keda section enables the installation of KEDA ScaledObjects instead of regular HorizontalPodAutoscalers. This configuration is optional and can be used when there is a need for autoscaling based on custom or external metrics.

Most settings default to the values set in the hpa section where applicable.

If the following are true, CPU and memory triggers are added automatically based on the CPU and memory thresholds set in the hpa section:

  • triggers is not set.
  • The corresponding request.cpu.request or request.memory.request setting is also set to a non-zero value.

If no triggers are set, the ScaledObject is not created.

Refer to the KEDA documentation for more details about those settings.

NameTypeDefaultDescription
enabledBooleanfalseUse KEDA ScaledObjects instead of HorizontalPodAutoscalers
pollingIntervalInteger30The interval to check each trigger on
cooldownPeriodInteger300The period to wait after the last trigger reported active before scaling the resource back to 0
minReplicaCountIntegerhpa.minReplicasMinimum number of replicas KEDA will scale the resource down to.
maxReplicaCountIntegerhpa.maxReplicasMaximum number of replicas KEDA will scale the resource up to.
fallbackMapKEDA fallback configuration, see the documentation
hpaNameStringkeda-hpa-{scaled-object-name}The name of the HPA resource KEDA will create.
restoreToOriginalReplicaCountBooleanSpecifies whether the target resource should be scaled back to original replicas count after the ScaledObject is deleted
behaviorMaphpa.behaviorThe specifications for up- and downscaling behavior.
triggersArrayList of triggers to activate scaling of the target resource, defaults to triggers computed from hpa.cpu and hpa.memory

Incoming email

By default, incoming email is disabled. There are two methods for reading incoming email:

First, enable it by setting the common settings. Then configure the IMAP settings or Microsoft Graph settings.

These methods can be configured in values.yaml. See the following examples:

IMAP

To enable incoming e-mail for IMAP, provide details of your IMAP server and access credentials using the global.appConfig.incomingEmail settings.

In addition, the requirements for the IMAP email account should be reviewed to ensure that the targeted IMAP account can be used by GitLab for receiving email. Several common email services are also documented on the same page to aid in setting up incoming email.

The IMAP password will still need to be created as a Kubernetes Secret as described in the secrets guide.

Microsoft Graph

See the GitLab documentation on creating an Azure Active Directory application.

Provide the tenant ID, client ID, and client secret. You can find details for these settings in the command line options.

Create a Kubernetes secret containing the client secret as described in the secrets guide.

Reply-by-email

To use the reply-by-email feature, where users can reply to notification emails to comment on issues and MRs, you need to configure both outgoing email and incoming email settings.

Service Desk email

By default, the Service Desk email is disabled.

As with incoming e-mail, enable it by setting the common settings. Then configure the IMAP settings or Microsoft Graph settings.

These options can also be configured in values.yaml. See the following examples:

Service Desk email requires that Incoming email be configured.

IMAP

Provide details of your IMAP server and access credentials using the global.appConfig.serviceDeskEmail settings. You can find details for these settings in the command line options.

Create a Kubernetes secret containing IMAP password as described in the secrets guide.

Microsoft Graph

See the GitLab documentation on creating an Azure Active Directory application.

Provide the tenant ID, client ID, and client secret using the global.appConfig.serviceDeskEmail settings. You can find details for these settings in the command line options.

You will also have to create a Kubernetes secret containing the client secret as described in the secrets guide.

Asymmetric token verification

With the webhook delivery method, mailroom signs each delivery with a token that GitLab verifies. By default, mailroom and GitLab share the authToken secret. A mailroom deployed outside this chart can instead sign tokens with an ES256 private key. GitLab then needs only the matching public key, so the private key never leaves that mailroom.

To trust public keys, store them as fields of one secret, and list the fields in publicKeyFiles.keys. Each field holds one PEM-encoded public key:

yaml
global:
  appConfig:
    incomingEmail:
      publicKeyFiles:
        secret: incoming-email-mailroom-public-keys
        keys: [current.pub]

Configure global.appConfig.serviceDeskEmail.publicKeyFiles the same way for Service Desk email.

The chart mounts the listed fields into the Webservice pods and adds them under public_key_files in gitlab.yml. The authToken stays configured alongside them. GitLab picks the check for each token from its key ID, so it accepts both token types at the same time. You can run the chart mailroom and an external mailroom side by side.

Rotate a public key

GitLab trusts every key listed in keys. To rotate keys without rejecting valid tokens, trust the new key first, switch the signer, and then remove the old key.

Add the key to the secret before you list its field in keys. If you list a field that the secret does not have, GitLab cannot verify tokens signed with that key.

  1. Add the new public key to the secret under a new field. Leave the existing fields unchanged. GitLab matches keys by their content, so the field name is only a label.

  2. Add the new field to keys, keep the old one, and run helm upgrade:

    yaml
    global:
      appConfig:
        incomingEmail:
          publicKeyFiles:
            secret: incoming-email-mailroom-public-keys
            keys: [next.pub, current.pub]

    GitLab now accepts tokens signed with either key. Webservice reads the keys only at startup. Changing keys changes gitlab.yml, which restarts the Webservice pods and loads the new key. Changing only the secret does not restart the pods and has no effect.

  3. Switch the mailroom that signs tokens to the new private key.

  4. After no tokens are signed with the old key, remove its field from keys and run helm upgrade. Then delete the field from the secret.

To roll back, switch the signer back to the old key before you remove the new key from keys.

serviceAccount

This section controls if a ServiceAccount should be created and if the default access token should be mounted in pods.

NameTypeDefaultDescription
annotationsMap{}ServiceAccount annotations.
automountServiceAccountTokenBooleanfalseControls if the default ServiceAccount access token should be mounted in pods. You should not enable this unless it is required by certain sidecars to work properly (for example, Istio).
createBooleanfalseIndicates whether or not a ServiceAccount should be created.
enabledBooleanfalseIndicates whether or not to use a ServiceAccount.
nameStringName of the ServiceAccount. If not set, the full chart name is used.

affinity

For more information, see affinity.