Adds common labels for Kubernetes Agent Chart
What does this MR do?
Introduces an option that helps apply a set of labels spread across all
objects associated with the GitLab Kubernetes Agent (kas
) chart. Given the following:
global:
common:
labels:
baz: "bat"
gitlab:
kas:
common:
labels:
foo: "bar"
The label set baz=bat
is applied to all objects created by the GitLab
KAS Chart (foo=bar
is applied to all objects for only the GitLab KAS
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:
kas:
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 GitLab KAS 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.kas.podLabels
>gitlab.kas.common.labels
>global.pod.labels
>global.common.labels
=> Applies to the Deployment object for the GitLab KAS -
gitlab.kas.serviceLabels
>gitlab.kas.common.labels
>global.service.labels
>global.common.labels
=> Applies to the Service object for the GitLab KAS -
gitlab.kas.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
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