Skip to content

Adds common labels for the Pages chart

John Skarbek requested to merge jts/2465-pages into master

What does this MR do?

Introduces an option that helps apply a set of labels spread across all objects associated with the Pages chart. Given the following:

global:
  common:
    labels:
      baz: "bat"
gitlab-pages:
  common:
    labels:
      foo: "bar"

The label set baz=bat is applied to all objects created by the Pages Chart ( this is to expand to encompass all objects in the future, but this MR is already large ). The label set foo=bar is applied to all objects for only the Pages Chart.

There are additional methods we can apply labels to various objects.

global:
  common:
    labels:
      common: label
  pod:
    labels:
      common_pod: label
  service:
    labels:
      common_service: label
gitlab-pages:
  podLabels:
    extra_pod: label
  serviceLabels:
    extra_service: label

We expect to see all labels appropriately applied to the necessary objects. We merge items for the chart that we are operating on into the common labels to help avoid creating duplicate labels. Example, labels added specifically to the Pages chart are merged into the labels that are provided to the global.common.labels section. We attempt to manage precedence as best possible leveraging the merge function. Helm performs the following when building the template:

  • gitlab-pages.podLabels > gitlab-pages.common.labels > global.pod.labels > global.common.labels => Applies to the Statefulset object for Pages
  • gitlab-pages.serviceLabels > gitlab-pages.common.labels > global.service.labels > global.common.labels => Applies to the Service object for the Pages
  • gitlab-pages.common.labels > global.common.labels => Applies to essentially all other objects other than the above.

Note that we do not interfere with the standard set of labels that we generate in the _application.tpl. Users will still have the chance of creating labels that may interfere with each other, but the possibility should be low as the items generated us in gitlab.standardLabels are very minimal, would interfere with label selectors, and very common in the helm ecosystem.

Should labels be repetitive, Helm will NOT bail, Kubernetes will NOT throw a warning, instead Kubernetes will take in the last key value pair in the label hash. It is considered invalid YAML and will mark the appropriate keys as duplicates, and as such this will fail any YAML linting.

Related issues

#2465 (closed)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • Merge Request Title and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Tests added
  • Integration tests added to GitLab QA
  • Equivalent MR/issue for omnibus-gitlab opened
Edited by John Skarbek

Merge request reports